<filename>Machine.py
from random import choice


class Machine(object):
	"""Handle the possible moves for the machine Machine"""
	def __init__(self):
		super(Machine, self).__init__()
	
	def loadNew(self):
		self.table = {
		2:{'222100011':['0,1:1,0','0,1:1,1','0,2:1,2'],'222001110':['0,0:1,0','0,1:1,1','0,1:1,2'],
		   '222010101':['0,0:1,0','0,0:1,1','0,2:1,1','0,2:1,2']},
		4:{'202210001':['0,0:1,1','0,2:1,1','0,2:1,2','1,0:2,0'],'202012100':['0,0:1,1','0,0:1,0','0,2:1,1','1,2:2,2'],
		   '022120001':['0,1:1,0','0,2:1,2','1,1:2,1'],'220021100':['0,0:1,0','0,1:1,2','1,1:2,1'],
		   '202110010':['0,0:1,1','0,2:1,1','0,2:1,2'],'202011010':['0,0:1,1','0,2:1,1','0,0:1,0'],
		   '220101001':['0,1:1,0','0,1:1,1','0,1:1,2'],'022101100':['0,1:1,0','0,1:1,1','0,1:1,2'],
		   '022021100':['0,1:1,2','1,1:2,0','1,1:2,1'],'220120001':['0,1:1,0','1,1:2,2','1,1:2,1'],
		   '022211100':['0,1:1,2','0,2:1,1'],'220112001':['0,0:1,1','0,1:1,0'],
		   '202201010':['1,0:2,0','1,0:2,1'],'202102010':['1,2:2,1','1,2:2,2'],
		   '220112001':['0,0:1,1','0,1:1,0'],'022211100':['0,1:1,2','0,2:1,1'],
		   '022010001':['0,2:1,1','0,2:1,2'],'220010100':['0,0:1,0','0,0:1,1'],
		   '022010100':['0,2:1,1','0,2:1,2'],'220010001':['0,0:1,0','0,0:1,1'],
		   '202100001':['0,2:1,2'],'202001100':['0,0:1,0']},
		6:{'002221000':['1,0:2,0','1,1:2,1'],'200122000':['1,1:2,1','1,2:2,2'],
		   '200111000':['0,0:1,1'],'002111000':['0,2:1,1'],
		   '020211000':['0,1:1,2','1,0:2,0'],'020112000':['0,1:1,0','1,2:2,2'],
		   '200221000':['1,0:2,0','1,1:2,1'],'002122000':['1,1:2,1','1,2:2,2'],
		   '002210000':['0,2:1,1','0,2:1,2','1,0:2,0'],'200012000':['0,0:1,0','0,0:1,1','1,2:2,2'],
		   '020120000':['0,1:1,0','1,1:2,1'],'020021000':['0,1:1,2','1,1:2,1'],
		   '200210000':['0,0:1,1','1,0:2,0'],'002012000':['0,2:1,1','1,2:2,2']}}
		
	def chooseMove(self, boardState, currentRound):
		self.boardState = boardState
		self.currentRound = currentRound
		self.move = choice(self.table[self.currentRound][self.boardState])
		return self.move

	def learn(self, win):
		if win:
			self.table[self.currentRound][self.boardState] = [self.move]
		else:
			self.table[self.currentRound][self.boardState].remove(self.move)
