Procedural Randomness

version 2 by Aaron Reed

  • Home page
  • Beginning
  • Previous
  • Next



  • Example: ** Château Générique - Randomized but sticky room descriptions.

    Say we wanted to create unimportant details for a large number of rooms with some randomized text. It would seem strange for this text to change every time we returned to the room or typed "look," breaking our suspension of disbelief in the constancy of the world.

    Here we create a 5x5 grid of rooms with names and descriptions that are random, but consistently so: when we return to a room we find everything precisely as we left it.

        "Château Générique".

        Include Procedural Randomness by Aaron Reed.

        R1 is west of R2 and north of R6. R2 is west of R3 and north of R7. R3 is west of R4 and north of R8. R4 is west of R5 and north of R9. R5 is north of R10. R6 is west of R7 and north of R11. R7 is west of R8 and north of R12. R8 is west of R9 and north of R13. R9 is west of R10 and north of R14. R10 is north of R15. R11 is west of R12 and north of R16. R12 is west of R13 and north of R17. R13 is west of R14 and north of R18. R14 is west of R15 and north of R19. R15 is north of R20. R16 is west of R17 and north of R21. R17 is west of R18 and north of R22. R18 is west of R19 and north of R23. R19 is west of R20 and north of R24. R20 is north of R25. R21 is west of R22. R22 is south of R17 and west of R23. R23 is west of R24 and south of R18. R24 is west of R25 and south of R19.

        Rule for printing the name of a room:
            set seed to location;
            say "[one of]Spacious [or]Crooked [or]Blue [or]Wide [or]Open [or]French [or]Carpeted [or]Lonely [or]Grand [or]Master [or]Guest [with procedural randomness]";
            say "[one of]Bedroom [or]Hall [or]Ballroom [or]Kitchen [or]Foyer [or]Dining Room [or]Library [or]Study [or]Game Room [or]Corridor [or]Spare Room [or]Den [with procedural randomness]".
        
        The description of a room is usually "[special-desc].".

        To say special-desc:
            set seed to location;
            say "[one of]Only the finest[or]Ridiculously expensive[or]Posh[or]Fashionably antique[with procedural randomness][one of] furnishings[or] cabinets[or] furniture[or] centerpieces[with procedural randomness] and[one of] tasteful[or] outrageous[or] postmodern[or] sophisticated[with procedural randomness] [one of]carpeting[or]wall panelling[or]oak floorboards[or]chandeliers[with procedural randomness]";
            say "[if a procedurally random chance of 1 in 3 succeeds]; [one of]but strangely drafty[or]quintessentially in vogue[or]a faint smell of must lingers[with procedural randomness][end if]. ";
            say "The exits are to [a list of viable directions]".
        
        Definition: a direction is viable if the room it from the location is a room.

        Test me with "south / east / north / west".