A TicTacToe who can played in every terminal.
Very simple in functionality.
Programmed as a "TicTacToe-Class", so you can program your own gamemode.
- player1Name -> str = X
- player2Name -> str = O
When instantiating the class, the parameters player 1 and player 2 could be set for naming the output.
If you don´t to this, your terminal call the players X
and O.
Set the Dictionary gameboard to positions 1 - 9
- player -> int
Return the players dictionary with the elements "Name" and "Symbol".
Return the gameboard refurbished for terminal.
Empty positions are numerated by number 1 - 9.
Player 1 get color green
Player 2 get color yellow
- player -> int
- position -> int
Sets the players "Symbol" in transfered position. Return a feedback-string for terminal output.
If position is occupied the method raises an keyerror like an position out of range was transfered.
- symbol -> str
Return the transfered players symbol.
Check the gameboard-dic, horizontal, vertikal and diagonal whether there are three identical symbols in a row.
In case of an hit the metode return the name of the winner.
If no winner is found and all positions are occupied the function returns "nobody" otherwise the function return an empty string.
- You have to set two names for the two players.
- Random pick of the beginnig player.
- Write the number in terminal where you want to place your symobol.
- Play until one winns or all position are occupied.