Git Product home page Git Product logo

tic-tac-toe's Introduction

TIcTacToe

TicTacToe game in C++

Uses minimax algorithm in game theory to find optimal move

Majority of the code is located in the Tictactoe.cpp file

"play" member function uses all the member functions to run a tic-tac-toe game

"isComplete" member function checks if any row, collumn or diagonal is completed. It aslo checks if all the cells are filled and therefore if game is draw

"getOptimalMove" member function finds optimal move using minimax algorithm which is a backtracking algorithm that recursively places move on all the possible cells and calculates score for each move

"setGrid" member function creates a grid (board) of desired size

"reset" member function resets all the data members to initial conditions

To run the tic-tac-toe program compile using:

g++ -std=c++14 -O1 main.cpp Tictactoe.cpp -o exec

then Run the tic-tac-toe game program using:

./exec

Tested with Ubuntu g++ 7.8.5 on Ubuntu 18.04

generated test cases to test the tic-tac-toe program

Used Catch2 framework to write test cases

To run the test cases compile the test file using:

g++ -std=c++14 -O1 catch_amalgamated.cpp test.cpp Tictactoe.cpp -o test

then run the test using:

./test < testCases.txt

tic-tac-toe's People

Contributors

rajshah05 avatar

Watchers

James Cloos 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.