Inside of the int main() method is only an instance of the Gamesetup_Handler, which has the menu lead implemented and sets up the whole game. Playerinitialization and the playermanagement is taken by the Game_Handler. The Playfield_Handler takes care of printing the playfield and checks if a player has won.
Tip: If you want to play with a bigger field against some bots, then make the console a bit bigger
- Open Visual Studio Code
- Open the repo in Visual Studio Code
- Open and compile
main.cpp
It's possible to run the code on other compilers than gnu, but some lines have to be changed and the overall structure has to be implemented a bit different depending on what IDE you want to run the code
- Choose Kit of MinGW
- Let it build
- On the bottom of Visual Studio Code should now be a run button, click this one
Based on simple abstraction: a method
player_move(...)that has to be derived in every derived class of player
The structure of the players is quiet simple to understand, all I have done is to create a base class Player that needs to be derived and through pointers I can call the true virtual method player_move(...) in every derived class without to know what class was instanciated.
In the Game_Handler you set up a new if statement in the initialize_players() method.You also have to add the playertype in the menu so that the user can choose it.
The function to include that is in the Gamesetup_Handler: set_player_type()
For refreshing what inheritance is in object-oriented programming: Inheritance
- I implemented a complete menu lead, instead of opening and compiling it once you can play more games before you close it
- Outsourced code snippets in an only functional header, wanted to use modules but the gnu compiler isn't capable in using them
- For the playfield I went through this tutorial: GeeksForGeeks
- Random number generator: Stackoverflow
- Console clearing: DelftStack
- Intended output delay on console: Stackoverflow