Add weight calculation heuristic
This commit is contained in:
parent
45abd8c7eb
commit
1c039106d9
3 changed files with 59 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
import random, math
|
||||
from .Heuristic import ReversiHeuristic
|
||||
|
||||
class PlayerEngine:
|
||||
def __init__(self, logger, options: dict = {}):
|
||||
|
@ -88,7 +89,11 @@ class MinmaxPlayerEngine(PlayerEngine):
|
|||
move = ''
|
||||
if depth == 0:
|
||||
leafs +=1
|
||||
return board.heuristique(), nodes, leafs
|
||||
if self.options['heuristic'] == 'weight':
|
||||
score = ReversiHeuristic(board).get()
|
||||
else:
|
||||
score = board.heuristique()
|
||||
return score, nodes, leafs
|
||||
|
||||
if friend_move:
|
||||
value = -math.inf
|
||||
|
@ -150,7 +155,12 @@ class AlphabetaPlayerEngine(PlayerEngine):
|
|||
leafs = 0
|
||||
if depth == 0 :
|
||||
leafs +=1
|
||||
return board.heuristique(), nodes, leafs
|
||||
self.logger.debug("option: {}".format(self.options))
|
||||
if self.options['heuristic'] == 'weight':
|
||||
score = ReversiHeuristic(self.logger).get(board)
|
||||
else:
|
||||
score = board.heuristique()
|
||||
return score, nodes, leafs
|
||||
|
||||
if friend_move:
|
||||
value = -math.inf
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue