## Software Construction: Parcheesi Rules

Parcheesi is a race between four players. Each player moves four pawns from their starting point, around the board and then into the center. The first player to get all four pawns into the center wins.

Initially, the board looks like this, with each player's pawns in their home circle. (Click on any board to see a larger version of it.)

On each turn, a player rolls two dice and moves their pawns according to these rules:

• Entering
If one of the dice has a five, or both dice together sum to five, one of the pieces may be moved out of the start area into the main board (moving out consumes the five). The entering positions are the positions on the board that are half purple and half the color of the player. For example, if green rolls 1 and a 4 on the first turn, the board looks like this:
• Normal Move
With the exception of doubles, when a player rolls the dice, the player moves their pieces by the numbers indicated by the pips. Pieces move in the counter-clockwise direction around the board, on the purple and light blue squares. If, for example, green rolls a 5 and a 3 on the first turn, the board looks like this:
then, if green rolls a 4 and a 6 on their next turn (and the other players don't enter) green might first move the 4, resulting in the board on the left and then move the 6, resulting in the board on the right.
• Double Bonus
When a player rolls doubles and all of their pieces are out of the starting area, the player moves by the tops and bottoms of the dice. That is, if the player rolls double 1s, the player moves two pieces 1 square and two pieces 6 squares (of course, this can be all the same piece). The opposite sides of the die always sum to seven, so the total number of spaces moved is always 14.
Two pawns of the same color on a space form a blockade. A blockade cannot be passed by any other pawn (even one of the same color). A blockade cannot be moved together (this rule affects only doubles). As a simple example, if red were to roll a 2 and a 1 in the following board, only the freshly entered pawn could advance.
• Individual Die Rolls
Each die roll should be thought of as an individual "mini-move". That is, when a player rolls a 3 and a 4, for example, the player may move one pawn 3 squares and another pawn 4 squares. This may be the same pawn, but this is not the same as moving that pawn 7 squares directly. For example, in the following board, if red has a 3 and a 4, red cannot move, even though the spot seven spaces away is safe to land on.
• Bop
If a pawn is by itself on a light blue square and a pawn of a different color lands on the square it occupies (by an exact count of the dice) the original pawn is bopped, which means it is sent back to the starting square. The player that bopped now may move any one of its pawns by 20. This bonus acts just like an extra "mini-move" as described above. For example, if red rolls a 1 and a 2 in the board on the left, after moving the board looks like on the right.
• Safety
Purple squares are safety squares. The only way a pawn can be bopped on a purple square is if the bopping pawn is entering from the start and lands on the pawn on the entering square. A blockade on an entering square behaves like a blockade otherwise does, however, meaning that a blockade on an entering square prevents bopping. A safety square cannot be occupied by two different colored pawns. One pawn on a safety does not constitute a blockade, however, so other colors can pass by. For example, if red rolls a 2 and a 3 in the situation below, it can take the 2 and then the 3, but not the 3 and then the 2.
If, however, red rolls a 1 and a 4, in the picture on the left, red bops green and we get the picture on the right.
• Home Row
When a pawn makes a nearly complete circuit, it turns off into its correspondingly colored home row. For example, if green, after travelling all the way around the board to the bottom left, rolls a 4 and a 3, it moves into the green section of the board:
• Home
Pawns must enter home by an exact count. For example, in the board below, green must roll a 1 in order to move the piece home.
• Home Bonus
When a piece moves home, the player whose piece moved home gets a bonus of 10. This bonus acts just like an extra "mini-move" as described above. For example, if green rolls a 1 and a 2 in the board on the left the move results in the board on the right.
• Cell Occupancy
Each square in the main ring and in the home rows can have only zero, one or two pawns on it. If it contains two pawns, those pawns must be the same color (and would form a blockade, as above).
• Use all Dice
A player must use all of their dice. There is some subtlety to this rule. Consider this board, where green rolls a 1 and a 3.
If green moves the piece from red's entry to form a blockade, then they cannot take the 3. If, on the other hand, they first take the 3 with the piece further back and then take the 1 they can use both dice. You do not need to check for this situation. Simply checking that there are no possible legal moves with any leftover die rolls (and bonuses) is sufficient. In other words, either of the turns described above are legal. More precisely, the rule we are using is: if a player returns a move array, which then finishes their turn (without using all of the dice and bonuses), there must not be any further moves possible in the final board that use the remaining die rolls.
• Mandatory Entering
Parcheesi typically requires a player to enter the board, if possible. That is not required here however.
• Doubles Bonus
When a player rolls doubles (no matter if all of the pieces are out or not) play does not pass to the next player at the end of the turn. Instead, the player that rolled doubles takes another turn. If they roll doubles a second time, they take a third turn. On the third turn, if they roll doubles, their turn is forfeit and the pawn that is the furthest along (on either the home row or the main part of the board) is moved back to the starting circle (the die roll is otherwise ignored). If they do not roll doubles on the third turn, they take the third turn as normal.
• Try it yourself
Download either parcheesi.zip or parcheesi.tar.gz to get some code that will let you check interesting (or not so interesting) cases in the rules yourself. Post on piazza if you find a bug or aren't sure if it is right.

Robby Findler