Package MeatEngine :: Package AI :: Module randomPlayer
[hide private]
[frames] | no frames]

Source Code for Module MeatEngine.AI.randomPlayer

 1  import random 
 2   
3 -class RandomTicTacToePlayer:
4 - def __init__(self, side):
5 self.side=side
6
7 - def getMove(self, board):
8 legalMoves=[] 9 for x in range(3): 10 for y in range(3): 11 if board.isLegalMove(x,y,self.side): 12 legalMoves.append((x,y)) 13 x,y=random.choice(legalMoves) 14 return 3*y+x+1
15