Giter Site home page Giter Site logo

day83-ticktacktoe's Introduction

DAY83-TICKTACKTOE

MY TIC-TAC-TOE PROJRCT - DAY 83

Starting this projet, My Biggest Challenge was finding a way to represent the grid for the

game and after a couple of attempts, I finally came up with a way to represent the grid in the command line and collect inputs to match each portion of the grid.

My Approach

I Created a Class called Tic-Tac-Toe which has attributes and methods.

Attributes included:

  A list which contained the players inputs in terms of numbers ranging from 1 - 9 where each number represents a position on the game grid

  A dictionary called 'markers' which takes each number in each players list and uses it to create the game grid.

  Flags like "game_over" to check if any player has won, "current_player" to check whose turn it is.

Methods included:

  "start game" which is called at the beginning of the game ensures the player inputs are empty and the current player is assigned as 'x'

  "Print_guide" prints a guided grid which shows the Player which numbers corresponds to which position on the grid.

  "Collect_input" Collects the user Input and ensures the Input is a valid input before Proceeding.

  "Update_markers" This method takes all the items in the each of the Players Input arrays and appends each entry into the position in the grid. for example, if player_1's array is = [1, 5, 9], each item in the list represents a position for player 1 on the grid. Therefore the method writes "x"  into the game grid at position 1, 5, 9. and does the same for player 2 but with "o"

  "update_p1" and "update_p2" are used to add the processed user input into theie individual arrays

  "print_grid" prints all game grid alongside every user's input.

  "check_for-winner" Checks to se if there's a winner.

day83-ticktacktoe's People

Contributors

rhythmbear avatar

Watchers

 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.