Part 2 of SOK 2025
Work done so far
Move tracker for PvC game
Implemented the code for tracking the move played by player and computer in bohnenspiel TUI game.
It is achieved using getLastMove
method initialized and defined in mankalaengine.h
and mankalaengine.cpp
. This method returns a pair
containing the last moved as int played and the player as Player who made it.
During each iteration of the game loop, the above method is called for both player and computer to retrieve their respective last moves.
The above code in TUI file of bohnenspiel game variant is used to display the move played in the terminal.
The player move is tracked using user.getLastMove() and the computer move is tracked using opponent.getLastMove(). The game loop alternates between the player and the computer, updating the board and tracking moves after each turn. The last moves are printed after each turn. The computer’s move are adjusted by adding 6 to align it’s side of board(move 6-11).
How it works?
- Player’s Turn:
- The player select the hole to play.
- The move is played, and the board is updated.
- The move is tracked using
user.getLastMove()
.
- Computer’s Turn:
- The computer select the hole to play.
- The move is played, and the board is updated.
- The move is tracked using
opponent.getLastMove()
.
After each turn the last moves played are displayed.
What’s next
The next goal moving forward is to create a PvP game mode for two different users.