thePeras / Tic-Tac-Toe_Algoritm

Tic-Tac-Toe that never loses

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TIC-TAC-TOE THAT NEVER LOSES

The following project is an implement of a tic-tac-toe algoritm that never takes a lose.

If you think you can beat it, try it out:

play here

Algoritm

The algoritm was taken in the book of Pedro Domingos, "The Master Algorithm" and it's the following on

  1. If you or your opponent has two in a row, play on the remaining square.
  2. Otherwise, if there’s a move that creates two lines of two in a row, play that.
  3. Otherwise, if the center square is free, play there.
  4. Otherwise, if your opponent has played in a corner, play in the opposite corner.
  5. Otherwise, if there’s an empty corner, play there.
  6. Otherwise, play on any empty square.

If you don't know anything about artificial intelligence and want to know a litle beat I really recommend you the book.

Game

This implement is build on top of a tic-tac-toe project made by Borna Šepić. That means the mecanism of the game is built by him, and was forked by his Tic-Tac-Toe repo

My role

I have costumized the Borna aproach and gave it a little of my taste. So the user can choose being the first or second to play.

About

Tic-Tac-Toe that never loses


Languages

Language:JavaScript 78.5%Language:HTML 15.8%Language:CSS 5.8%