def getMoveThatFillsMainDiagonal(self, state, aSymbol): symbolCounter = 0 emptyLine = 0 emptyColumn = 0 myMove = move.Move(0, 0) if state.emptyPosition(1, 1): emptyLine = 1 emptyColumn = 1 else: if (state.getValue(1, 1) == aSymbol): symbolCounter += 1 if state.emptyPosition(2, 2): emptyLine = 2 emptyColumn = 2 else: if (state.getValue(2, 2) == aSymbol): symbolCounter += 1 if state.emptyPosition(3, 3): emptyLine = 3 emptyColumn = 3 else: if (state.getValue(3, 3) == aSymbol): symbolCounter = symbolCounter + 1 if symbolCounter == 2: myMove = move.Move(emptyLine, emptyColumn) return myMove
def getMove3Way2(self, state): if state.emptyPosition(1, 2): myMove = self.getBasicMove(state) else: self.moveOrder += 1 if (state.emptyPosition(2, 3)): myMove = move.Move(3, 3) else: myMove = move.Move(3, 1) return myMove
def getMove3Way1(self, state): self.moveOrder += 1 if state.emptyPosition(2, 1): myMove = self.getBasicMove(state) else: if ((state.emptyPosition(3, 2)) and (state.emptyPosition(3, 3))): myMove = move.Move(3, 3) else: myMove = move.Move(1, 3) return myMove
def getMove3Way3(self, state): if state.occupiedPosition(3, 1): self.moveOrder += 1 myMove = move.Move(1, 3) else: if state.occupiedPosition(1, 3): self.moveOrder += 1 myMove = move.Move(3, 1) else: myMove = self.getBasicMove(state) return myMove
def getMove2(self, state): self.moveOrder += 1 if state.occupiedPosition(2, 2): self.strategyWay = 3 myMove = move.Move(3, 3) else: if ((state.occupiedPosition(2, 1)) or (state.occupiedPosition(2, 3)) or (state.occupiedPosition(3, 1))): self.strategyWay = 2 myMove = move.Move(1, 3) else: self.strategyWay = 1 myMove = move.Move(3, 1) return myMove
def getMove2(self, state): if (state.emptyPosition(3, 3)): self.strategyWay = 1 myMove = self.getBasicMove(state) else: self.strategyWay = 2 self.moveOrder += 1 myMove = move.Move(3, 1) return myMove
def click(self, line, column): if (self.getStatus() == 1): self.startMatch() else: if (self.getStatus() == 2 or self.getStatus() == 3): aMove = move.Move(line, column) self.proceedMove(aMove) else: if (self.getStatus() == 4 or self.getStatus() == 5): self.reset()
def getAnyPossibleMove(self, state): myMove = None for x in range(3): aLine = x + 1 for y in range(3): aColumn = y + 1 if state.emptyPosition(aLine, aColumn): myMove = move.Move(aLine, aColumn) return myMove return myMove
def getMoveThatFillsColumn(self, state, aSymbol): symbolCounter = 0 emptyLine = 0 emptyColumn = 0 myMove = move.Move(0, 0) for y in range(3): aColumn = y + 1 if (state.occupiedPositionsOnTheColumn(aColumn) == 2): symbolCounter = 0 emptyLine = 0 emptyColumn = 0 for x in range(3): aLine = x + 1 if state.emptyPosition(aLine, aColumn): emptyLine = aLine emptyColumn = aColumn else: if (state.getValue(aLine, aColumn) == aSymbol): symbolCounter = symbolCounter + 1 if symbolCounter == 2: myMove = move.Move(emptyLine, emptyColumn) return myMove
def getFirstMove(self): return move.Move(1, 1)
def enable(self, aState): self.turn = True return move.Move(0, 0)
def getMove1(self, state): self.moveOrder += 1 myMove = move.Move(1, 1) return myMove
def getMove2(self, state): # strategyWay 1 if ((state.occupiedPositionsOnTheLine(1) == 2) or (state.occupiedPositionsOnTheLine(3) == 2) or (state.occupiedPositionsOnTheColumn(1) == 2) or (state.occupiedPositionsOnTheColumn(3) == 2)): self.strategyWay = 1 myMove = self.getBasicMove(state) else: # strategyWay 2 if (((state.occupiedPosition(1, 2)) and (state.occupiedPosition(3, 2))) or ((state.occupiedPosition(2, 1)) and (state.occupiedPosition(2, 3)))): self.strategyWay = 2 self.moveOrder += 1 myMove = move.Move(1, 1) else: # strategyWay 3 if (((state.occupiedPosition(1, 1)) and (state.occupiedPosition(3, 3))) or ((state.occupiedPosition(3, 1)) and (state.occupiedPosition(1, 3)))): self.strategyWay = 3 self.moveOrder += 1 myMove = move.Move(2, 1) else: # strategyWay 4 if (((state.occupiedPosition(1, 2)) and (state.occupiedPosition(2, 3))) or ((state.occupiedPosition(1, 2)) and (state.occupiedPosition(3, 3))) or ((state.occupiedPosition(1, 1)) and (state.occupiedPosition(2, 3)))): self.strategyWay = 4 self.moveOrder += 1 myMove = move.Move(1, 3) else: # strategyWay 5 if (((state.occupiedPosition(1, 2)) and (state.occupiedPosition(2, 1))) or ((state.occupiedPosition(1, 2)) and (state.occupiedPosition(3, 1))) or ((state.occupiedPosition(1, 3)) and (state.occupiedPosition(2, 1)))): self.strategyWay = 5 self.moveOrder += 1 myMove = move.Move(1, 1) else: # strategyWay 6 if (((state.occupiedPosition(3, 2)) and (state.occupiedPosition(1, 3))) or ((state.occupiedPosition(3, 2)) and (state.occupiedPosition(2, 3))) or ((state.occupiedPosition(3, 1)) and (state.occupiedPosition(2, 3)))): self.strategyWay = 6 self.moveOrder += 1 myMove = move.Move(3, 3) else: # strategyWay 7 self.strategyWay = 7 self.moveOrder += 1 myMove = move.Move(3, 1) return myMove