JirR02 d1c3fcd614 Bonus Task I
Added Bonus Task I to repository
2025-03-20 11:01:37 +01:00

2.0 KiB

Project overview

The goal of this project is to implement a game called Dots And Boxes: two players, A and B, take turns to draw lines connecting dots on a m \times n (here 2 \times 2) board.

If a player manages to close a box (a 1 \times 1 square surrounded by lines), the player claims the box by placing its token (A/B) in the box, and the player gets another turn. The game is finished when all boxes have been claimed, and the player with the most claimed boxes wins. Note that, even if a player claims multiple boxes in a single move, they would only get one extra move.

For example, in the following game player A won:

Your task

The file game.cpp contains a partial implementation of the game. The main game loop is implemented in the function play_game(grid). This function is called from main.cpp and gets the game grid as an argument. The game grid is already fully implemented. We describe the functionality it provides in a following section below.

Your task is extending the game implementation in file game.cpp such that it works the way described above. We provide some functions in this file and thus suggest a certain structure -- but you are completely free to do it your way. Add, remove or change anything you want. The only constraint is that you must implement the function play_game which takes the game grid as argument. You are of course free to change the body of this function in whatever way you like.

If you do decide to change the body of the play_game function be careful to not accidentally change the format of the outputs it generates. For example: If you change the output std::cout << "Game finished" << std::endl; to std::cout << "Game Finished" << std::endl; you will not pass some test cases. The autograder is very picky when checking whether or not your outputs are correct. You can get all the points in this exercise without changing any of the output lines in the template.

Note: More Information on the the concept of the game on Code Expert.