def test_raw_material_score_black_turn(self): fen = "1r1q1rk1/3nbppp/p1bp4/2p1pn2/P3P3/2NP3P/1BPQ1PP1/1R2KB1R w K - 0 17" board = chess.Board(fen=fen) analyse_return_value = { 'string': 'NNUE evaluation using nn-82215d0fd0df.nnue enabled', 'depth': 5, 'seldepth': 5, 'multipv': 1, 'score': chess.engine.PovScore(chess.engine.Cp(648), chess.BLACK), 'nodes': 228, 'nps': 114000, 'tbhits': 0, 'time': 0.002, 'pv': [ chess.Move.from_uci('e4f5'), chess.Move.from_uci('e7g5'), chess.Move.from_uci('d2d1'), chess.Move.from_uci('d8a5'), chess.Move.from_uci('b2a1'), chess.Move.from_uci('d6d5'), chess.Move.from_uci('h3h4') ] } rms = engine.RawMaterialScores(depth=5) expected_scores = [3, 0, 0, 0, 0, 0] with mock.patch("chessmate.features.engine.EngineFeature.engine") as mock_engine: mock_engine.analyse.return_value = analyse_return_value result = rms(board) self.assertSequenceEqual(result, expected_scores)
def test_raw_material_score_black_1_up(self): expected_score = 1 fen = "rn2k3/p2b1p1p/4p2B/8/1p3b2/1P1q4/P2P1P1P/R2QR1K1 w q - 0 19" board = chess.Board(fen=fen) rms = engine.RawMaterialScores(depth=0) result = rms._raw_material_score(board, chess.BLACK) self.assertEqual(result, expected_score)
def test_raw_material_score_white_2_up(self): expected_score = 2 fen = "rn2k3/p2b1p1p/3bp2B/8/1p6/1P1q4/P2P1PNP/R2QR1K1 w q - 0 18" board = chess.Board(fen=fen) rms = engine.RawMaterialScores(depth=0) result = rms._raw_material_score(board, chess.WHITE) self.assertEqual(result, expected_score)
def test_relative_plies(self): relative_plies = [0, 1, 5] expected_use_ply = [True, True, False, False, False, True] rms = engine.RawMaterialScores(relative_plies=relative_plies) self.assertEqual(rms.depth, 6) self.assertSequenceEqual(rms.use_ply, expected_use_ply)
def test_depth(self): expected_depth = 7 expected_use_ply = [True] * 7 rms = engine.RawMaterialScores(depth=expected_depth) self.assertEqual(rms.depth, expected_depth) self.assertSequenceEqual(rms.use_ply, expected_use_ply)