def MenuPrincipal(): imprimir_menu() opcion = input("") Beep.Beep() while (opcion != '1' and opcion != '2' and opcion != '3'): print("==>Por Favor eliga opción 1 o 2<==") opcion = input("") Beep.Beep() Limpiar.Limpiar() if (opcion == '1'): Play.play() time.sleep(3) return True elif (opcion == '2'): Limpiar.Limpiar() Ranking.ImprimirRanking() input("presione enter para volver...") return True elif (opcion == '3'): despedir() return False
def _handle_btn_events(self, cursor, event): if self.btn_dict.get("classic").is_clicked(cursor, event): Play() elif self.btn_dict.get("survival").is_clicked(cursor, event): Play() elif self.btn_dict.get("back").is_clicked(cursor, event): return 0
def two_players_offline(self): play = Play(2, self.screen, self.clock, gameTerrain) play.two_players_offline('Player 1', 'Player 2') pygame.mouse.set_visible(True) #pygame.mixer.music.play(-1) self.start_menu() return
def one_player(self): active = False play = Play(1, self.screen, self.clock, gameTerrain) play.one_player() pygame.mouse.set_visible(True) #pygame.mixer.music.play(-1) active = True
def main(): game = Game.Game(X='X', O='O') game.set_table() Xplayer = Play.Player('X', game) Oplayer = Play.Player('O', game) while True: Xplayer.play() game.check_the_table() Oplayer.play() game.check_the_table()
def partGen(genre, insturment, part="Intro", play=False, plot=False, speed=1, volume=1, tempo=120, trackfolder="tracks", modelpath="models"): part = part.lower() if part == "intro": pass if part == "outro": pass if part == "bridge": pass if part == "chorus": pass if part == "verse": pass if part == "outro": pass if part == "intro": pass start = datetime.datetime.now() model = loadmodel(genre, insturment, trackfolder=trackfolder, modelpath=modelpath) i = [usePattern(model=model, genre=genre, insturment=insturment) * 1] filename = namethefile(insturment.capitalize() + "-" + genre.capitalize()) mid = listtomidi(i, round((250000 / 120) * tempo * 2), filename, insturment=insturment) mid.save(filename) gen = datetime.datetime.now() - start print("Generated", filename.replace("Generated/", ""), "in", str(gen)) start = datetime.datetime.now() import Play, GenPlot if plot: try: GenPlot.showplotofmidi( filename, "GeneratedPlots/" + filename.replace("mid", "png")) plot = datetime.datetime.now() - start print("Ploted", filename, "in", str(plot)) except: print("Plot failed.") if play: Play.play(filename, speed, volume)
def readmidi(filename, play=False, plot=False, printtracks=False): start = datetime.datetime.now() mid = mido.MidiFile(filename, clip=True) if printtracks: for track in mid.tracks: for message in track: print(message) print("\n\n\n") if play: Play.play(filename, 1, 1) if plot: import GenPlot GenPlot.showplotofmidi( filename, "GeneratedPlots/" + filename.replace("mid", "png").split("/")[-1]) plot = datetime.datetime.now() - start print("Ploted", filename, "in", str(plot))
def main(argv): maxInt = sys.maxsize decrement = True while decrement: # decrease the maxInt value by factor 10 # as long as the OverflowError occurs. decrement = False try: csv.field_size_limit(maxInt) except OverflowError: maxInt = int(maxInt / 10) decrement = True names = [] dir = './plays/' with open('hanochlevin.tsv', encoding="utf8") as fd: rd = csv.DictReader(fd, delimiter="\t", quotechar='"') for row in rd: name = row['play'].replace(' ', '_') + '.html' filename = dir + name if not os.path.exists(os.path.dirname(filename)): try: os.makedirs(os.path.dirname(filename)) except OSError as exc: # Guard against race condition if exc.errno != errno.EEXIST: raise f = open(filename, "w", encoding='utf8') f.write(row['html']) f.close() names.append(name) labels = 'all_labels' edges = 'important' node_colors = 'one_color' metric = 'basic' for arg in argv: o, a = arg.split('=') if o == 'labels': labels = a elif o == 'edges': edges = a elif o == 'node_colors': node_colors = a elif o == 'metric': metric = a names_dealer = NamesDealer.NamesDealer() for name in names: htmp = MyHTMLParsers.MyHtmlParser() dirname = dir + name play = Play.Play(dirname, htmp, names_dealer, labels, edges, node_colors, metric) play.graph() play.draw_graph()
def songGen(model, genre, insturment, play=False, plot=False, speed=1, volume=1, tempo=120): start = datetime.datetime.now() i = usePattern(model, genre, insturment) * 2 # print("Generated Intro") v = usePattern(model, genre, insturment) * 2 # print("Generated Verse") c = usePattern(model, genre, insturment) * 2 # print("Generated Chorus") o = usePattern(model, genre, insturment) * 2 # print("Generated Outro") b = usePattern(model, genre, insturment) * 2 # print("Generated Bridge") structures = [[i, v, c, v, c, o], [i, v, c, v, c, b, v, c, o], [i, v, c, v, c, b, c, v, o], [i, c, v, c, v, b, c, o], [i, v, c, v, b, v, c, b, o]] song_structure = random.choice(structures) songl = [] for structure in song_structure: songl.append(structure) filename = namethefile("Song") mid = listtomidi(songl, round((250000 / 120) * tempo), filename) mid.save(filename) gen = datetime.datetime.now() - start print("Generated", filename.replace("Generated/", ""), "in", str(gen)) start = datetime.datetime.now() import Play, GenPlot if plot: GenPlot.showplotofmidi( filename, "GeneratedPlots/" + filename.replace("mid", "png")) plot = datetime.datetime.now() - start print("Ploted", filename, "in", str(plot)) if play: Play.play(filename, speed, volume)
def click(self, game, player): if player.used == []: # Null play game.repeatTurn() return play = Play.Play(game, player) # Invalid plays if not play.isLegal(game) or (not game.challenge and not play.isValid(game)): game.display.clearMsg() game.display.printMsg("Illegal move") recall(game, player) game.repeatTurn() else: game.display.clearMsg() game.display.printMsg(player.name + " scored " + \ str(play.score) + " points!") game.plays.append(play) player.score += play.score player.newTurn = True player.used = []
def play_game(self): self.puzzle = Puzzle(self.instance) self.state = Play(self.puzzle) self.play = self.state.play()
import Login_and_Logout_and_Add_and_Details if __name__ == "__main__": while 1: print('\n=========WELCOME TO QUIZ ==========') print('-----------------------------------------') print('1. PLAY QUIZ') print("2. CREATE NEW ACCOUNT FOR PLAYER") print("3. CREATE NEW ACCOUNT FOR ADMIN") print("4. LOGIN") print("5. LOGOUT") print("6. ADD A QUESTION") print("7. VIEW ACCOUNT DETAILS") print("8. EXIT") choice = int(input('ENTER YOUR CHOICE: ')) if choice == 1: Play.Play() elif choice == 2: name = input("Enter your name is : ") password = input("Enter your password is : ") Super_User.User(name, password) elif choice == 3: name = input("Enter your name is : ") password = input("Enter your password is : ") Super_User.Super_User(name, password) elif choice == 4: test_name = input("Enter your name is : ") test_password = input("Enter your password is : ") Login_and_Logout_and_Add_and_Details.Login(test_name, test_password) elif choice == 5: Login_and_Logout_and_Add_and_Details.Logout()
import Home import Solve import Levels import Play # default screen is Home screen = 1 while screen <= 4: if screen == 1: screen = Home.main() elif screen == 2: lvl = Levels.main() if lvl == 5: break screen = Play.main(lvl) elif screen == 4: screen = Solve.main()
newmon7 = war.add(te) newmon8 = lost.add(grey) newmon9 = pal.add(sup) newmon10 = grey.add(ku) print() print("GoMon join") print(newmon1) print(newmon2) print(newmon3) print(newmon4) print(newmon5) print(newmon6) print(newmon7) print(newmon8) print(newmon9) print(newmon10) Play.greaterThan(war, lost) # Outputnya : False Play.greaterThan(sup, lada) # Outputnya : True Play.greaterThan(leo, te) # Outputnya : False Play.lowerThan(goma, grey) # Outputnya : False Play.lowerThan(grey, lost) # Outputnya : True Play.lowerThan(lada, war) # Outputnya : True Play.equals(ku, mo) # Outputnya : False Play.equals(pal, sup) # Outputnya : False Play.equals(rai, sup) # Outputnya : True Play.greaterThan(te, war) # Outputnya : False Play.lowerThan(mo, mo) # Outputnya : False Play.greaterThan(lost, leo) # Outputnya : True
def gameScoreboard(): scoreboard = True players = [] #Score.newll.printList() test = Score.newll.printList() while test.isEmpty() is False: players.append(test.pop()) # SCROLL scroll_pos = 0 scroll_limit = (len(players) - 8) * POS_Y_gap + 20 while scoreboard: # UPPER SCROLL LIMIT if scroll_pos > 0: scroll_pos = 0 # LOWER SCROLL LIMIT if scroll_pos < -scroll_limit: if scroll_limit >= 0: scroll_pos = -scroll_limit else: scroll_pos = 0 Misc.gameDisplay.fill(Misc.BLACK) Misc.message_to_screen("SCOREBOARD", Misc.WHITE, scroll_pos + title_POS, "XL") Misc.message_to_screen_uncentered("Player", Misc.WHITE, scroll_pos + name_POS_Y - POS_Y_gap, "M", name_POS_X) Misc.message_to_screen_uncentered("Score", Misc.WHITE, scroll_pos + name_POS_Y - POS_Y_gap, "M", score_POS_X) replay_pox_y = scroll_pos + name_POS_Y for i in range(len(players)): pos_y = replay_pox_y + i * POS_Y_gap # print players[i] #print players[i][0] Misc.message_to_screen_uncentered(players[i][0], Misc.WHITE, pos_y, "S", name_POS_X) Misc.message_to_screen_uncentered(players[i][1], Misc.WHITE, pos_y, "S", score_POS_X) Misc.button("REPLAY", replay_POX_X, pos_y - replay_elevation, replay_size[0], replay_size[1], Misc.GREY, Misc.WHITE, "S") back_pos_y = scroll_pos + name_POS_Y + len(players) * POS_Y_gap Misc.button("BACK", back_POS_X, back_pos_y, back_size[0], back_size[1], Misc.GREY, Misc.WHITE, "S") # INPUT HANDLING for event in pygame.event.get(): if event.type is pygame.QUIT: pygame.quit() quit() # Button Events if event.type is pygame.MOUSEBUTTONDOWN: if event.button is 1: POS_X, POS_Y = pygame.mouse.get_pos() # Back Button if (back_POS_X < POS_X < back_POS_X + back_size[0] and back_pos_y < POS_Y < back_pos_y + back_size[1]): scoreboard = False # Replay Buttons elif (replay_POX_X < POS_X < replay_POX_X + replay_size[0] and replay_pox_y < POS_Y < replay_pox_y - replay_elevation + (len(players)-1) * POS_Y_gap + replay_size[1]): button_pos = POS_Y - (name_POS_Y - replay_elevation) - scroll_pos if button_pos % POS_Y_gap <= replay_size[1]: Play.play_game_seed(players[button_pos / POS_Y_gap][2]) scoreboard = False #print players[button_pos / POS_Y_gap][2] if event.button is 4: scroll_pos -= scroll_speed if event.button is 5: scroll_pos += scroll_speed # # UP and DOWN button scrolling # if pygame.key.get_pressed()[pygame.K_UP]: # scroll_pos -= scroll_speed # if pygame.key.get_pressed()[pygame.K_DOWN]: # scroll_pos += scroll_speed pygame.display.flip() Misc.refresh()
def game_intro(): intro = True while intro is True: for event in pygame.event.get(): if event.type is pygame.QUIT: pygame.quit() quit() if event.type is pygame.MOUSEBUTTONDOWN: if event.button is 1: pos_x, pos_y = pygame.mouse.get_pos() # LOAD BUTTON if (LOAD_BUTTON_POS_X < pos_x < LOAD_BUTTON_POS_X + ButtonLength and LOAD_BUTTON_POS_Y < pos_y < LOAD_BUTTON_POS_Y + ButtonWidth): game_loop = True while game_loop: game_loop = Play.play_game_seed("laststate") # START BUTTON elif (START_BUTTON_POS_X < pos_x < START_BUTTON_POS_X + ButtonLength and START_BUTTON_POS_Y < pos_y < START_BUTTON_POS_X + ButtonWidth): game_loop = True while game_loop: game_loop = Play.play_game(Misc.difficulty, None) elif (SCOREBOARD_BUTTON_POS_X < pos_x < SCOREBOARD_BUTTON_POS_X + ButtonLength and SCOREBOARD_BUTTON_POS_Y < pos_y < SCOREBOARD_BUTTON_POS_Y + ButtonWidth): Scoreboard.gameScoreboard() # DIFFICULTY BUTTON elif (DIFFICULTY_BUTTON_POS_X < pos_x < DIFFICULTY_BUTTON_POS_X + ButtonLength and DIFFICULTY_BUTTON_POS_Y < pos_y < DIFFICULTY_BUTTON_POS_Y + ButtonWidth): Difficulty.gameDifficulty() # EXIT BUTTON elif (EXIT_BUTTON_POS_X < pos_x < EXIT_BUTTON_POS_X + ButtonLength and EXIT_BUTTON_POS_Y < pos_y < EXIT_BUTTON_POS_Y + ButtonWidth): pygame.quit() quit() Misc.gameDisplay.fill(Misc.BLACK) Misc.gameDisplay.blit(Misc.wallpaper, Misc.display_origin) Misc.message_to_screen("MINESWEEPER", Misc.GREY, TITLE_POS, "XXL") Misc.button("START", START_BUTTON_POS_X, START_BUTTON_POS_Y, ButtonLength, ButtonWidth, Misc.GREY, Misc.WHITE, "S") Misc.button("LOAD", LOAD_BUTTON_POS_X, LOAD_BUTTON_POS_Y, ButtonLength, ButtonWidth, Misc.GREY, Misc.WHITE, "S") Misc.button("SCOREBOARD", SCOREBOARD_BUTTON_POS_X, SCOREBOARD_BUTTON_POS_Y, ButtonLength, ButtonWidth, Misc.GREY, Misc.WHITE, "S") Misc.button("DIFFICULTY", DIFFICULTY_BUTTON_POS_X, DIFFICULTY_BUTTON_POS_Y, ButtonLength, ButtonWidth, Misc.GREY, Misc.WHITE, "S") Misc.button("EXIT", EXIT_BUTTON_POS_X, EXIT_BUTTON_POS_Y, ButtonLength, ButtonWidth, Misc.GREY, Misc.WHITE, "S") if Misc.EZ_SENSOR is True: Misc.button("EZ SENSOR ON", 0, Misc.display_height - 20, Misc.display_width, 20, Misc.PINK, Misc.PINK, "S") else: Misc.button("EZ SENSOR OFF", 0, Misc.display_height - 20, Misc.display_width, 20, Misc.GREY, Misc.GREY, "S") Misc.refresh()
def runTest(self): self.assertEqual(Play.get_log5_value(self.batter, self.pitcher, self.league_avg[Play.OBP], Play.OBP, self.pf), 0.33129013565553544, 'Log5OBP are incorrect')
def simPitch(self, pitcherAbil=None, batterAbil=None, pitch=None): if pitcherAbil == None: pitcherAbil = self.__pitcherAbil if batterAbil == None: batterAbil = self.__batterAbil pitchType = None pitchZone = -1 if pitch == None: (pitchType, pitchZone) = self._getNextPitch() else: (pitchType, pitchZone) = pitch swungAtBall = False #r = random.randint(0,100) if pitchZone not in gsSTRIKEZONE:# and r >=20: #the pitch is in the strike zone #TODO: calculate batter pateince to see if he swings at this pitch #if (batter swings) : # => it's a strike prSwingAtBall = PrEng.PrSwingAtBall(self.__batterAbil.getBatterPatience()) r = random.randint(0,99) if r < int(100*prSwingAtBall): #he swung swungAtBall = True #TODO: base on pitchers control decide whether or not he hit the batter # if gsATBATRESULT_HITBYPITCH if swungAtBall: None elif not swungAtBall and self.__pitcherStats.getBalls() == gsMAXBALLCOUNT-1: #TODO: need to check to see if runs score and generate a Play() #print "*** ATBATRESULT: WALK ***" playObj = Play(self.__batterGUID, self.__pitcherGUID, pitchType, pitchZone, 0, self.__pitcherStats.getBalls(), self.__pitcherStats.getStrikes(), gsATBATRESULT_WALK) #earlyResultCode bases = self.__fieldState.getBasesState() runnersAdvancedList = bases.simBaseRunners(gsATBATRESULT_WALK) playObj.setResult(gsATBATRESULT_WALK) playObj.setRunnersAdvanced(runnersAdvancedList) playObj.createPlayEncoding() self.__resultCode = str(playObj) #print playObj self.__pitcherStats.addPitchThrown(pitchType, pitchZone, 0,#walks don't count as at bats gsPITCHCALL_WALK, playObj) #TODO: need to use fieldState to determine who # scored and set appropriately # in the playObj because in the case of a WALK/HBP runs can # score without a ball being in play self.__batterStats.addPitchReceived(pitchType, pitchZone, 0, gsPITCHCALL_WALK, self.__fieldState.numRunnersInScoringPos(), playObj) self.__playObj = playObj #print "WALK" return gsPITCHCALL_WALK else:# not swungAtBall: #this addPitchReceived does nothing for now #because we don't track #individual pitches for batters self.__pitcherStats.addPitchThrown(pitchType, pitchZone, 0, gsPITCHCALL_BALL) self.__batterStats.addPitchReceived(pitchType, pitchZone, 0, gsPITCHCALL_BALL, 0) return gsPITCHCALL_BALL #else: #it's in the strike zone #we always swing this call get the probability that the #batter makes contact if not swungAtBall: pr = PrEng.PrContactNew(pitcherAbil, self.__pitcherSkills, batterAbil, self.__batterSkills, (pitchType, pitchZone)) #using the probability of contact we then #do our monte carlo simulation to determine #if the ball is actually hit r = random.randint(0,999) if r <= (pr * 1000): #f****n' contact! self.__contactMade = True playObj = Play(self.__batterGUID, self.__pitcherGUID, pitchType, pitchZone, 0, self.__pitcherStats.getBalls(), self.__pitcherStats.getStrikes()) self.simBallInPlay(playObj) if playObj.isFoul():#.startswith(gsPITCHCALL_FOUL): self.__contactMade = False self.__pitcherStats.addPitchThrown(pitchType, pitchZone, 0, gsPITCHCALL_FOUL) self.__batterStats.addPitchReceived(pitchType, pitchZone, 0, gsPITCHCALL_FOUL, 0) self.__resultCode = gsNULL_ATBATRESULT_CODE self.__playObj = playObj return gsPITCHCALL_FOUL else: playObj.createPlayEncoding() self.__resultCode = str(playObj) self.__pitcherStats.addPitchThrown(pitchType, pitchZone, 0, None, playObj) self.__batterStats.addPitchReceived(pitchType, pitchZone, 0, None, self.__fieldState.numRunnersInScoringPos(), playObj) self.__playObj = playObj return gsPITCHCALL_CONTACT #else: #he whiff'd! if self.__pitcherStats.getStrikes() == gsMAXSTRIKECOUNT-1: #it's a strikeout playObj = Play(self.__batterGUID, self.__pitcherGUID, pitchType, pitchZone, 0, self.__pitcherStats.getBalls(), self.__pitcherStats.getStrikes(), gsATBATRESULT_STRIKEOUT) #earlyResultCode self.__fieldState.incOuts(1) bases = self.__fieldState.getBasesState() runnersAdvancedList = bases.simBaseRunners(gsATBATRESULT_STRIKEOUT) playObj.setResult(gsATBATRESULT_STRIKEOUT) playObj.setRunnersAdvanced(runnersAdvancedList) playObj.createPlayEncoding() self.__resultCode = str(playObj) self.__pitcherStats.addPitchThrown(pitchType, pitchZone, 0, gsPITCHCALL_STRIKEOUT, playObj) self.__batterStats.addPitchReceived(pitchType, pitchZone, 0, gsPITCHCALL_STRIKEOUT, self.__fieldState.numRunnersInScoringPos(), playObj) self.__playObj = playObj return gsPITCHCALL_STRIKEOUT else: #its just a strike if swungAtBall: #print "SWUNG AT BALL" None self.__pitcherStats.addPitchThrown(pitchType, pitchZone, 0, gsPITCHCALL_STRIKE) self.__batterStats.addPitchReceived(pitchType, pitchZone, 0, gsPITCHCALL_STRIKE, 0) return gsPITCHCALL_STRIKE
import os import time from importlib.machinery import SourceFileLoader import voice_rec import Sintez_Audio as sau import Play as pau spis = os.listdir('/home/anton/PycharmProjects/untitled1/lib') modules = [] for i in spis: modules.append(i) while True: sau.gen('ожидаю запрос') pau.play() x = voice_rec.voice() if x != 'окей': while x != 'окей': x = voice_rec.voice() time.sleep(0.3) sau.gen('слушаю') pau.play() x = voice_rec.voice() for i in range(len(spis)): f = SourceFileLoader(modules[i], "lib/"+modules[i]).load_module() if f.KEYS == x: sau.gen(f.func()) pau.play()
def runTest(self): #print("batter:{} pitcher:{} league_avg:{}".format(self.batter.getWalkHitAvg(), self.pitcher.getWalkHitAvg(), # self.league_avg[Play.WALKS])) self.assertEqual(Play.get_log5_value(self.batter, self.pitcher, self.league_avg[Play.WALKS], Play.WALKS, self.pf), 0.23075164629244718, 'Log5Walks are incorrect')
class InGame(DirectObject): def __init__(self, parent): self.active = False self.paused = True self.parent = parent self.mainFrame = DirectFrame(frameColor=(0,0,0,0), frameSize=(-0.2,0.2,0.4,-0.4 )) self.continueImage = OnscreenImage(image = 'Models/menu/Resume.png', pos = (0,0,0.5), scale = 0.2) self.continueImage.setTransparency(TransparencyAttrib.MMultisampleMask) self.restartImage = OnscreenImage(image = 'Models/menu/Restart.png', pos = (0,0,0), scale = 0.2) self.restartImage.setTransparency(TransparencyAttrib.MMultisampleMask) self.exitImage = OnscreenImage(image = 'Models/menu/Exit.png', pos = (0,0,-0.5), scale = 0.2) self.exitImage.setTransparency(TransparencyAttrib.MMultisampleMask) self.cont = DirectButton(parent = self.mainFrame, pos = (0,0,0.5), scale=.2, frameColor = (0,0,0,0), frameSize = (-1,1,-1,1), command = self.togglePause) self.cont.guiItem.setActive(True) self.cont.bind(DGG.WITHIN, self.mouseOverContinue, [self.cont]) self.cont.bind(DGG.WITHOUT, self.mouseOutContinue, [self.cont]) self.restart = DirectButton(parent = self.mainFrame, pos = (0,0,0), scale=.2, frameColor = (0,0,0,0), frameSize = (-1,1,-1,1), command = self.restart) self.restart.guiItem.setActive(True) self.restart.bind(DGG.WITHIN, self.mouseOverRestart, [self.restart]) self.restart.bind(DGG.WITHOUT, self.mouseOutRestart, [self.restart]) self.exit = DirectButton(parent = self.mainFrame, pos = (0,0,-0.5), scale=.2, frameColor = (0,0,0,0), frameSize = (-1,1,-1,1), command = parent.exit) self.exit.guiItem.setActive(True) self.exit.bind(DGG.WITHIN, self.mouseOverExit, [self.exit]) self.exit.bind(DGG.WITHOUT, self.mouseOutExit, [self.exit]) #self.firstTransition = Transitions(loader) #self.firstTransition.setFadeColor(0,0,0) self.continueImage.hide() self.restartImage.hide() self.exitImage.hide() self.deactivate() #Change text color on mouseover def mouseOverContinue(self, frame, mousePos): self.continueImage.setImage('Models/menu/Resume2.png') self.continueImage.setTransparency(TransparencyAttrib.MMultisampleMask) def mouseOutContinue(self, frame, mousePos): if self.paused: self.continueImage.setImage('Models/menu/Resume.png') self.continueImage.setTransparency(TransparencyAttrib.MMultisampleMask) def mouseOverRestart(self, frame, mousePos): self.restartImage.setImage('Models/menu/Restart2.png') self.restartImage.setTransparency(TransparencyAttrib.MMultisampleMask) def mouseOutRestart(self, frame, mousePos): if self.paused: self.restartImage.setImage('Models/menu/Restart.png') self.restartImage.setTransparency(TransparencyAttrib.MMultisampleMask) def mouseOverExit(self, frame, mousePos): self.exitImage.setImage('Models/menu/Exit2.png') self.exitImage.setTransparency(TransparencyAttrib.MMultisampleMask) def mouseOutExit(self, frame, mousePos): if self.paused: self.exitImage.setImage('Models/menu/Exit.png') self.exitImage.setTransparency(TransparencyAttrib.MMultisampleMask) def activate(self): #self.firstTransition.fadeOut(3) self.active = True self.paused = False self.play = Play(self) #self.firstTransition.fadeOut(3) def deactivate(self): self.mainFrame.hide() self.active = False self.paused = True def togglePause(self): self.continueImage.setImage('Models/menu/Resume.png') self.continueImage.setTransparency(TransparencyAttrib.MMultisampleMask) self.restartImage.setImage('Models/menu/Restart.png') self.restartImage.setTransparency(TransparencyAttrib.MMultisampleMask) self.play.togglePause() def restart(self): self.restartImage.setImage('Models/menu/Restart.png') self.restartImage.setTransparency(TransparencyAttrib.MMultisampleMask) self.togglePause() self.play.player.die(self.play.level) def __del__(self): self.cont.destroy() self.exit.destroy() self.mainFrame.destroy()
def tournament(self): bg = pygame.image.load("img/white.png") self.screen.blit(bg, [0, 0]) background_for_result = pygame.image.load( "img/Tournament_start_screen.jpg") self.screen.blit(background_for_result, [0, 0]) font = pygame.font.Font('Base05.ttf', 20) black = (255, 204, 51) back_table = pygame.image.load("img/Left_sign.png") back_table = pygame.transform.scale(back_table, (200, 50)) table_for_number_of_players = pygame.image.load("img/Right_sign.png") table_for_number_of_players = pygame.transform.scale( table_for_number_of_players, (200, 50)) self.screen.blit(back_table, [0, 535]) # dole levo back_text = font.render('HOME', True, black) backRect = back_text.get_rect() backRect.center = (95, 560) self._display_surf.blit(back_text, backRect) self.screen.blit(table_for_number_of_players, [300, 465]) # 8 igraca tabla self.screen.blit(table_for_number_of_players, [300, 400]) # 7 igraca tabla self.screen.blit(table_for_number_of_players, [300, 335]) # 6 igraca tabla self.screen.blit(table_for_number_of_players, [300, 270]) # 5 igraca tabla self.screen.blit(table_for_number_of_players, [300, 205]) # 4 igraca tabla four_players_text = font.render('4 PLAYERS', True, black) four_players_rect = four_players_text.get_rect() four_players_rect.center = (400, 230) five_players_text = font.render('5 PLAYERS', True, black) five_players_rect = five_players_text.get_rect() five_players_rect.center = (400, 295) six_players_text = font.render('6 PLAYERS', True, black) six_players_rect = six_players_text.get_rect() six_players_rect.center = (400, 360) seven_players_text = font.render('7 PLAYERS', True, black) seven_players_rect = seven_players_text.get_rect() seven_players_rect.center = (400, 425) eight_players_text = font.render('8 PLAYERS', True, black) eight_players_rect = eight_players_text.get_rect() eight_players_rect.center = (400, 490) self._display_surf.blit(four_players_text, four_players_rect) self._display_surf.blit(five_players_text, five_players_rect) self._display_surf.blit(six_players_text, six_players_rect) self._display_surf.blit(seven_players_text, seven_players_rect) self._display_surf.blit(eight_players_text, eight_players_rect) pygame.display.update() wait = True while wait: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.time.delay(500) self.start_menu() return if event.type == pygame.MOUSEBUTTONDOWN: mouse_pos = event.pos if 322 < mouse_pos[0] < 490 and 205 < mouse_pos[ 1] < 255: #za 4 igraca print('4 igraca') play = Play(4, self.screen, self.clock, gameTerrain) process = mp.Process( target=play.initialize_tournament()) process.start() process.join() pygame.mouse.set_visible(True) pygame.mixer.music.play(-1) self.start_menu() return if 322 < mouse_pos[0] < 490 and 270 < mouse_pos[ 1] < 320: #za 5 igraca print('5 igraca') play = Play(5, self.screen, self.clock, gameTerrain) process = mp.Process( target=play.initialize_tournament()) process.start() process.join() pygame.mouse.set_visible(True) pygame.mixer.music.play(-1) self.start_menu() return if 322 < mouse_pos[0] < 490 and 335 < mouse_pos[ 1] < 385: #za 6 igraca print('6 igraca') play = Play(6, self.screen, self.clock, gameTerrain) process = mp.Process( target=play.initialize_tournament()) process.start() process.join() pygame.mouse.set_visible(True) pygame.mixer.music.play(-1) self.start_menu() return if 322 < mouse_pos[0] < 490 and 400 < mouse_pos[ 1] < 450: #za 7 igraca print('7 igraca') play = Play(7, self.screen, self.clock, gameTerrain) process = mp.Process( target=play.initialize_tournament()) process.start() process.join() pygame.mouse.set_visible(True) pygame.mixer.music.play(-1) self.start_menu() return if 322 < mouse_pos[0] < 490 and 465 < mouse_pos[ 1] < 515: #za 8 igraca print('8 igraca') play = Play(8, self.screen, self.clock, gameTerrain) process = mp.Process( target=play.initialize_tournament()) process.start() process.join() pygame.mouse.set_visible(True) pygame.mixer.music.play(-1) self.start_menu() return if 30 < mouse_pos[0] < 180 and 535 < mouse_pos[ 1] < 585: # za HOME pygame.mouse.set_visible(True) pygame.mixer.music.play(-1) pygame.time.delay(500) self.start_menu() return
def Get_Team_Game_Stats(data): games = [] game_num = 0 # First seperate data into seperate games i = 1 while i < len(data): game = [] game.append(data[i]) i += 1 play_num = 0 while data[i][CONST.CODE] == game[play_num][CONST.CODE]: game.append(data[i]) i += 1 play_num += 1 if i >= len(data): break games.append(game) game_num += 1 # Now compile data for each game team_game_stats = [] team_game_stats_print = [] team_game_stats_print.append(Team_Game_Stats_Header()) for i in range(0, len(games)): game_stats_1 = Team_Game_Stat(games[i][0][CONST.CODE], games[i][0][CONST.OFF]) game_stats_2 = Team_Game_Stat(games[i][0][CONST.CODE], games[i][0][CONST.DEF]) for j in range(0, len(games[i])): play = Play(games[i][j]) # Get next play if j + 1 < len(games[i]): next_play = Play(games[i][j + 1]) else: next_play = Play([0] * len(games[i])) # Get rushing information play.Sack_Occurred() play.Fumble_Check(next_play) if "Rush" == play.data[CONST.TYPE] or ("Pass" == play.data[CONST.TYPE] and play.Sack == 1): play.Rush_Att = 1 try: play.Rush_Yard = play.data[CONST.Y_DESC] except: play.Rush_Yard = play.data[CONST.Y_DESC] play.Rushing_Touchdown_Occurred() # Get passing information if "Pass" == play.data[CONST.TYPE] and not ("Pass" == play.data[CONST.TYPE] and play.Sack == 1): play.Pass_Att = 1 play.Completion(next_play) play.Interception() play.Passing_Touchdown_Occurred() try: play.Pass_Yard = play.data[CONST.Y_DESC] except: play.Pass_Yard = play.data[CONST.Y_DESC] # Get kickoff information if "Kickoff" == play.data[CONST.TYPE]: play.Kickoff_Ret = 1 play.Kickoff = 1 if "Touchdown" == play.data[CONST.REST]: play.Kickoff_Ret_TD = 1 if None != re.search("touchback", play.data[CONST.P_REST], re.IGNORECASE): play.Kickoff_Touchback = 1 play.Kickoff_Ret = 0 # Points information play.Points = play.data[CONST.O_PT] # Get punt information if "Punt" == play.data[CONST.TYPE]: play.Punt = 1 play.Punt_Ret = 1 if "Touchdown" == play.data[CONST.REST]: play.Punt_Ret_TD = 1 if None != re.search("block", play.data[CONST.P_REST], re.IGNORECASE): play.Kick_Punt_Blocked = 1 elif "Blocked" == play.data[CONST.REST]: play.Kick_Punt_Blocked = 1 # Get field goal information if "Field.Goal" == play.data[CONST.TYPE]: play.Field_Goal_Att = 1 if "Made.FG" == play.data[CONST.REST]: play.Field_Goal_Made = 1 elif "Blocked" == play.data[CONST.REST]: play.Kick_Punt_Blocked = 1 if "Touchdown" == play.data[CONST.REST]: if None != re.search("block", play.data[CONST.P_REST], re.IGNORECASE): play.Kick_Punt_Blocked = 1 # Get XP information if "Extra.Point" == play.data[CONST.TYPE]: play.Off_XP_Kick_Att = 1 if None != re.search("made", play.data[CONST.P_REST], re.IGNORECASE): play.Off_XP_Kick_Made = 1 if "Blocked" == play.data[CONST.REST]: play.Kick_Punt_Blocked = 1 # Get two point conversion information if "Two.Point.Attempt" == play.data[CONST.TYPE]: play.Off_2XP_Att = 1 play.Def_2XP_Att = 1 play.Two_Pt_Conv_Successful(next_play) # Check for a safety play.Safety_Occurred(next_play) # Get tackles for loss data if "Rush" == play.data[CONST.TYPE] or "Pass" == play.data[CONST.TYPE]: if None != re.search("loss", play.data[CONST.P_REST], re.IGNORECASE): play.Tackle_For_Loss = 1 try: play.Tackle_For_Loss_Yard = play.data[CONST.Y_SPOT] except: play.Tackle_For_Loss_Yard = play.data[CONST.Y_DESC] # Get penalty information if "Penalty" == play.data[CONST.TYPE]: play.Penalty = 1 try: play.Penalty_Yard = play.data[CONST.Y_SPOT] except: play.Penalty_Yard = play.data[CONST.Y_DESC] # Get first down information play.First_Down(next_play) if 3 == play.data[CONST.DOWN] and (play.Rush_Att == 1 or play.Pass_Att == 1): play.Third_Down_Att = 1 if play.First_Down_Rush == 1 or play.First_Down_Pass == 1: play.Third_Down_Conv = 1 elif 4 == play.data[CONST.DOWN] and (play.Rush_Att == 1 or play.Pass_Att == 1): play.Fourth_Down_Att = 1 if play.First_Down_Rush == 1 or play.First_Down_Pass == 1: play.Fourth_Down_Conv = 1 # Get time of possession information if play.data[CONST.CLK] < 900 and next_play.data[CONST.CLK] < 900: # normal play.Time_Of_Possession = play.data[CONST.CLK] - next_play.data[CONST.CLK] elif ( next_play.data[CONST.CLK] == 900 and play.data[CONST.CODE] == next_play.data[CONST.CODE] ): # end of quarter play.Time_Of_Possession = play.data[CONST.CLK] elif play.data[CONST.CODE] != next_play.data[CONST.CODE]: # end of game play.Time_Of_Possession = play.data[CONST.CLK] # Get red zone information if (play.Pass_TD == 1 or play.Rush_TD == 1) and play.data[CONST.SPOT] <= 20: play.Red_Zone_TD = 1 elif play.Field_Goal_Made == 1 and play.data[CONST.SPOT] <= 20: play.Red_Zone_Field_Goal = 1 # Add play stats to team-game-stats if int(game_stats_1.Team_Code) == int(play.data[CONST.OFF]): game_stats_1.Add_Off_Stats(play) game_stats_2.Add_Def_Stats(play) elif int(game_stats_2.Team_Code) == int(play.data[CONST.OFF]): game_stats_2.Add_Off_Stats(play) game_stats_1.Add_Def_Stats(play) # Add this game to the array team_game_stats.append(game_stats_1) team_game_stats.append(game_stats_2) team_game_stats_print.append(game_stats_1.Compile_Stats()) team_game_stats_print.append(game_stats_2.Compile_Stats()) return (team_game_stats, team_game_stats_print)
def Get_Team_Game_Stats(data): games = [] game_num = 0 # First seperate data into seperate games i = 1 while i < len(data): game = [] game.append(data[i]) i += 1 play_num = 0 while data[i][CONST.CODE] == game[play_num][CONST.CODE]: game.append(data[i]) i += 1 play_num += 1 if i >= len(data): break games.append(game) game_num += 1 # Now compile data for each game team_game_stats = [] team_game_stats_print = [] team_game_stats_print.append(Team_Game_Stats_Header()) for i in range(0, len(games)): game_stats_1 = Team_Game_Stat(games[i][0][CONST.CODE], games[i][0][CONST.OFF]) game_stats_2 = Team_Game_Stat(games[i][0][CONST.CODE], games[i][0][CONST.DEF]) for j in range(0, len(games[i])): play = Play(games[i][j]) # Get next play if j + 1 < len(games[i]): next_play = Play(games[i][j + 1]) else: next_play = Play([0] * len(games[i])) # Get rushing information play.Sack_Occurred() play.Fumble_Check(next_play) if "Rush" == play.data[CONST.TYPE] or ( "Pass" == play.data[CONST.TYPE] and play.Sack == 1): play.Rush_Att = 1 try: play.Rush_Yard = play.data[CONST.Y_DESC] except: play.Rush_Yard = play.data[CONST.Y_DESC] play.Rushing_Touchdown_Occurred() # Get passing information if "Pass" == play.data[CONST.TYPE] and not ( "Pass" == play.data[CONST.TYPE] and play.Sack == 1): play.Pass_Att = 1 play.Completion(next_play) play.Interception() play.Passing_Touchdown_Occurred() try: play.Pass_Yard = play.data[CONST.Y_DESC] except: play.Pass_Yard = play.data[CONST.Y_DESC] # Get kickoff information if "Kickoff" == play.data[CONST.TYPE]: play.Kickoff_Ret = 1 play.Kickoff = 1 if "Touchdown" == play.data[CONST.REST]: play.Kickoff_Ret_TD = 1 if None != re.search("touchback", play.data[CONST.P_REST], re.IGNORECASE): play.Kickoff_Touchback = 1 play.Kickoff_Ret = 0 # Points information play.Points = play.data[CONST.O_PT] # Get punt information if "Punt" == play.data[CONST.TYPE]: play.Punt = 1 play.Punt_Ret = 1 if "Touchdown" == play.data[CONST.REST]: play.Punt_Ret_TD = 1 if None != re.search("block", play.data[CONST.P_REST], re.IGNORECASE): play.Kick_Punt_Blocked = 1 elif "Blocked" == play.data[CONST.REST]: play.Kick_Punt_Blocked = 1 # Get field goal information if "Field.Goal" == play.data[CONST.TYPE]: play.Field_Goal_Att = 1 if "Made.FG" == play.data[CONST.REST]: play.Field_Goal_Made = 1 elif "Blocked" == play.data[CONST.REST]: play.Kick_Punt_Blocked = 1 if "Touchdown" == play.data[CONST.REST]: if None != re.search("block", play.data[CONST.P_REST], re.IGNORECASE): play.Kick_Punt_Blocked = 1 # Get XP information if "Extra.Point" == play.data[CONST.TYPE]: play.Off_XP_Kick_Att = 1 if None != re.search("made", play.data[CONST.P_REST], re.IGNORECASE): play.Off_XP_Kick_Made = 1 if "Blocked" == play.data[CONST.REST]: play.Kick_Punt_Blocked = 1 # Get two point conversion information if "Two.Point.Attempt" == play.data[CONST.TYPE]: play.Off_2XP_Att = 1 play.Def_2XP_Att = 1 play.Two_Pt_Conv_Successful(next_play) # Check for a safety play.Safety_Occurred(next_play) # Get tackles for loss data if "Rush" == play.data[CONST.TYPE] or "Pass" == play.data[ CONST.TYPE]: if None != re.search("loss", play.data[CONST.P_REST], re.IGNORECASE): play.Tackle_For_Loss = 1 try: play.Tackle_For_Loss_Yard = play.data[CONST.Y_SPOT] except: play.Tackle_For_Loss_Yard = play.data[CONST.Y_DESC] # Get penalty information if "Penalty" == play.data[CONST.TYPE]: play.Penalty = 1 try: play.Penalty_Yard = play.data[CONST.Y_SPOT] except: play.Penalty_Yard = play.data[CONST.Y_DESC] # Get first down information play.First_Down(next_play) if 3 == play.data[CONST.DOWN] and (play.Rush_Att == 1 or play.Pass_Att == 1): play.Third_Down_Att = 1 if play.First_Down_Rush == 1 or play.First_Down_Pass == 1: play.Third_Down_Conv = 1 elif 4 == play.data[CONST.DOWN] and (play.Rush_Att == 1 or play.Pass_Att == 1): play.Fourth_Down_Att = 1 if play.First_Down_Rush == 1 or play.First_Down_Pass == 1: play.Fourth_Down_Conv = 1 # Get time of possession information if play.data[CONST.CLK] < 900 and next_play.data[ CONST.CLK] < 900: # normal play.Time_Of_Possession = play.data[ CONST.CLK] - next_play.data[CONST.CLK] elif next_play.data[CONST.CLK] == 900 and play.data[ CONST.CODE] == next_play.data[ CONST.CODE]: # end of quarter play.Time_Of_Possession = play.data[CONST.CLK] elif play.data[CONST.CODE] != next_play.data[ CONST.CODE]: # end of game play.Time_Of_Possession = play.data[CONST.CLK] # Get red zone information if (play.Pass_TD == 1 or play.Rush_TD == 1) and play.data[CONST.SPOT] <= 20: play.Red_Zone_TD = 1 elif play.Field_Goal_Made == 1 and play.data[CONST.SPOT] <= 20: play.Red_Zone_Field_Goal = 1 # Add play stats to team-game-stats if int(game_stats_1.Team_Code) == int(play.data[CONST.OFF]): game_stats_1.Add_Off_Stats(play) game_stats_2.Add_Def_Stats(play) elif int(game_stats_2.Team_Code) == int(play.data[CONST.OFF]): game_stats_2.Add_Off_Stats(play) game_stats_1.Add_Def_Stats(play) # Add this game to the array team_game_stats.append(game_stats_1) team_game_stats.append(game_stats_2) team_game_stats_print.append(game_stats_1.Compile_Stats()) team_game_stats_print.append(game_stats_2.Compile_Stats()) return (team_game_stats, team_game_stats_print)
i = 'hello' counter = 0 # Create Deck deck = Setup.createshuffleddeck() Setup.deal(p1, p2, deck) # Turn card over discard.insert(0, deck[0]) deck.remove(deck[0]) # who goes first turn = random.randint(1, 2) # Create players name1 = V1.Pendejo(True, p1, discard, deck) name2 = V1.Pendejo(True, p2, discard, deck) # while loop to run through the game play while counter != 3: if turn == 1: Play.turn(name1, p1, deck, discard) turn = 0 else: Play.turn(name2, p2, deck, discard) turn = 1 if counter == 0: break elif Play.knock() is False: counter = 0
class MainWindow: def __init__(self, taquin, instance): self.instance = instance self.taquin = taquin self.solved_in = float( timeit.timeit(lambda: self.play_game(), number=1)) self.solved_in = round(self.solved_in, 6) self.main_win = QMainWindow() self.ui = UiForm() self.ui.setup_ui(self.main_win, self.states[0]) self.main_win.setStyleSheet("background-color: rgb(66, 81, 80)") self.main_win.setFixedSize(self.main_win.width(), self.main_win.height()) self.blocks = self.ui.buttons self.utility = Utility() self.ui.label.setText(" Solved in : " + str(self.solved_in) + " s" '\n' + " Expanded states : " + str(self.expansed) + '\n' + " Number of moves : " + str(self.moves - 1)) # self.node = [] # for i, node in enumerate(self.play[0]): # if i == 0: # continue # self.node.append(node) self.ui.start_button.clicked.connect(lambda: self.on_button_click()) self.ui.shuffle.clicked.connect(lambda: self.on_shuffle_click()) def play_game(self): self.puzzle = Puzzle(self.instance) self.state = Play(self.puzzle) self.play = self.state.play() def show(self): self.main_win.update() self.main_win.show() def on_button_click(self): self.move() def move(self): if self.indices2: the_action = self.indices2[0] from_ = the_action[0] where_it_moved = the_action[1] get_button = self.utility.function(from_, self.blocks) get_blank_button = self.utility.function(-1, self.blocks) x_neighbor = get_button.x() y_neighbor = get_button.y() self.anim = QPropertyAnimation(get_button, b"geometry") self.anim.setDuration(100) self.anim.setStartValue( QRect(get_button.x(), get_button.y(), 77, 77)) self.anim.setEndValue( QRect(get_blank_button.x(), get_blank_button.y(), 77, 77)) self.anim.start() self.anim2 = QPropertyAnimation(get_blank_button, b"geometry") self.anim2.setStartValue( QRect(get_blank_button.x(), get_blank_button.y(), 77, 77)) self.anim2.setEndValue(QRect(x_neighbor, y_neighbor, 77, 77)) self.anim2.start() self.blocks = self.utility.permute_buttons(get_blank_button, get_button, self.blocks) self.ui.label.setText(" Solved in : " + str(self.solved_in) + " s" '\n' + " Expanded states : " + str(self.expansed) + '\n' + " " + where_it_moved + '\n' + " Number of moves : " + str(len(self.indices2) - 1)) # print(str(from_) + str(self.node[0].action)) # print(self.node[0].current_state.print_state()) self.indices2.pop(0) def on_shuffle_click(self): num_blocks = 4 taquin = SolutionTaquin(num_blocks) taquin.frontiere = SortedDict() taquin.explorer = {} taquin.initialiser(7, num_blocks) # app = QApplication(sys.argv) main_window = MainWindow(taquin, taquin.creerInstanceAleatoire(num_blocks)) main_window.show() self.main_win.close()
def runTest(self): self.assertEqual(Play.get_log5_value(self.batter, self.pitcher, self.league_avg[Play.SINGLES], Play.SINGLES, self.pf), 0.19614446131634222, 'Log5Singles are incorrect')
#coding:utf-8 import wave from numpy import * from pylab import * import Play wf = wave.open("output.wav", 'r') Play.printWaveInfo(wf) buffer = wf.readframes(wf.getnframes()) print len(buffer) data = frombuffer(buffer, dtype="int16") plot(data) show()
def activate(self): #self.firstTransition.fadeOut(3) self.active = True self.paused = False self.play = Play(self)
def two_players_online(self): bg = pygame.image.load("img/white.png") self.screen.blit(bg, [0, 0]) background_for_result = pygame.image.load( "img/Online_start_screen2.jpg") self.screen.blit(background_for_result, [0, 0]) font = pygame.font.Font('Base05.ttf', 20) black = (255, 204, 51) back_table = pygame.image.load("img/Left_sign.png") back_table = pygame.transform.scale(back_table, (200, 50)) table_for_connect = pygame.image.load("img/Right_sign.png") table_for_connect = pygame.transform.scale(table_for_connect, (200, 50)) self.screen.blit(back_table, [0, 535]) # dole levo back_text = font.render('HOME', True, black) backRect = back_text.get_rect() backRect.center = (95, 560) self._display_surf.blit(back_text, backRect) self.screen.blit(table_for_connect, [325, 335]) #bilo 300 i 335 connect_text = font.render('CONNECT', True, black) connect_text_rect = connect_text.get_rect() connect_text_rect.center = (425, 360) #bilo 400 i 360 self._display_surf.blit(connect_text, connect_text_rect) pygame.display.update() wait = True while wait: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.time.delay(500) self.start_menu() return if event.type == pygame.MOUSEBUTTONDOWN: mouse_pos = event.pos #bilo 322 i 490 if 347 < mouse_pos[0] < 505 and 335 < mouse_pos[ 1] < 385: # za click na connect #print('Connect') play = Play(9, self.screen, self.clock, gameTerrain) play.establish_a_connection() #process = mp.Process(target=play.establish_a_connection()) #process.start() #process.join() pygame.mouse.set_visible(True) pygame.mixer.music.play(-1) self.start_menu() return if 30 < mouse_pos[0] < 180 and 535 < mouse_pos[ 1] < 585: # za HOME pygame.mouse.set_visible(True) pygame.mixer.music.play(-1) pygame.time.delay(500) self.start_menu() return
import numpy as np data = [] player = {} player[Cards.Cards.SILVER] = 0.4 player[Cards.Cards.GOLD] = 0.6 player[Cards.Cards.PROVINCE] = 0.7 xmax = 0.8 ymax = 0.8 init_state = State.State(1, 1, 0, [Cards.Cards.COPPER, Cards.Cards.COPPER, Cards.Cards.COPPER, Cards.Cards.ESTATE, Cards.Cards.ESTATE], [], [Cards.Cards.COPPER, Cards.Cards.COPPER, Cards.Cards.COPPER, Cards.Cards.COPPER, Cards.Cards.ESTATE]) for x in np.arange(0.1,xmax, 0.2): for y in np.arange(0.1,ymax, 0.2): player[Cards.Cards.MARKET] = x player[Cards.Cards.VILLAGE] = y print [x,y] for _ in range(20): init_state = Play.play_turn(init_state, player) data.append([player[Cards.Cards.MARKET], player[Cards.Cards.VILLAGE], Play.victory_points(init_state)]) Plot.plot(data, xmax, ymax)
def runTest(self): self.assertEqual(Play.get_log5_value(self.batter, self.pitcher, self.league_avg[Play.TRIPLES], Play.TRIPLES, self.pf), 0.20240232840980726, 'Log5Triples are incorrect')
def runTest(self): self.assertEqual(Play.get_log5_value(self.batter, self.pitcher, self.league_avg[Play.DOUBLES], Play.DOUBLES, self.pf), 0.23889256036096038, 'Log5Doubles are incorrect')
def runTest(self): self.assertEqual(Play.get_log5_value(self.batter, self.pitcher, self.league_avg[Play.HOMERUNS], Play.HOMERUNS, self.pf), 0.3521627251589127, 'Log5Homeruns are incorrect')