Coder Social home page Coder Social logo

tictactoe's Introduction

Tic Tac Toe

This app implements a tic tac toe game of the user against the computer.

The game chooses a random player to start the game. You have always the "X" and the opponent (computer) has always the "O".

The Game can finish with either a win, a loss or a draw.

It then prompts you for a new game.

(Game screenshot) alt text

I hope you enjoy the game!

AI

This game uses a modified minimax algorithm1.

The AI first checks* if the computer can win on the next move, then checks if it has to prevent the player from winning in the next move.

If neither of the above apply, it then plays according to the minimax algorithm1.

I believe that you will find the overall AI behaviour quite competitive, resulting most of the times in a draw.

Demo

A demo is available here:

https://tic-tac-toe-pl2022.netlify.app

Instalation

A compiled version is ready in dist directory.

You will need to have npm installed in order to modify and rebuild.

$ npm install

package.json comes with the following scripts:

$ npm run build

Builds the dist folder in development mode

$ npm run prod

Builds the dist folder in production mode

(The dist provided in this repo was made with this command)

$ npm run dev

Runs the app in a development server at localhost:3000

Note

This app is an excersise during my self education in web design. I focused more on the css/javascript part rather than the actual logic of the AI. My contribution in the AI was the addition of the initial check* before using the minimax algorithm.

PL, 2022


References

1 Minimax Algorithm in Game Theory | Set 3 (Tic-Tac-Toe AI โ€“ Finding optimal move)

https://www.geeksforgeeks.org/minimax-algorithm-in-game-theory-set-3-tic-tac-toe-ai-finding-optimal-move/

tictactoe's People

Contributors

parisl69 avatar

Stargazers

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