Description
Purpose In this project, you will implement the 2-player game of a Line ’em Up.
1 Game of Line ’em Up
The game of Line ’em Up is a generic version of tic-tac-toe: it is an adversarial 2 player game played on a n×n
board where each position has one of 4 values:
• a white piece (◦) – for the player who plays the white pieces
• a black piece (•) – for the player who plays the black pieces
• a bloc () – where no player can place their pieces (in tic-tac-toe, there are no blocs)
• an empty position () – where players can place their pieces
Game set up: Initially, b blocs () are placed at specific positions, and the rest of the positions are left empty.
Each player chooses the color they will play (◦ or •). The player who plays ◦ always plays first. Figure 1 shows an
initial game board with n=5 and b=6 blocs are positioned at [(0,D), (1,B), (2,A), (2,D), (3,B), (4,C)].
A B C D E
0
1
2
3
4
Figure 1: Example of an initial board with n=5 and b=6 blocs at positions [(0,D), (1,B), (2,A), (2,D), (3,B), (4,C)].
Moves: Players play in alternating turns. At each turn, the active player chooses one empty position where
they place their own color (◦ or •). Then the next player makes their move.
End game: The game ends as soon as one player has lined up s consecutive pieces of their own color in a row,
in a column or diagonally; in that case, that player wins the game. If there are no more empty positions on the
board, then the game ends in a draw. For example, with the game board of Figure 1, possible wins are shown in
Figures 2 and 3 if s=4, and a possible draw is shown in Figure 4.
A B C D E
0 ◦ ◦
1 •
2 •
3 ◦ •
4 ◦ •
Figure 2: Example of a win for • with n=5,
b=6 and s=4.
A B C D E
0 ◦ ◦ • •
1 • • • ◦
2 • ◦
3 ◦ • • ◦
4 • ◦ ◦ ◦
Figure 3: Example of a win for ◦ with n=5,
b=6 and s=4.
A B C D E
0 ◦ ◦ ◦ •
1 • • • •
2 ◦ ◦ ◦
3 ◦ ◦ ◦ •
4 • ◦ • •
Figure 4: Example of a draw with
n=5, b=6 and s=4.
1