Skip to content

Crankdad/TicTacToe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

TIC TAC TOE

A TicTacToe who can played in every terminal.
Very simple in functionality.

Programmed as a "TicTacToe-Class", so you can program your own gamemode.

Methods:

__init__

  • 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


getPlayer

  • player -> int

Return the players dictionary with the elements "Name" and "Symbol".


showGameboard

Return the gameboard refurbished for terminal.
Empty positions are numerated by number 1 - 9.

Player 1 get color green
Player 2 get color yellow


setPosition

  • 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.


getNamebySymbol

  • symbol -> str

Return the transfered players symbol.


checkForVictory

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.

Run the script

Standard-Gamemode

  1. You have to set two names for the two players.
  2. Random pick of the beginnig player.
  3. Write the number in terminal where you want to place your symobol.
  4. Play until one winns or all position are occupied.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages