Giter Club home page Giter Club logo

tic-tac-toe-'s Introduction

TicTacToe

logo

tester.mov

Live Site

TicTacToe

Repository

Author

Ocimar Felipe Costa

How To Play/Use

  • 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

Features

Use this section to itemize the features of your project.

videotester.mov

Implemented Features

1 - Logo of the game.

Logo Tic Tac Toe

2 - Put the name of the player.

Player Name

3 - Machine asks if you want to play?

    1 - Yes / 2 - No

Do you want to play a game?

4 - Player selects houses using the numerical keyboard from 1 to 9.

Tictactoe

5 - End the game notifies who was the winner, and it shows that the result is being sent to google cloud spreadsheet.

winner

6 - Ask if you want to play one more time.

    1 - Yes / 2 - No

one more time

Future Features

  • Use more colorama features.
  • Vary tic tac toe layout.
  • To give the user the option to choose which tag to start with.

Flow Chart

  • Flow Code chart.

Chart code

  • Flow Game Chart.

Game flow chart

Data Model/ Classes

Board

  • get_board Metod get board the game

BasePlayer

  • Base player is a generic representation of a player.

Properties

  • Marks the symbol to be used to represent player X or 0.

Methods

  • available_moves_display Method to choose a move based on a game board.

ComputerPlayer

  • Computer player is the computer in the games.

Player

  • The human player determines his movements using the base player.

TicTacToe

  • Basically the game TicTacToe

Properties

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

Methods

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

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

Testing

Validation Testing

Code TicTacToe Game

Code TicTacToe

Code run

Manual Testing

  • You will find my manual testing sheet here

Defect Tracking

Defects

Outstanding Defects

Nothing to change.

Commenting Code

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()


Gitpod

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+nRj7ynW44XSK7H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0dJQe6\nDLJ6Za26GTE9yXmEehTv5B8uQ82HubUYyJbbMm3ZleNHZ/4jfeRmIHKwBDCn8B3c\nWYiByCZ5V/Yc9ZyloGgJUXAufz8DrXWLHQC8tCxvQQKBgQDA+5fXk4DHWNl5b1DI\nApTGN1+JBbf3q/UtYn9pyJvSbSYbChIvSToAIz/2rJ8L27A1TPhVCY2Mrwjdlwzu\n8ia1pN4Sq1oCPxVBcwl//s5YyHzZtZbAIoQwZBff1SAZmqw9bitncJ9maazw3PoZ\nswguIH/g+OpM3DDUz+MVQbFPxA==\n-----END PRIVATE KEY-----\n",
  "client_email": "[email protected]",
  "client_id": "109103238029005579935",
  "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

Heroku

  • Head to Heroku and create an account.
  • Click on "Create New App".
  • Name your app, select your region and click on "Create app".

App Information

ocimar84:Tic-Tac-Toe-

Config Vars

B  Build Packs

Deploy A

B  Build Packs

Deploy either manual or automatic

Credits

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

Tutorials

https://www.youtube.com/watch?v=dK6gJw4-NCo

https://www.youtube.com/watch?v=M3G1ZgOMFxo

https://www.youtube.com/watch?v=E8fmDDtaHLU

Content

(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/

Acknowledgments

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.

tic-tac-toe-'s People

Contributors

ocimar84 avatar andremaurilio avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.