Add python c binding class interface (#29)
All checks were successful
Python tests (make) / test (push) Successful in 14s

Reviewed-on: #29
Co-authored-by: Josh <josh@joshuaschuett.com>
Co-committed-by: Josh <josh@joshuaschuett.com>
This commit is contained in:
2025-08-22 19:28:03 +00:00
committed by Josh
parent c27977bef8
commit 6005741b10
10 changed files with 338 additions and 357 deletions

View File

@@ -1,33 +1,15 @@
import unittest
from test.chess_ffi import Board
from test.chess_ffi import KING_ATTACKS
from test.chess_ffi import KNIGHT_ATTACKS
from test.chess_ffi import PAWN_ATTACKS
from test.chess_ffi import gen_moves
from test.chess_ffi import init_attack_caches
from test.chess_ffi import load_fen
from binding.python_c_ffi import Board
from binding.python_c_ffi import ChessFFI
class ChessLibTestBase(unittest.TestCase):
@classmethod
def setUpClass(cls):
init_attack_caches()
cls.KNIGHT_ATTACKS = KNIGHT_ATTACKS
cls.KING_ATTACKS = KING_ATTACKS
cls.PAWN_ATTACKS = PAWN_ATTACKS
cls.chess_ffi = ChessFFI()
cls.chess_ffi.init_attack_cache()
def setUp(self):
# This should be an empty board for each test in the suite.
self.board = Board()
def load_fen(self, fen, board=None):
if board:
return load_fen(board, fen)
return load_fen(self.board, fen)
def gen(self, captures_only: bool = False, cap: int = 256):
return gen_moves(self.board, captures_only=captures_only, cap=cap)
self.board = Board()