Random directions

From Wiki of ZZT
Revision as of 04:10, 7 February 2021 by KKairos (talk | contribs) (grammar)
Jump to navigation Jump to search

There are three random directions in ZZT-OOP: rndns, rndne, and rnd, and one random direction modifier: rndp. They are explained in detail below. rndns, rndne, and rnd are all valid directions usable with direction modifiers.

rndns

rndns is a ZZT-OOP direction which causes the object to choose randomly from its north or south during play. For example, /rndns will cause the object to randomly move north or south.

rndne

rndne is a ZZT-OOP direction which causes the object to choose randomly from its north or east during play. For example, #if blocked ne #send label will cause the object to check whether it is blocked to the north or to the east at random, and it will #send itself to the label :label if it is blocked.

rnd

rnd is a ZZT-OOP direction which causes the object to choose randomly from its north, south, east, or west during play.

Despite having all four directions in its possibility space, the possibilities are not even. East and west are chosen at 1/3 probability each, and north and south only occur at 1/6 probability each. For example, #put rnd white boulder will cause the object to attempt to put a white boulder on the tile randomly north, south, east, or west of itself, with east and west being twice as likely as north and south.

rndp

rndp is a ZZT-OOP direction modifier which causes the object to choose a random direction perpendicular to the succeeding direction, rather than simply use the succeeding direction. For example, #move rndp e causes the object to attempt to move one of two directions perpendicular to east, that is, randomly north or south.

As a direction modifier, rndp can be combined with the three proper random directions above to make new directions. For example, #go rndp rndne causes the object to attempt to move one of two directions perpendicular to a direction randomly chosen from north or east, that is, randomly north, south, east, or west, with equal probability of each direction being chosen.