Spaces:
Sleeping
Sleeping
File size: 852 Bytes
7d23b62 beb9e09 7d23b62 beb9e09 7d23b62 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
from .minmax import *
import time
class Gomoku_bot:
def __init__(self, board, role, depth=4, enableVCT=False):
self.board = board
self.role = role
self.depth = depth
self.enableVCT = enableVCT
def get_action(self, return_time=True):
start = time.time()
score = minmax(self.board, self.role, self.depth, self.enableVCT)
end = time.time()
sim_time = end - start
move = score[1] # this move starts from left up corner (0,0), however, the move in the game starts from left bottom corner (0,0)
move = (self.board.size - 1 - move[0], move[1]) # convert the move to the game's coordinate
# turn tuple into an int
move = move[0] * self.board.size + move[1]
if return_time:
return move, sim_time
else:
return move
|