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 = ''
if depth == 0:
leafs +=1
return self.heuristic.get(board), nodes, leafs
return self.heuristic.get(board, self.player), nodes, leafs
if friend_move:
value = -math.inf
@ -154,7 +154,7 @@ class AlphabetaPlayerEngine(PlayerEngine):
leafs = 0
if depth == 0 :
leafs +=1
return self.heuristic.get(board), nodes, leafs
return self.heuristic.get(board, self.player), nodes, leafs
if friend_move:
value = -math.inf

View file

@ -11,23 +11,23 @@ class HeuristicEngine:
raise NotImplementedError
class ScoreHeuristicEngine(HeuristicEngine):
def get(board):
return board.heuristique()
def get(self, board, player):
return board.heuristique(player)
class WeightHeuristicEngine(HeuristicEngine):
def get(self, board):
score = self.get_weight(board)
def get(self, board, player):
score = self.get_weight(board, player)
return score
def get_weight(self, board):
def get_weight(self, board, player):
score = 0
size = board.get_board_size()
weights = self._get_weight_array(size)
for pos_x 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]
else:
score -= weights[pos_x][pos_y]
@ -55,5 +55,5 @@ class WeightHeuristicEngine(HeuristicEngine):
class FullHeuristicEngine(WeightHeuristicEngine):
def get(self, board):
return self.get_weight(board) + board.heuristique()
def get(self, board, player):
return self.get_weight(board, player) + board.heuristique(player)