Implementation of turn based game Quixo in Python. Minimax with alpha beta pruning algorithm is used for computer play.
Pass any player instance from players.py to play.py
Random vs Random
# 100 Iterations
# play.py
play(RandomPlayer(),RandomPlayer(),100)
AI vs Random
# 100 Iterations
# play.py
play(AI_Player(GOOD_AI_PLAYER),RandomPlayer(),100)
play(piece,move)
piece: tuple = (row,col)
move: int = Direction
SLIDE_LEFT = 0
SLIDE_UP = 1
SLIDE_RIGHT = 2
SLIDE_DOWN = 3
Only blank and self pieces can be moved.
Only edge pieces can be moved.
if row is 0 cant slide down
if row is board_size cant slide up
if col is 0 cant slide right
if col is board_size cant slide down
0 = Blank
1 = X
2 = O
1 = X
2 = O
V = evaluate(board)
V = 100 + depth (X wins with minimum number of movements)
V = - (100 + depth) (O wins with minimum number of movements)
More owned pieces on the board is usually better in initial game states.
V = (X Piece Count) - (O Piece Count)
printBoard() - print game board
printTurn() - prints current turn
getPossibleMoves() - returns all possible moves for the current board.
Returns moves in list of (piece,move)
getPossiblePieceMove() returns all possible moves for a single piece for current board.
Returns (move)
isGameEnd() - Returns winner integer value if game ended else returns None
changeTurn() - Changes turn
shift() - Shifts board when moving a piece
Used by play() method
checkMove() - Check a move if its valid
Returns True or False