Skip to content

A tic-tac-toe library that supports different sizes and dimensions and how many marks in a row to win

License

Notifications You must be signed in to change notification settings

AttackingOrDefending/python-tictactoe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-tictactoe

PyPI version Tests Build Mypy codecov

A tic-tac-toe library that supports different sizes and dimensions and how many marks in a row to win.

Installing

Download and install the latest release:

pip install python-tictactoe

Features

  • Includes mypy typings.

  • Different board sizes

from tictactoe import Board

board = Board(dimensions=(4, 5))
  • More than 2 dimensions
from tictactoe import Board

board = Board(dimensions=(6, 2, 5, 8))
  • More than 3 in a row to win
from tictactoe import Board

board = Board(dimensions=(10, 10, 10), x_in_a_row=8)
  • See the board
from tictactoe import Board

board = Board(dimensions=(2, 2, 2), x_in_a_row=2)
board.push((0, 0, 0))
board.push((0, 1, 0))
print(board)

"""
 X |   
-------
 O |   
-------
-------
   |   
-------
   |   
"""
  • Generate endgame tablebases
from tictactoe.egtb import Generator
import functools, operator

dimensions = (4, 3)
total_squares = functools.reduce(operator.mul, dimensions)
for index in reversed(range(total_squares + 1)):
    Generator(dimensions, 3, index)
  • Read endgame tablebases
from tictactoe.egtb import Reader
from tictactoe import Board

reader = Reader((3, 3), 3, 2)
board = Board((3, 3), 3)
board.push((0, 0))
board.push((0, 1))
print(reader.index(board))

License

python-tictactoe is licensed under the MIT License. Check out LICENSE for the full text.

About

A tic-tac-toe library that supports different sizes and dimensions and how many marks in a row to win

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages