Functional Requirements

These are the functional requirements for the Traffic Jam Puzzle computer solitaire game.

1.0 Reset_Board

Board is reset to its starting configuration: Five left-most markers facing right, and five right-most markers facing left, with an empty stone in the middle.

2.0 Is_Valid_Move

Determine whether or not a move is valid. The rules for a valid move are:

2.1 The move must be within the range of valid stones.

2.2 The stone designated by move must be occupied.

2.3 If the marker at move is facing right THEN

The move is valid IF the stone to its right is empty OR
IF the stone to its right has a Left marker
AND the "leapfrog" stone is empty.

2.4 If the marker at move is facing left THEN

The move is valid IF the stone to its left is empty OR
IF the stone to its left has a Right marker
AND the "leapfrog" stone is empty.

(Note: Invalid moves are ignored by the program).

 

3.0 Update_Board

A move is made to the current Board, resulting in an updated Board. Specifically, the marker at move is moved to the empty stone, and the stone at move becomes empty.

4.0 Is_Win

If the Board is in a winning configuration, a win_message is displayed for the player. The winning configuration has the five left-most markers facing left, and five right-most markers facing right, with an empty stone in the middle.