Giter Club home page Giter Club logo

tic-tac-toe's Introduction

Tic-Tac-Toe

Tic Tac Toe is a game where the board is 3x3 and the user is aiming to place three of their symbol in a row horizontally, vertically, or diagonally.

Play it here: https://cooper-adams.github.io/Tic-Tac-Toe/

The goal in this project is create a playable Tic-Tac-Toe game within a browser and the logic of the game is entirely within modules or factories.

There are three modules that house the logic:

gameBoard - Keeps the array private and gives 4 public functions to access/modify it.

gameFlow - Deals with all gameplay logic. Has nine public functions, and 7 private functions. The private functions deal with checking for wins in the rows, columns, and diagonals. In addition, a few of the private functions contain the logic for the AI, specifically the MiniMax algorithm and its helpers. The MiniMax algorithm analyses the current game state and all possible future states to find the best move possible for that game state. And to increase efficiency, I am using Alpha-Beta pruning to prevent analysing further worst case board states.

displayController - Deals with the display in its entirety. All members are private, and there is one public function to be used for the AI to place their marker when they select their position. Also contains a delay function to make it seem as though the computer is thinking before making their move.

The MiniMax algorithm is efficient and effective thanks to the alpha-beta pruning, and at best you can tie with the AI on the "Impossible" difficulty. Otherwise, the game can end in a tie or have either player win in PvP or the other AI difficulties.

Future Considerations:

  • Score Board (Displays both user's marker's or one user's and the AI's)
  • Custom select dropdown (The options of the HTML select element cannot be styled with CSS)
  • Functionality to play as X or O.

tic-tac-toe's People

Contributors

cooper-adams 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.