-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.py
47 lines (35 loc) · 1.29 KB
/
bot.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import gameInterface
import gameState
import AI
import time
from autopy import alert
# Contains an AI which interacts with the game via a GameInterface. The state
# is represented by a GameState
class Bot:
def __init__(self):
boardDim = gameState.Point(8,8)
self.ai = AI.AI(boardDim, 2)
self.gameInterface = gameInterface.GameInterface(boardDim)
self.gameState = gameState.GameState(boardDim)
# Begins a playing a game
def start(self):
while self.gameState.gameOver != True:
time.sleep(2)
if self.gameInterface.isMouseAtExit():
if alert.alert('Paused', 'Quit?'):
break
self.gameState = self.gameInterface.readGame()
move = self.ai.determineMove(self.gameState.board)
if move == None:
print 'No move!'#self.gameState.board
else:
self.gameInterface.makeMove(move)
#self.gameInterface.moveOffBoard()
print 'done!'
return self.gameState
# Main method just to start a game
def main():
bot = Bot()
return bot.start()
if __name__ == '__main__':
main()