Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Simplified Checkers Game

A simple variant of the traditional checkers game, where the program will generate a move after every user move.

Setup

An 8x8 chessboard with 12 black and 12 white pieces initially positioned as shown.

Screen Shot 2022-06-21 at 4 53 18 pm

The user is side black and the program (computer) generate moves for side white. Black makes a move first.

Gameplay

In a single turn, the player either makes a move or a capture

Move (only diagonally forward for one step towards the opponent):

Screen Shot 2022-06-21 at 4 55 55 pm

Capture (jumps forward to an open cell diagonally as shown, landing cell must be empty):

Screen Shot 2022-06-21 at 4 57 05 pm

Towers: whenever a normal piece reach the furthest row, it becomes a tower and is able to make a move or capture both forward or backward (at maximum 4 possible moves). Note the cell B1:

Screen Shot 2022-06-21 at 5 03 48 pm

A player wins the game if it is the opponent's turn and they cannot take action, move or capture, either because no pieces / towers are left or no legal moves or capture are possible.

Screen Shot 2022-06-21 at 5 06 22 pm

Implementation

This program implements the minimax algorithm to make decision on which move to take. If white is making a move, it constructs a tree of all reacheable board configurations, with a depth of 5. So the root node will be the current board configuration\n and the children nodes will be the boards of all possible moves made by white. Children nodes of these nodes will be all possible moves made by black, we keep doing\n this until reach a tree height of 5.

We calculate the 'board cost' at the leaf nodes, which is: Board Cost = b + 3B - w - 3W

Where b and w are the number of black and white pieces; B and W are the number of black and white towers. Therefore black moves would want to maximise cost while white moves would want to minimise cost. Board costs of other nodes are imputed by looking at the children nodes with max / min costs if black / white is making a move. This bottom-up imputation will eventually lead to the cost at the root node, where a decision is made (choose the board configuration that has this optimal cost).

Screen Shot 2022-06-21 at 5 46 11 pm

Screen Shot 2022-06-21 at 5 47 14 pm

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages