You are implementing a strategy board game played by two players, Black and White. It is played on an N by N board. The winner is the player who has more discs of his color than his opponent at the end of the game. This will happen when neither of the two players has a legal move or there are no spaces left on the board

Starting Position

At the beginning of the game, two black discs and two white discs are placed in the middle of the board. Black always begins, and the two players subsequently take turns moving.

Making a Move

At his turn, a player must place a disc of his color on one of the empty squares of the board, adjacent to an opponent's disc. No two matching colors are connected vertically or horizontally so a miniature-chequered pattern is made

The Game

Both players take it in turns to make their move which consists of placing one piece down in a legally acceptable position and then turning any of the opposing player's pieces where applicable. A legal move is one that consists of, for example, a black piece being placed on the board that creates a straight line (vertical, horizontal or diagonal which diagonal is optional for this project) made up of a black piece at either end and only white pieces in between. When a player achieves this, they must complete the move by turning any white pieces in between the two black so that they line becomes entirely black. This turning action must be completed for every legal turning line that is created with the placing of the new piece. Players will then continue to move alternately until they get to the end of the game and a winner is decided. This decision is reached by identifying which of the two opponents has the most pieces on the board.

Sample Run for computer versus computer version

Initial game with 4 by 4 board and two white "W" discs and two black "B" discs in the middle of the board:

____
_WB_
_BW_
____

Success: Black move at (1, 0)

____
BBB_
_BW_
____

Score: Black: 4, White: 1
Success: White move at (2, 0)

____
BBB_
WWW_
____

Score: Black 3, White: 3
Success: Black move at (3, 1)

____
BBB_
WBW_
_B__

Score: Black: 5, White: 2
Success: White move at (0, 0)

W___
WBB_
WBW_
_B__

Score Black: 4, White: 4

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.