Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Krasto committed Jan 9, 2024
1 parent 36697a2 commit eda0640
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ci_quixo/minmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ class MinMaxPlayer(Player):
def __init__(self, max_depth: int = None, *, alpha_beta: bool = True, pruning: bool = True, verbose: bool = False) -> None:
super().__init__()

self.max_depth = 3 if max_depth is None else max_depth
self.max_depth = 2 if max_depth is None else max_depth
self.use_alpha_beta_pruning = alpha_beta
self.use_symmetries = pruning
self.verbose = verbose
self.history: dict[str, "CompleteMove"] = dict()
self.stats = defaultdict(int)

def make_move(self, game: Game) -> "CompleteMove":
Expand Down Expand Up @@ -74,17 +75,22 @@ def max_side(self: "MinMaxPlayer", game: "CustomGame", alpha: int, beta: int, de
best_move = None
alpha, beta = -np.inf, np.inf

if str(game) in self.history:
self.stats['cache-hit'] += 1
return self.history[str(game)]

for move in moves_getter(game):
copy = game.simulate_move(move)
min_score = min_side(self, copy, alpha, beta, 1)
if min_score > alpha:
alpha = min_score
best_move = move
self.stats['EVALS'] += 1
self.history[str(game)] = best_move
return best_move


if __name__ == "__main__":
from helper import evaluate
m = MinMaxPlayer(pruning=True)
# evaluate(m, None, 1, True)
evaluate(m, None, 10, True)

0 comments on commit eda0640

Please sign in to comment.