Add python c binding class interface #29
@@ -1,12 +1,12 @@
|
|||||||
from test.base import ChessLibTestBase
|
from test.base import ChessLibTestBase
|
||||||
from test.chess_ffi import Board
|
from binding.python_c_ffi import Board
|
||||||
from test.chess_ffi import perft
|
|
||||||
|
|
||||||
|
|
||||||
class TestPerftQuick(ChessLibTestBase):
|
class TestPerftQuick(ChessLibTestBase):
|
||||||
def test_perft_1(self):
|
def test_perft_1(self):
|
||||||
b = Board()
|
b = Board()
|
||||||
self.load_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", board=b)
|
fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
|
||||||
|
self.chess_ffi.load_fen(b, fen)
|
||||||
node_count = {
|
node_count = {
|
||||||
1: 20,
|
1: 20,
|
||||||
2: 400,
|
2: 400,
|
||||||
@@ -15,13 +15,14 @@ class TestPerftQuick(ChessLibTestBase):
|
|||||||
5: 4865609,
|
5: 4865609,
|
||||||
}
|
}
|
||||||
for node, count in node_count.items():
|
for node, count in node_count.items():
|
||||||
actual = int(perft(b, node))
|
actual = int(self.chess_ffi._c_perft(b, node))
|
||||||
self.assertEqual(count, actual, f"perft({node}) start pos")
|
self.assertEqual(count, actual, f"perft({node}) start pos")
|
||||||
|
|
||||||
|
|
||||||
def test_perft_2(self):
|
def test_perft_2(self):
|
||||||
b = Board()
|
b = Board()
|
||||||
self.load_fen("r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1", board=b)
|
fen = "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1"
|
||||||
|
self.chess_ffi.load_fen(b, fen)
|
||||||
node_count = {
|
node_count = {
|
||||||
1: 48,
|
1: 48,
|
||||||
2: 2039,
|
2: 2039,
|
||||||
@@ -29,13 +30,14 @@ class TestPerftQuick(ChessLibTestBase):
|
|||||||
4: 4085603,
|
4: 4085603,
|
||||||
}
|
}
|
||||||
for node, count in node_count.items():
|
for node, count in node_count.items():
|
||||||
actual = int(perft(b, node))
|
actual = int(self.chess_ffi._c_perft(b, node))
|
||||||
self.assertEqual(count, actual, f"perft({node}) start pos")
|
self.assertEqual(count, actual, f"perft({node}) start pos")
|
||||||
|
|
||||||
|
|
||||||
def test_perft_3(self):
|
def test_perft_3(self):
|
||||||
b = Board()
|
b = Board()
|
||||||
self.load_fen("8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 1", board=b)
|
fen = "8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 1"
|
||||||
|
self.chess_ffi.load_fen(b, fen)
|
||||||
node_count = {
|
node_count = {
|
||||||
1: 14,
|
1: 14,
|
||||||
2: 191,
|
2: 191,
|
||||||
@@ -44,13 +46,14 @@ class TestPerftQuick(ChessLibTestBase):
|
|||||||
5: 674624,
|
5: 674624,
|
||||||
}
|
}
|
||||||
for node, count in node_count.items():
|
for node, count in node_count.items():
|
||||||
actual = int(perft(b, node))
|
actual = int(self.chess_ffi._c_perft(b, node))
|
||||||
self.assertEqual(count, actual, f"perft({node}) start pos")
|
self.assertEqual(count, actual, f"perft({node}) start pos")
|
||||||
|
|
||||||
|
|
||||||
def test_perft_4(self):
|
def test_perft_4(self):
|
||||||
b = Board()
|
b = Board()
|
||||||
self.load_fen("r3k2r/Pppp1ppp/1b3nbN/nP6/BBP1P3/q4N2/Pp1P2PP/R2Q1RK1 w kq - 0 1", board=b)
|
fen = "r3k2r/Pppp1ppp/1b3nbN/nP6/BBP1P3/q4N2/Pp1P2PP/R2Q1RK1 w kq - 0 1"
|
||||||
|
self.chess_ffi.load_fen(b, fen)
|
||||||
node_count = {
|
node_count = {
|
||||||
1: 6,
|
1: 6,
|
||||||
2: 264,
|
2: 264,
|
||||||
@@ -58,13 +61,14 @@ class TestPerftQuick(ChessLibTestBase):
|
|||||||
4: 422333,
|
4: 422333,
|
||||||
}
|
}
|
||||||
for node, count in node_count.items():
|
for node, count in node_count.items():
|
||||||
actual = int(perft(b, node))
|
actual = int(self.chess_ffi._c_perft(b, node))
|
||||||
self.assertEqual(count, actual, f"perft({node}) start pos")
|
self.assertEqual(count, actual, f"perft({node}) start pos")
|
||||||
|
|
||||||
|
|
||||||
def test_perft_5(self):
|
def test_perft_5(self):
|
||||||
b = Board()
|
b = Board()
|
||||||
self.load_fen("rnbq1k1r/pp1Pbppp/2p5/8/2B5/8/PPP1NnPP/RNBQK2R w KQ - 1 8 ", board=b)
|
fen = "rnbq1k1r/pp1Pbppp/2p5/8/2B5/8/PPP1NnPP/RNBQK2R w KQ - 1 8"
|
||||||
|
self.chess_ffi.load_fen(b, fen)
|
||||||
node_count = {
|
node_count = {
|
||||||
1: 44,
|
1: 44,
|
||||||
2: 1486,
|
2: 1486,
|
||||||
@@ -72,13 +76,14 @@ class TestPerftQuick(ChessLibTestBase):
|
|||||||
4: 2103487,
|
4: 2103487,
|
||||||
}
|
}
|
||||||
for node, count in node_count.items():
|
for node, count in node_count.items():
|
||||||
actual = int(perft(b, node))
|
actual = int(self.chess_ffi._c_perft(b, node))
|
||||||
self.assertEqual(count, actual, f"perft({node}) start pos")
|
self.assertEqual(count, actual, f"perft({node}) start pos")
|
||||||
|
|
||||||
|
|
||||||
def test_perft_6(self):
|
def test_perft_6(self):
|
||||||
b = Board()
|
b = Board()
|
||||||
self.load_fen("r4rk1/1pp1qppp/p1np1n2/2b1p1B1/2B1P1b1/P1NP1N2/1PP1QPPP/R4RK1 w - - 0 10 ", board=b)
|
fen = "r4rk1/1pp1qppp/p1np1n2/2b1p1B1/2B1P1b1/P1NP1N2/1PP1QPPP/R4RK1 w - - 0 10"
|
||||||
|
self.chess_ffi.load_fen(b, fen)
|
||||||
node_count = {
|
node_count = {
|
||||||
1: 46,
|
1: 46,
|
||||||
2: 2079,
|
2: 2079,
|
||||||
@@ -86,5 +91,5 @@ class TestPerftQuick(ChessLibTestBase):
|
|||||||
4: 3894594,
|
4: 3894594,
|
||||||
}
|
}
|
||||||
for node, count in node_count.items():
|
for node, count in node_count.items():
|
||||||
actual = int(perft(b, node))
|
actual = int(self.chess_ffi._c_perft(b, node))
|
||||||
self.assertEqual(count, actual, f"perft({node}) start pos")
|
self.assertEqual(count, actual, f"perft({node}) start pos")
|
||||||
Reference in New Issue
Block a user