Direction modifiers: Difference between revisions
m (code formatting!) |
(fixed opp cw rndne example) |
||
(One intermediate revision by one other user not shown) | |||
Line 8: | Line 8: | ||
==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. For example, <code># | '''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>#go rndp e</code> causes the object to attempt to move one of two directions perpendicular to east, that is, randomly north or south. For more information, see [[Random directions#rndp|rndp]]. | ||
==Combining Direction Modifiers== | ==Combining Direction Modifiers== | ||
Line 20: | Line 20: | ||
</pre> | </pre> | ||
And <code>opp | And <code>opp cw rndne</code> would evaluate this way: | ||
<pre> | <pre> | ||
opp | opp cw rndne | ||
= opp (cw (randomly n or e)) | = opp (cw (randomly n or e)) | ||
= opp (randomly e or s) | = opp (randomly e or s) |
Latest revision as of 00:34, 22 April 2023
In ZZT-OOP, a direction modifier is a word that prefixes a direction to create a new direction. If you like, you may think of them (in math terms) as relations which take a given "input" direction and produce an "output." They are explained in detail below.
cw and ccw
cw and ccw are ZZT-OOP direction modifiers which modify the direction clockwise and counter-clockwise, respectively. For example, cw n
evaluates to e
, but ccw n
evaluates to w
.
opp
opp is a ZZT-OOP direction modifier which evaluates to the exact opposite of the given direction. For example, opp n
evaluates to s
.
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, #go rndp e
causes the object to attempt to move one of two directions perpendicular to east, that is, randomly north or south. For more information, see rndp.
Combining Direction Modifiers
Multiple direction modifiers can be combined in a single line. Lines written this way will cause the object to treat each modifier as "modifying" the rest of the written direction, so that it is "evaluated" in pairs from right-to-left. As a concrete example, the following combination opp cw n
evaluates like this:
opp cw n = opp (cw n) = opp e = w
And opp cw rndne
would evaluate this way:
opp cw rndne = opp (cw (randomly n or e)) = opp (randomly e or s) = randomly w or n
ZZT-OOP | |
---|---|
Prefixes |
|
Messages | |
Directions | |
Flags | |
Commands |