Giter VIP home page Giter VIP logo

hluke93-ms3's Introduction

Tic Tac Toe -v- Computer (by Luke Hickson)

Tic-tac-toe (American English), noughts and crosses (Commonwealth English), or Xs and Os (Irish English) is a paper-and-pencil game for two players who take turns marking the spaces in a three-by-three grid with X or O. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row is the winner. It is a solved game, with a forced draw assuming best play from both players. Live Website Here.

Tic Tac Toe Board

Table of Contents

  1. Rules of the Game
  2. User Goals
  3. User Expectations
  4. Features
    1. Future Features
  5. Testing
    1. Manual Testing
  6. Deployment
  7. Credits
    1. Technologies Used
    2. Content

Rules of the Game (Historically)


Tic-tac-toe is played on a three-by-three grid by two players, who alternately place the marks X and O in one of the nine spaces in the grid. There is no universally-agreed rule as to who plays first. The Aim of the game is the get three of your marks in a horizontal, vertical, or diagonal row. Players soon discover that the best play from both parties leads to a draw. Hence, tic-tac-toe is often played by young children who may not have discovered the optimal strategy.

Tic Tac Toe Board


Go to the top


User Goals


Game Flow


Game Flow


I want to create a game that is easy to navigate for users.

  • Was this achieved?

Yes

  • How was this achieved?

This was achieved by taking a very simple apporach to the classic Tic Tac Toe.
The game will run in a smooth loop to allow the user to keep playing as many times as they want to or can end the game.

I want the user to play against a computer rather than a 2 player game.

  • Was this achieved?

Yes

  • How was this achieved?

This was achieved by creating a computer choice function which randomly generates a choice on the board for the computer.

I want to make it clear by using a color scheme (Win=Green , Lose=Red) the outcome of the game

  • Was this achieved?

Yes

  • How was this achieved?

This was achieved by adding color to the various outcomes of the game.

Game Colors

  • Winner Message, Green ("\033[1;34m").\

  • Lose Message, Red ("\033[1;31;31m").\

  • Draw Message, White ("\033[1;37;40m").\

  • Main Game Color,Pink ("\033[1;35;35m").\

  • Reference Board color, Blue ("\033[1;34;34m").


Go to the top


Features


Welcome page

  • This is the first page you see when the app loads. On this page there is a Tic Tac Toe image located at the top of the screen, a welcoem message and a question to the user. The question asks the user "Please Enter Your Name: ".

Welcome Page


Choose Marker

  • The player is welcomed by name and asked to choose a marker to play with. "X" or "O".

Choose Marker Page


Ready to Play?

  • After the user chooses a marker , either the user of computer will play first. The user is asked one more time if they are ready to play?

Ready to Play


Main Game Screen

  • The user is presented with the main game screen. A reference board in blue and a game board in pink.
  • The user is asked to pick a position to drop their marker.
  • If the computer was chose to go first , it's move will already be on the board.

Main Board


User Win Screen

  • In the event of the user winning, the user is presented with a winner message in green , and asked if they want to play again

User Win


Computer Win Screen

  • In the event of the computer winning, the user is presented with a loosing message in red , and asked if they want to play again

Computer Win


Draw Screen

  • In the event of a draw, the user is presented with a draw message in white , and asked if they want to play again

Draw Screen


Thanks for Playing Screen

  • The user has selectted that they do not want to play again and is displayed the message below.

Thanks for Playing


Go to the top


Future Features

Minimax Algorithim

  • In the future i woudl like to implennt the Minimax algorithm for the computer choice. This would add a much higher level of difficulty to the game. Currently it is only a randomly generated computer choice.

Testing


Python Testing

  • Python was tested using PEP8 validator

  • The Python results came back with the following:

PEP8

PEP8


E501(Line Too Long)


Resolved by reduceing line length

W503(Line Break Before Binary Operator)


Resolved by aligning code up correctly that goes across 2 lines

E303(Too Many Blank Lines)


Resolved by removing blank lines

W293(Blank Line Contains Whitespace)


Resolved by removing additional white space

W291(Trailing Whitespace)


Resolved by removing trailing whitespace

E128(Continuation Line Under-Indented For Visual Indent)


Resolved by indeningt lines to the opening parentheses

W391(Blank Line At End Of File)


Resolved me removing additonal line and the end of the file.

PEP8 All Correct

PEP8 Correct

Go to the top


Manual Testing

  • When the game is first run , the user can enter in any name , which may include letters , numbers and special characters. This was tested and works as expected. (The Letter F was tested as a name)

Welcome "F"


  • The user is then asked if you want to choose "X" or "O".
  • If neither "X" or "O" is entered , the program will keep asking the name quesitons until a valid input is recieved.

Choose 1 Choose R


  • A random decision is then made if the user or computer goes first.
  • This was tested by running the program multiple times to see both decisions.

User First Computer First


  • The user is then asked if they are ready to play (Yes or No).\

  • A bug was found here when the user enters no.\

  • This was resolved by amending the play_game variable code.

  • This is the error that was recieved

Ready to Play Error


Code Amendment

play_game = input('Are you ready to play? Enter Yes or No. ')

  if play_game.lower()[0] == 'y':
     game_on = True
  else:
    game_on = False

After this amendment , the code worked as expected.

  • Once the user selects "No" , They are then asked if they wish to "play again".\
  • If not , the user is displayed a thank you message , and instrucitons how to paly again.

Play Again No

Thanks For Playing


  • When the user selection "Yes" that they are ready to play the game, the reference board is displayed and the game board.

Main Board


  • A number from 1-9 must be entered in by the user.
  • Any other entry will result in the user being asked again for a selection.
  • Even a empty space will ask the user for antoher choice

Incorrect Entry


  • When the User Wins the game , a user win message is displayed

Winning screen


  • When the User loses the game , a computer win message is displayed

Loosing Screen


  • When the User Draws the game , a Draw message is displayed

Draw Screen


  • Do you want to play again screen
  • If "Yes", the game restarts to the welcome screen
  • If anyhing else other than "Y" or "Ye" or "Yes" is entered , the game ends with the ending message and intructions how to play again

Welcome Page Thanks For Playing


Deployment


  1. Went to Heroku dashboard and clicked on 'create a new app'.
  2. Selected a name for my app; every app must have a unique name so I couldn't call it TicTacToe as this was already taken so I went for tictactoe2022.
  3. Selected my region (Ireland) and clicked create app.
  4. I then went to the tab at the top of the page and clicked on settings.
  5. As Instruced on the Codeinstitute tutorial i added a Key: PORT and Value: 8000
  6. I added the buildpacks needed by clicking on the buildpack button.
  7. Here I selected python and pressed save changes.
  8. Then repeated the same process but selected nodejs this time, making sure it was done in that order with python at the top and nodejs under.
  9. I went back up to the tab at the top and clicked deploy.
  10. I selected github as the deployment method and clicked connect to github.
  11. I then searched for my github repository name, and connected to the correct repository.
  12. Then I scrolled down, here there were two options.
  13. The first option being to enable automatic deployment, which means that Heroku will rebuild the app every time I pushed a change to github. This is the on i selected.
  14. The other option being to manually deploy.
  15. When all the code is received from github there is a view button that it a link to the running app, I clicked this to make sure everything was running as expected.

Go to the top



Credits


Technologies Used


  • Luci Chart was used for the Flow Chart.
  • Am I Responsive was used to test the responsiveness of the site
  • Github was used as the repository hosting service
  • Gitpod was used as the Code Editor for the site
  • Heroku was used to deploy the site
  • PEP8 was used to test the python code.
  • Youtube was used to watch tutorials on how to make tic-tac-toe using python.

Content


The Code used in this website was written by the developer. The Code institute , YouTube and W3 Schools were used a guides.


hluke93-ms3's People

Contributors

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