def InitGame(): global player1, robot, boneyard, gameTable, turn, player2, player3, playerNum, start, player1Play global gameTable1, gameTable2, gameTable3, gameTable4, gameTable5, gameTable6, gameTable7, StartUp robot = initDomino.robot player1 = initDomino.player1 #print player1Play gameTable1 = [] gameTable2 = [] gameTable3 = [] gameTable4 = [] gameTable5 = [] gameTable6 = [] gameTable7 = [] if initDomino.start == 0: gameTable = initDomino.gameTable game.Turn() elif initDomino.start == 1: #THIS NEEDS CHANGING print gameTable # turn = [] if initDomino.playerNum == 1: boneyard = initDomino.boneyard else: player2 = initDomino.player2 player3 = initDomino.player3 whoStarts()
def getInitRobot(): global init, robot print("getInitRobot") robot = initDomino.robot # print robot[0] # print("IM HERE") game.Turn() init = False return robot, init
def Human4(): global human, gameTable, play, pickBone, boneyard, gameType, turn, human2, human3 turn = main.turn human = main.human human2 = main.human2 human3 = main.human3 play = [] game.GameStatus() while True: try: humanPlay = raw_input( '*** input tile *** ') # input the tile you want to play if humanPlay == "pass" or humanPlay == "00": break else: humanPlay = int(humanPlay) break except ValueError: print("Whoops, try typing it again...") if humanPlay == "pass": # goes to the next person game.Turn() print("turn = ") print turn elif humanPlay == "00": play = np.zeros(2) else: humanPlay = int(humanPlay) humanPlay = [int(i) for i in str(humanPlay)] play = np.append(humanPlay, play) Remove() # remove played tile from hand Place() # place tile on gameTable
def Random(): global match, robot, gameTable, play, pickBone, boneyard, gameType, possMove, playerNum, play global gameTable1, gameTable2, gameTable3, gameTable4, gameTable5, gameTable6, gameTable7 game.Turn() print game.turn if len(game.turn) == 1 or len(game.turn) == 2: robot, init = mainDomino.getInitRobot() # print init gameTable = mainDomino.getInitGameTable() # gameTable1 = mainDomino.gameTable1 elif len(game.turn) == 3 or len(game.turn) == 4: robot = mainDomino.robot gameTable = playersInput.gameTable # gameTable1 = mainDomino.gameTable1 else: gameTable = playersInput.gameTable # gameTable1 = playersInput.gameTable1 if len(mainDomino.gameTable1) == 2 and len(game.turn) >= 3: gameTable1 = playersInput.gameTable1 else: gameTable1 = mainDomino.gameTable1 if len(mainDomino.gameTable2) > 2: gameTable2 = playersInput.gameTable2 else: gameTable2 = mainDomino.gameTable2 if len(mainDomino.gameTable3) > 2: gameTable3 = playersInput.gameTable3 else: gameTable3 = mainDomino.gameTable3 if len(mainDomino.gameTable4) > 2: gameTable4 = playersInput.gameTable4 else: gameTable4 = mainDomino.gameTable4 if len(mainDomino.gameTable5) > 2: gameTable5 = playersInput.gameTable5 else: gameTable5 = mainDomino.gameTable5 if len(mainDomino.gameTable6) > 2: gameTable6 = playersInput.gameTable6 else: gameTable6 = mainDomino.gameTable6 if len(mainDomino.gameTable7) > 2: gameTable7 = playersInput.gameTable7 else: gameTable7 = mainDomino.gameTable7 #elif init == False: ## We want this one if its not coming from init # robot = mainDomino.robot # if len(robot)<6: # robot = mainDomino.UpdateRobot() # gameTable = mainDomino.gameTable phrases.supportive("robotsTurn") #phrases.competitive("robotsTurn") Matching() play = [] robotPlay = [] # if initDomino.playerNum == 1: # boneyard = mainDomino.boneyard # else: # player2 = mainDomino.player2 # player3 = mainDomino.player3 #gameType = initDomino.gameType # if there is one match then play it # print("match = ") # print match if len(match) == 2: robotPlay = match # play = [int(play) for play in play] # if there are more than one match, randomly pick one to play elif len(match) >= 4: i = len(match) / 2 possMove = np.resize(match, (i, 2)) match = random.sample(possMove, 1) robotPlay = np.resize(match, (1, 2)) elif len(match) == 0: while match == []: i = len(robot) + 1 if len(mainDomino.boneyard) > 0: initDomino.asr.say("I need a tile from the boneyard please") mainDomino.robotsTiles() pickBone = mainDomino.bar robot = np.append(pickBone, robot) robot = np.reshape(robot, (i, 2)) RemoveBoneyard() mainDomino.UpdateBoneyard() mainDomino.UpdateRobot() Random() elif len(boneyard) == 0: # if there are no more tiles in boneyard turn = game.Turn() # get next players turn if initDomino.playerNum == 1: print("boneyard empty, player1's turn") playersInput.player1sTurn() # player1s turn else: print("next players turn") playersInput.fourPlayer( ) # otherwise its the next persons go # print("here") play = np.append(robotPlay, play) Remove() mainDomino.Doubles() whereToPlace() Place() # place tile on gameTable # print("here!!!!!") numCards = str(len(robot)) #print("I have " + numCards + " cards left") # mainDomino.UpdateGame() game.GameStatus() # print robot # game.Turn() if initDomino.playerNum == 1: playersInput.player1sTurn() else: playersInput.fourPlayer()
options.columns = ['r', 'y', 'g'] out = [] n = 10000 zombie = z.Zombie() for r in red_dice_options: for y in yellow_dice_options: for g in green_dice_options: if g + y + r > 0: # do not calculate for zero dice jar = gb.Jar(g, y, r) print jar shots = [] brains = [] for i in range(n): turn = z.Turn(zombie, jar) turn.roll_dice() brains.append(turn.zombie.brains) shots.append(turn.zombie.shots) shots = np.array(shots) brains = np.array(brains) out.append([g, y, r, brains, shots]) out = pd.DataFrame(out) out.columns = ['greens', 'yellows', 'reds', 'brains_array', 'shots_array'] out['mean_brains'] = out.brains_array.apply(np.mean) out['mean_shots'] = out.shots_array.apply(np.mean) out.set_index(['greens', 'yellows', 'reds'], inplace=True) out['prob_0_shots'] = out.shots_array.apply( lambda x: 1.0 * len(x[x == 0]) / len(x)) out['prob_1plus_shots'] = out.shots_array.apply(