Simplify weight heuristic calculation

This commit is contained in:
Yorick Barbanneau 2023-12-22 16:18:44 +01:00
parent 1b984f7a5e
commit d3077f8fea

View file

@ -77,18 +77,17 @@ class WeightHeuristicEngine(HeuristicEngine):
def get_weight(self, board, player):
score = 0
size = self.options['size']
w = [[0 for _ in range(size)] for _ in range(size)]
for pos_x in range(self.options['size']):
for pos_y in range(self.options['size']):
# Get player at x,y
p = board._board[pos_x][pos_y]
if p == player:
score += self.weights[pos_x][pos_y]
w[pos_x][pos_y] = self.weights[pos_x][pos_y]
elif p != player and p != board._EMPTY:
elif p != board._EMPTY:
score -= self.weights[pos_x][pos_y]
w[pos_x][pos_y] = -self.weights[pos_x][pos_y]
return score
"""