tester.mov
Ocimar Felipe Costa
-
This app was developed as part of my third Portfolio project with the Code Institute. It is a Tic Tac Toe game developed with Python as its only language and is a Player vs Computer style game that are chosen by the user. The user can then play against a computer that chooses its moves at random, or a computer that maximizes its wins while minimizing its losses. In the end I incorporated the google cloud spreadsheet to show the result of all matches.
-
The explanatory video of how the system works:
exemplo.mov
Use this section to itemize the features of your project.
videotester.mov
1 - Logo of the game.
2 - Put the name of the player.
3 - Machine asks if you want to play?
1 - Yes / 2 - No
4 - Player selects houses using the numerical keyboard from 1 to 9.
5 - End the game notifies who was the winner, and it shows that the result is being sent to google cloud spreadsheet.
6 - Ask if you want to play one more time.
1 - Yes / 2 - No
- Use more colorama features.
- Vary tic tac toe layout.
- To give the user the option to choose which tag to start with.
- Flow Code chart.
- Flow Game Chart.
- get_board Metod get board the game
- Base player is a generic representation of a player.
- Marks the symbol to be used to represent player X or 0.
- available_moves_display Method to choose a move based on a game board.
- Computer player is the computer in the games.
- The human player determines his movements using the base player.
- Basically the game TicTacToe
- board an array of 9 entries representing positions.
- current_winner tracks whether a player has won the game or not.
- computer player representing the computer.
- player player that represents the human user.
- game.printboard() Prints out the game board to the terminal.
- game.playerinput() Enter the player's name and ask if he wants to play. (1 - yes / 2 - No).
- game.checkifwin() Places the player tags according to the index provided. If the index is an empty square, return True and make the move. If the index is occupied, return False and invalidate the move.
- game.switchplayer() Change who is playing by switching between the player and the computer.
- game.computer() Computer randomly selects your position on the board.
- game.checkifwin() Places the computer's tags according to the index provided. If the index is an empty square, return True and make the move. If the index is occupied, return False and invalidate the move.
- class TicTacToeGame() Used to determine the python class.
Python Libraries
- Random: used to randomize the computer's moves.
- Colorama: used to color the game throughout.
- You will find my manual testing sheet here
Nothing to change.
Documentation worthy example:
def printboard(self):
"""
Prints the game board
"""
prYellow(self.board[0] + " | " + self.board[1] + " | " + self.board[2])
prYellow("----------")
prYellow(self.board[3] + " | " + self.board[4] + " | " + self.board[5])
prYellow("----------")
prYellow(self.board[6] + " | " + self.board[7] + " | " + self.board[8])
def getboard(self):
"""
Get value of board
"""
lista = "[ \n" + self.board[0] + "," + self.board[1] \
+ "," + self.board[2] + "," + "\n" + self.board[3] \
+ "," + self.board[4] + "," + self.board[5] \
+ "," + "\n" + self.board[6] + "," + self.board[7] \
+ "," + self.board[8] + "," + "\n ]"
value = [self.username, self.currentPlayer, lista, self.winner]
return value
def playerinput(self):
""""
Gathers user input
Checks if input is valid to open spot or not
"""""
inp = int(input("Select a spot 1-9: "))
if self.board[inp - 1] == "-":
self.board[inp-1] = self.currentPlayer
else:
prRed("Oops player is already at that spot.")
self.playerinput()
creds.json file
{
"type": "service_account",
"project_id": "ocimartictactoe",
"private_key_id": "b6869f37eb1a62a2896caee1903d1c4286b84dea",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC1OJYZeSXJ8Pdk\nfnYW5W+1+uBurbXQMf6Rw8zJ8y7W86MKBAO4BmChCX1xOi9ZbyQO4zGu1LjkRfDj\n3ggxuoknyEPU5vutgaUiK3Yi2NJSLEc/q2nRsvaDyOLxkrmOV802XUGfZpx03JpD\n9Hqu3z0IZggEi+ujv97ncTa5/Ik30+TZL288tlwuzWuf4n2HhZtNCNGLaa2hTJL0\ndoyidKqyAV/YiyxaW+nRj7ynW44XSK7H1QncnpegL4stWlTVUkLhZLSsnS38jBFN\n14J5+4P/WZVEAG06KT3bS1cFs/QFeXe/7bCS28t+/musrrMnmOiLyPnBVV//yQqd\nW0+3qScZAgMBAAECggEAEYbN1YbcUGySsKXJFqvNTboGwg2LhlLffl+DyzWkHmaP\n1SR665hfo2jUjgKE7nm2Rg5TvByXXn8j2MCc5ZpXMNbIi1W6ROyYo6EKcD0CElp1\nRZjMHNuEcKMZd9MAnoiqsIr9EW/jdStEwYpqjHEgvlLdNvtaqIqiV0X2zK66OADc\nxMsLOufvPAR5HUt/Jrc+GqDahBQ7x6ycbfivU8bVcS0CjjMry5YY2e0UU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238029005579935",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/ocimartictactoe%40ocimartictactoe.iam.gserviceaccount.com"
}
If you have any dependencies, you should instruct users to install them
pip3 install -r requirements.txt
- Head to Heroku and create an account.
- Click on "Create New App".
- Name your app, select your region and click on "Create app".
-Code Institute Template - The Template for the GUI for this project was provided by Code Institute. This allows for the Command line to be shown and used within the browser.
https://www.youtube.com/watch?v=dK6gJw4-NCo
https://www.youtube.com/watch?v=M3G1ZgOMFxo
https://www.youtube.com/watch?v=E8fmDDtaHLU
(https://www.geeksforgeeks.org/print-colors-python-terminal/)
(https://realpython.com/documenting-python-code/)
https://www.geeksforgeeks.org/python-ascii-art-using-pyfiglet-module/
https://www.scraggo.com/python-classes-guess-the-number/
https://www.geeksforgeeks.org/print-colors-python-terminal/
I would like to thank all the knowledge that was acquired and make a comment, I had a lot of difficulty in finishing this project, I found the classes confusing, I had to look for another type of help to understand. I had a serious problem on my machine where once again github was not pushing.
I would like to thank my mentor Malia who was very patient in explaining things to me more clearly.
Andre Maurilho helped me configure my computer so that github would work, and even uploaded a file that was stuck in my repository.