Fix: bad parameters

This commit is contained in:
Yorick Barbanneau 2023-12-17 01:18:34 +01:00
parent c8447b7a6b
commit a64e318c82
2 changed files with 10 additions and 10 deletions

View file

@ -92,7 +92,7 @@ class MinmaxPlayerEngine(PlayerEngine):
move = '' move = ''
if depth == 0: if depth == 0:
leafs +=1 leafs +=1
return self.heuristic.get(board), nodes, leafs return self.heuristic.get(board, self.player), nodes, leafs
if friend_move: if friend_move:
value = -math.inf value = -math.inf
@ -154,7 +154,7 @@ class AlphabetaPlayerEngine(PlayerEngine):
leafs = 0 leafs = 0
if depth == 0 : if depth == 0 :
leafs +=1 leafs +=1
return self.heuristic.get(board), nodes, leafs return self.heuristic.get(board, self.player), nodes, leafs
if friend_move: if friend_move:
value = -math.inf value = -math.inf

View file

@ -11,23 +11,23 @@ class HeuristicEngine:
raise NotImplementedError raise NotImplementedError
class ScoreHeuristicEngine(HeuristicEngine): class ScoreHeuristicEngine(HeuristicEngine):
def get(board): def get(self, board, player):
return board.heuristique() return board.heuristique(player)
class WeightHeuristicEngine(HeuristicEngine): class WeightHeuristicEngine(HeuristicEngine):
def get(self, board): def get(self, board, player):
score = self.get_weight(board) score = self.get_weight(board, player)
return score return score
def get_weight(self, board): def get_weight(self, board, player):
score = 0 score = 0
size = board.get_board_size() size = board.get_board_size()
weights = self._get_weight_array(size) weights = self._get_weight_array(size)
for pos_x in range(size): for pos_x in range(size):
for pos_y in range(size): for pos_y in range(size):
if board._board[pos_x][pos_y] == board._nextPlayer: if board._board[pos_x][pos_y] == player:
score += weights[pos_x][pos_y] score += weights[pos_x][pos_y]
else: else:
score -= weights[pos_x][pos_y] score -= weights[pos_x][pos_y]
@ -55,5 +55,5 @@ class WeightHeuristicEngine(HeuristicEngine):
class FullHeuristicEngine(WeightHeuristicEngine): class FullHeuristicEngine(WeightHeuristicEngine):
def get(self, board): def get(self, board, player):
return self.get_weight(board) + board.heuristique() return self.get_weight(board, player) + board.heuristique(player)