🐛
This commit is contained in:
@ -246,7 +246,6 @@ def hexAI(channel):
|
||||
data = json.load(f)
|
||||
|
||||
board = data[channel]["board"]
|
||||
player = (data[channel]["players"].index("Gwendolyn")+1) % 2
|
||||
difficulty = data[channel]["difficulty"]
|
||||
"""
|
||||
if len(data[channel]["gameHistory"]):
|
||||
@ -271,7 +270,6 @@ def hexAI(channel):
|
||||
|
||||
possiblePlaces = [i for i,v in enumerate(sum(board,[])) if v == 0]
|
||||
judgements = [-math.inf]*len(possiblePlaces) # All possible moves are yet to be judged
|
||||
|
||||
|
||||
for i in possiblePlaces:
|
||||
testBoard = copy.deepcopy(board)
|
||||
@ -280,7 +278,8 @@ def hexAI(channel):
|
||||
judgements[i] = minimaxHex(testBoard,difficulty,-math.inf,math.inf,False)
|
||||
logThis("Best score for place {} is {}".format((i // BOARDWIDTH,i % BOARDWIDTH),judgements[i]))
|
||||
|
||||
bestScore = max(judgements) # the value of the best score(s)
|
||||
GwenColor = data[channel]["players"].index("Gwendolyn") + 1
|
||||
bestScore = max(judgements) if (GwenColor == 1) else min(judgements)
|
||||
indices = [i for i, x in enumerate(judgements) if x == bestScore] # which moves got that score?
|
||||
i = random.choice(indices)
|
||||
chosenMove = (i // BOARDWIDTH , i % BOARDWIDTH)
|
||||
|
Reference in New Issue
Block a user