def __init__(self, screen, width, height): self.screen = screen self.gray = (128, 128, 128) self.red = (255, 0, 0) self.numXPieces = 8 self.numYPieces = 8 self.bombNum = 10 self.gameState = gameState(self.screen, self.numXPieces, self.numYPieces, width, height, self.bombNum)
def main(): game=gameState() players=[] from drawBoard import HumanBot from RandomBot import RandomBot from CaptureBot import CaptureBot from BetterBot import BetterBot #set players players=[0, 0] players[0]=HumanBot() players[1]=HumanBot() #NB 14 characters is maximum name size game.blackName=players[0].getName() game.whiteName=players[1].getName() #draw game for first time drawBoard.redraw(game, players) #waitForKey() passCounter=0 while passCounter<2: print('Thinking...') (i, j) = players[playerNumber(game.move)].getMove(game) #print('Engine selected ', (i, j)) if False: #player control of engine moves drawBoard.redraw(game, players) print('Engine selected ', (i, j), '. Waiting for human choice...') (i, j)=HumanBot().getMove(game) if (i, j)==(-1, -1): passCounter+=1 else: passCounter=0 drawBoard.redraw(game, players, True) print('Engine selected: ', (i, j), ' based on this board') #waitForKey() game.makeMove(i, j, False) drawBoard.redraw(game, players) #time.sleep(0.5) #waitForKey() drawBoard.redraw(game, players) print('Game Over') waitForKey() sys.exit()
def main(): game = gameState() #set players players = [0, 0] players[0] = HumanBot() players[1] = HumanBot() #NB 14 characters is maximum name size game.blackName = players[0].getName() game.whiteName = players[1].getName() #draw game for first time gui.redraw(game, players) #waitForKey() play(game, players) gui.redraw(game, players) print('Game Over') waitForKey() sys.exit()
def main(): game=gameState() #set players players=[0, 0] players[0]=HumanBot() players[1]=HumanBot() #NB 14 characters is maximum name size game.blackName=players[0].getName() game.whiteName=players[1].getName() #draw game for first time gui.redraw(game, players) #waitForKey() play(game, players) gui.redraw(game, players) print('Game Over') waitForKey() sys.exit()
def newGame(): global gamestate while True: name = input("Enter a name for your new character:\n") while True: for i in range(len(characters)): if characters[i][0] == name: print("That name is alrady taken! Please try another!") name = input("Enter a name for your new character:\n") break break print("Why hello there {}!".format(name)) print("Please choose one of the follow skills to put points into.") points = 3 while points > 0: print("Points to spend: {}".format(points)) gamestate.displayStats() addedPoint = int(input("Enter the number of the skill you want to upgrade:\n")) while addedPoint not in [range(len(gamestate.stats)-1)]: addedPoint = int(input("Please enter the number of the skill you want to upgrade:\n")) gamestate.stats[addedPoint] += 1 points -= 1 gamestate.displayStats() confirm = input("Please confirm your info! (Y/N)") while confirm.lower() not in "yn": gamestate.displayStats() confirm = input("Please confirm your info! (Y/N)") if confirm.lower() == "y": tmpCharacter = Character(name, gameState.stats, []) characters.append(tmpCharacter) gamestate = gameState(tmpCharacter) save() break hub()
#!/usr/bin/env python3 from gameState import * from play import * gameState = gameState() play = play(gameState) play.run()
def __init__(self, row): self.gameStates = [] self.safe = None for r in row: self.gameStates.append(gameState(r))
from GUI import * from randomBot import * from human import * from basicBot import * from reinforceBot import * play = 0 train = 0 # when training the ball velocity is set much higher showGame = 1 test = 0 tic = time.time() numberOfGames = 10 gameCounter = 0 gameState = gameState(play, showGame) progress = progress(gameState) if play: leftPlayer = reinforceBot(gameState, 'left', True, progress) rightPlayer = human(gameState, 'right', True, progress) while gameState.gameover == 0: progress.timeStep(leftPlayer, rightPlayer) gameState.gui.update() if gameState.gameover > 0: gameCounter += 1 gameState.startGame() if gameCounter >= numberOfGames: break elif train: leftPlayer = reinforceBot(gameState, 'left', True, progress)