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