Simplify weight heuristic calculation
This commit is contained in:
parent
1b984f7a5e
commit
d3077f8fea
1 changed files with 4 additions and 5 deletions
|
@ -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
|
||||
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue