Remove same check
All checks were successful
Python tests (make) / test (push) Successful in 11s

This commit is contained in:
2025-08-25 13:02:53 -04:00
parent 9fa0a959d5
commit 633cdd2d7d

View File

@@ -15,6 +15,10 @@ class BaseEvaluation:
pass
def get_params(self):
pass
"""
We will use a random move evaluation as our base AI. This
is expected to be the worst performing strategy. We can
@@ -38,15 +42,7 @@ class NegaMaxEval(BaseEvaluation):
self.window = cp_window
def _same(self, a, b):
return (int(getattr(a, "from")) == int(getattr(b, "from"))
and int(a.to) == int(b.to)
and int(getattr(a, "promo", 0) or 0) == int(getattr(b, "promo", 0) or 0))
def get_best_move(self, board, legal_moves):
if not legal_moves:
raise RuntimeError("No legal moves")
best = Move()
ok = self.chess_ffi._c_ai_find_best_move_with_window(
board,
@@ -56,7 +52,9 @@ class NegaMaxEval(BaseEvaluation):
)
if ok:
for m in legal_moves:
if self._same(m, best):
return m
return best
return legal_moves[0]
def get_params(self):
return [self.depth, self.window]