Coder Social home page Coder Social logo

tic-tac-toe-game's Introduction

Tic-Tac-Toe-Game using javascript

A TicTacToe game with minimax algorithm

Use

Start the game with "game.html"

Minimax algorithm

A description for the algorithm, assuming X is the "turn taking player," would look something like:

  • If the game is over, return the score from X's perspective.
  • Otherwise get a list of new game states for every possible move
  • Create a scores list
  • For each of these states add the minimax result of that state to the scores list
  • If it's X's turn, return the maximum score from the scores list
  • If it's O's turn, return the minimum score from the scores list

You'll notice that this algorithm is recursive, it flips back and forth between the players until a final score is found.

Illustration

Image of the first tree

tic-tac-toe-game's People

Contributors

anouard24 avatar samery00 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

tic-tac-toe-game's Issues

Bug in script.js' turnClick function

Hi Abdelouadoud,

I found that if the human player win first and the computer win immediately after that, the program show that the computer win.
This issue doesn't exist in scriptai.js file, and the code is duplicated.
So, I will send you a pull request to solve this for future students.

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.