Python Tic-Tac-Toe program
$10-30 USD
Pagado a la entrega
Tic-tac-toe is a two players' game: player X and player O. Both players take turns placing their mark (X or O) on the spaces in a 3×3 grid. The first player to place three of their marks in a horizontal, vertical, or diagonal row wins the game.
For this assignment you need to implement the Tic-tac-toe game in Python as console application under the following guidelines:
Create three classes Player, Deck, and TicTacToe.
For the class Player, it must have the following attributes:
Name (e.g. Alice)
PlayingMark (X or O),
Statistics (won, draw, lost).
It should implement the methods:
__init__: the class constructor
get_score() which should return ((won * 2) + draw - lost).
__str__ method that would print the player name, mark, and score.
And for comparison, it should implement the __cmp__ operator to compare players score.
For the class Deck, it must have the following data attributes:
Board: a 3×3 board implemented as a list or any other data structure.
Player1Choices: a list or any other data structure that contains the indexes of cells that player 1 choose.
Player2Choices: a list or any other data structure that contains the indexes of cells that player 2 choose.
It should also implement the following methods:
__init__: the class constructor
__str__: To print the current board status as " | | \n {0} | {1} | {2}\n _____|_____|_____\n | | \n {3} | {4} | {5}\n _____|_____|_____\n | | \n {6} | {7} | {8}\n | | \n" .
The class TicTacToe must have the following attributes:
DeckList: a list of objects of the Deck class, where the current Deck is the last item.
Player1: an instance of the class Player representing player 1.
Player2: an instance of the class Player representing player 2.
Additionally it should implement the following methods:
__init__: the class constructor
validate_user_input(): validate if the user input is an int between 0 - 8 and it was not played previously.
is_game_over(): check if the game is over by finding if a user won or if the board is full, if true then append the Deck lists to a file with the name "[url removed, login to view]" and return true, else return false.
get_user_input(): a method to get user input, it should display a message like "enter player {name} choice:". and then it should call the validate_user_input() to validate the user input, if user's input is valid, then store the value in the Board and the check if the game is over by calling is_game_over()
start_game(): the main game logic should go here in this class, it should add a list item to DeckList, and while the game is not over, keep calling get_user_input() for each user. Once a game is over, ask if the user wants to play again and then start a new game.
Make sure that your code is well documented by using line comments and docStrings.
Nº del proyecto: #8617101
Sobre el proyecto
Adjudicado a:
I HAVE A SIMILAR SOURCE CODE.I believe that I can do the job for you perfectly with 100% completion rate and accuracy. The price I bid is affordable but I deliver excellent job before deadline for proper review of the Más