Sections of a PuzzleScript file

A puzzlescript file is divided into the following sections.

Mappings

So tags let you define a name that is expanded into its values, but within each expansion all the values will be the same, and sometimes you don't want that. Sometimes you want the expansion to be rock-paper-scissors in one part of a rule and scissors-rock-paper in another part. Or you want cat-dog-bird in one part and miaow-woof-tweet in another. Or you want the next number in a sequence.

That's where mappings come in. They look like this.

MAPPINGS
========
first => second
rock paper scissors -> paper scissors rock 

animal => makescall
cat dog bird -> miaow woof tweet

Int => IntUp
I0 I1 I2 I3 I4 I5 I6 I7 I8 I9 -> I1 I2 I3 I4 I5 I6 I7 I8 I9 I0

Secondary => ColorComponent1
Purple Orange Green -> Blue Red Yellow

And they might be used in rules like this.

// get the play that wins for the second player
first [ getwin player:first ] -> [ getwin player:second ]

// get the next number in sequence
Int [ Counter:Int TempCountThis ] -> [ Counter:IntUp TempCountedThis ]

Which reads:

Specifically, the first rule will be expanded exactly as if it had been written like this.

[ getwin player:rock ] -> [ getwin player:paper ]
[ getwin player:paper ] -> [ getwin player:scissors ]
[ getwin player:scissors ] -> [ getwin player:rock ]  

The rule direction is just one expansion parameter like others, and the relative directions > < v ^ perpendicular parallel orthogonal are predefined mappings for directions. So you can write rules like this.

(the player faces the direction of the key pressed)
[ > Player:directions ] -> [ > Player:> ]

(players can push wheelchairs only when they face one, standing behind it)
[ > Player:> | WheelChair:> ] -> [ > Player:> | > WheelChair:> ]

Mappings are not things you're going to use all the time, but when you need them, they're there.