Skip to content

A python script to evaluate any position in Tic Tac Toe.

License

Notifications You must be signed in to change notification settings

THARUN-V/Tic_Tac_Toe

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Tic_Tac_Toe

A python script to evaluate any position in Tic Tac Toe.

Running this code on your machine:

  1. Have a functioning Python 2.7+ version installed
  2. Clone this repository
  3. Open a terminal and cd into src
  4. Run python and import main (and optionally import positions)
  5. Run main.solve() on a position (either make your own or use one from positions.py)

Examples:

main.solve([['_', 'O', 'X'], ['_', 'X', '_'], ['O', '_', 'X']])
main.solve(positions.o_wins_1)

Use capital X, capital O, and underscores for X, O, and blanks respectively.

Always pass in a 3x3 list. X always goes first.

Explanation of the Code

This code is meant to follow minimax strictly by building a full decision tree under the position.

The position is evaluated from the bottom up, assuming both X and O are perfect players.

The program deliberately does not take advantage of storing positions or checking for symmetry.

There is a performance hit as a result (opening position: ~15 seconds, 1 Move: ~2 seconds, 2+ Moves: Instant)

About

A python script to evaluate any position in Tic Tac Toe.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%