Git Product home page Git Product logo

tictactoe-textbased's Introduction

tictactoe-textbased

Build a game of tic tac toe that is text based.

Setup

  • create an index.html file in this repo.
  • include the starter code script.js file.

Taking user input

At any point in our JS code, if we write prompt(), a pop up box will open in our browser for a user to enter in text.

// prompts user and stores value in the variable
var valueOfPrompt = prompt()
// logs value stored
console.log(valueOfPrompt)

You can also pass in a string as an argument to have the pop up box contain that string as a ... prompt.

var age = prompt("How old are you?")
alert("You are " + age + " years old.")

Whatever we type into the textbox in the window that prompt() brings up, is returned by prompt to the variable age.

1. Create a working game

  • create a game that users can play and that fills each square as they select it

2. Detecting a win state

  • modify your game so that the game knows when one player has won or lost

3. Further

  • when the game ends, or when the page is reloaded / loads for the very first time, prompt your users to ask if they want to play
  • ask the names of players 1 and 2 and display that back to them as they play and win

4. Even Further - Dynamic Board

  • Ask the user in the beggining on the game how large of a board they want.
  • Ask them how many in a row they want to qualify as a win
  • Detect the win state

4. Even Further!!!11!! - Computer Player

  • ask the player if they want to play against the computer
  • make the computer play by randomly picking a spot on the board
  • modify the computer player to be defensive and block the human player from winning
  • modify the computer player to be offensive and try to win the game

tictactoe-textbased's People

Contributors

awongh avatar nickangtc avatar

Watchers

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