Random directions: Difference between revisions

From Wiki of ZZT
Jump to navigation Jump to search
(created page.)
 
m (formatting mostly.)
Line 3: Line 3:


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


==rndne==
==rndne==
'''rndne''' is a ZZT-OOP direction which causes the object to choose randomly from its north or east during play.
'''rndne''' is a ZZT-OOP direction which causes the object to choose randomly from its north or east during play. For example, <code>#if blocked ne #send label</code> 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 <code>:label</code> if it is blocked.
 
Example: <code>#if blocked ne #send label</code> will cause the object to check whether it is blocked randomly to the north or to the east, and it will #send itself to the label <code>:label</code> if it is blocked.


==rnd==
==rnd==
'''rnd''' is a ZZT-OOP direction which causes the object to choose randomly from its north, south, east, or west during play.
'''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.
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, <code>#put rnd white boulder</code> 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.
 
Example: <code>#put rnd white boulder</code> 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==
'''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.
'''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, <code>#move rndp e</code> causes the object to attempt to move one of two directions perpendicular to east, that is, randomly north or south.
 
Examples:


<code>#move rndp e</code> 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, <code>#move rndp rndne</code> 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.
<code>#move rndp rndne</code> 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.


{{ZZT-OOP navbox}}
{{ZZT-OOP navbox}}

Revision as of 01:43, 7 February 2021

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, #move 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.