Checkers is a strategy board game for two players which involve diagonal moves of uniform game pieces and mandatory captures by jumping over opponent pieces. It is played by two opponents, on opposite sides of the 8x8 checkered gameboard. One player has the dark pieces (or 'x' tokens); the other has the light pieces (or o tokens). Each player has 12 pieces. Players alternate turns. A player may not move an opponent's piece. A move consists of moving a piece diagonally to an adjacent unoccupied square. If the adjacent square contains an opponent's piece, and the square immediately beyond it is vacant, the piece may be captured (and removed from the game) by jumping over it.
Figure: see image.
Only the dark squares of the checkered board are used. A piece may move only diagonally into an unoccupied square. The player without pieces remaining, or who cannot move due to being blocked, loses the game. Pieces move one step diagonally forwards, and capture an opponent's piece by moving two consecutive steps in the same line, jumping over the piece on the first step. Multiple enemy pieces can be captured in a single turn provided this is done by successive jumps made by a single piece; the jumps do not need to be in the same line and may "zigzag" (change diagonal direction). Pieces can move/jump only in forward direction.
Aim of the game: is to capture all the opponent's pieces or render them unable to move.
How the game ends:
Reference: https://simple.wikipedia.org/wiki/Checkers
To the previously developed Java-based game, add a module to "play against the computer". Create a separate class called CheckersComputerPlayer.java in the core package that generates the moves for the computer player. The logic to automatically generate computer moves does NOT have to be a sophisticated AI algorithm. A nave algorithm to generate the moves is sufficient for this assignment.
Create a simple console-based UI as shown in the figures below.
8 | _ | o | _ | o | _ | o | _ | o |
7 | o | _ | o | _ | o | _ | o | _ |
6 | _ | o | _ | o | _ | o | _ | o |
5 | _ | _ | _ | _ | _ | _ | _ | _ |
4 | _ | _ | _ | _ | _ | _ | _ | _ |
3 | x | _ | x | _ | x | _ | x | _ |
2 | _ | x | _ | x | _ | x | _ | x |
1 | x | _ | x | _ | x | _ | x | _ |
a b c d e f g h
Begin Game. Enter āPā if you want to play against another player; enter āCā to
play against computer.
C8 | _ | o | _ | o | _ | o | _ | o |
7 | o | _ | o | _ | o | _ | o | _ |
6 | _ | o | _ | o | _ | o | _ | o |
5 | _ | _ | _ | _ | _ | _ | _ | _ |
4 | _ | _ | _ | _ | _ | _ | _ | _ |
3 | x | _ | x | _ | x | _ | x | _ |
2 | _ | x | _ | x | _ | x | _ | x |
1 | x | _ | x | _ | x | _ | x | _ |
a b c d e f g h
Start game against computer.
You are Player X. It is your turn.
Choose a cell position of piece to be moved and the new position. e.g., 3a-4b
3g-4h
and so on...