Question
Suicide checkers, also known as Anti-Checkers, Giveaway Checkers and Losing draughts is a twoplayer variant of the board game checkers where the goal outcome has
Suicide checkers, also known as Anti-Checkers, Giveaway Checkers and Losing draughts is a twoplayer variant of the board game checkers where the goal outcome has been reversed - if you have no pieces left or if you cannot move anymore, you win. Players take alternating turns, moving their pieces according to the rules of checkers. The goal of the game is to have no pieces left. You are required to develop a computer program in C++ that allows two dierent algorithms to compete against each other in a game of suicide checkers. In the standard 88 version of the game, player 1 has 12 white pieces and player 2 has 12 black pieces. The starting conguration of the board has all pieces of each player lined up on the black spaces in the rst three rows on either side of the board. For checkers of varying even board size, we can have boards as shown in Figure 2 where we always have two blank rows in the center of the board. As can be seen the number of pieces changes for dierent board sizes. For a board size of 66, each player has 6 pieces. For a board size of 88, each player has 12 pieces. For a board size of 1010, each player has 20 pieces. For a board size of 1212, each player has 30 pieces.
A summary of the rules is provided below: Moves are only allowed on the black squares of the board, so pieces always move diagonally. Single pieces may only move forward toward the opponent. A piece making a non-capturing move (not involving a jump) may move only one square. A piece making a capturing move (a jump) jumps over one of the opponents pieces, landing in a straight diagonal line on the other side of the opponents piece. Only one piece may be captured in a single jump; however, multiple jumps are allowed during a single turn. After a piece is captured, it must be removed from the board. If a player is able to make a capture, this move is compulsory; the jump must be made. If more than one capture is available, the player is free to choose whichever he or she prefers. Kings : When a piece reaches the furthest row from the player who controls that piece, it is crowned and becomes a king. One of the pieces which had been captured is placed on top of the king so that it is twice as high as a single piece. Kings are limited to moving diagonally but may move both forward and backward. (Remember that single pieces, i.e. non-kings, are always limited to forward moves.) Kings may combine jumps in several directions, forward and backward, on the same turn. Single pieces may shift direction diagonally during a multiple capture turn, but must always jump forward (toward the opponent). The game ends when one player has lost all their pieces and is crowned the winner. The game may also end when there is a stalemate (a draw) and both players have pieces remaining on the board but are unable to make any additional moves. Implement checkers for a board size of n x n where 6 n 12 and n is always even. 2. Implement two dierent algorithms that will play suicide checkers against each other e.g. an algorithm that randomly chooses a valid move may be one of your algorithms. 3. Implementing the play of a king piece (see rules above) will be considered as a bonus and not a requirement. Pieces that reach the end of the board will therefore be unable to move as no forwards moves will be possible at this point
The input le named input.txt will contain a list of board sizes, separated by newline characters, that should be used to test the two algorithms against each other. The input le will have the following format 6
6
8
10
Your program must produce one output le. The le must be named results.txt. This le must contain the following: The rst line of the output should contain the size of the board for the current game, Each line after this should record a players turn - list p1 or p2 depending on whose turn it is. If a player makes a move without taking pieces list the block number the piece moved from, a dash and the block number the piece moved to, eg. p1 4-7. If a player makes a move that involves jumping the opponents piece you would have the following p2 12x5(8), where 12 is the block number player 2s piece moved from, block number 5 is where player 2s piece moved to and block number 8 is the location where player 1s piece was jumped. If a player makes a move that involves multiple jumps of the opponents piece you would have the following p2 17x12(14)12x5(8), where player 2s piece moves from block number 17 to 12 and then from 12 to 5 jumping over player 1s pieces located on blocks 14 and 8. Once the game is over the total number of pieces for player 1 and player 2 are listed on seperate lines as shown on lines 20 and 21 of Listing 1. The nal piece of information to include is who the winner is or if it is a draw. If there is a winner write either wp1 if player 1 wins or wp2 if player 2 wins. If there is a draw, write d. Any subsequent games listed in this le should be separated from previous games by an empty line as shown in line 23 of Listing 1. Only game board sizes listed in the current input le must be saved to the output le. The history for each board size listed in the input le must be appended to this le with one empty line inbetween dierent games.
Two dierent algorithms must be implemented. You are not required to use this specic algorithm but it is an option for one of the players. The rst step is to determine what legal moves are available. If we consider a 66 board in the staring conguration as shown in Figure 2a, we can create a list of possible moves our player is allowed to make.
please include a vector table or make use of struct and also use .txt files in the code instead of cin and cout. Please also ensure that the results.txt is of the same format and also include a random algorithm. Ensure that the code implemented works for more than one boardsize.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started