def chooseAi(self, playerId): validAnswer = False ifAi = interfaceAi.interfaceAi() while not validAnswer: aiList = ifAi.getAiList() print "choose AI for", self.getPlayerName(playerId) itemCount = 0 for aiItem in ifAi.getAiList(): itemCount += 1 print str(itemCount) + ") " + aiItem choice = raw_input("choice:") if choice.isdigit(): choiceInt = int(choice) - 1 if len(aiList) >= choiceInt and choiceInt >= 0: return choiceInt
from interfaceAi import interfaceAi players = ["placeholder", ] aiInstances = ["placeholder", None, None] gl = gameLogic() gl.startGame() ic = console() players.append(ic.choosePlayer(1)) players.append(ic.choosePlayer(2)) for playerId in range(len(players)): if players[playerId] == "ai": pickedAiId = ic.chooseAi(playerId) aiInstances[playerId] = interfaceAi() aiInstances[playerId].initAi(pickedAiId, playerId) aiGameRounds = 0 drawGameField = True if players[1] == "ai" and players[2] == "ai": aiGameRounds = ic.chooseAiGameRounds() drawGameField = False startTime = time.time() keepPlaying = True while keepPlaying: if gl.isGameOver(): # tell the AIs what happened if players[1] == "ai":