def run(config_path): print("Do you want to play FlappyBirds (0) or watch an AI (1) ? ", end='') answer = input() print(answer) while (answer.strip() != "0" and answer != "1"): print("Please select a 0 (play) or 1 (watch): ", end='') answer = input() if answer.strip() == "1": config = neat.config.Config(neat.DefaultGenome, neat.DefaultReproduction, neat.DefaultSpeciesSet, neat.DefaultStagnation, config_path) p = neat.Population(config) p.add_reporter(neat.StdOutReporter(True)) stats = neat.StatisticsReporter() p.add_reporter(stats) winner = p.run(genome_evaluation, 50) else: play()
def firm_name(event): new_name = self.entry.get() new_name = proper_name(new_name) self.player_name = new_name self.TKplayer_name.set(self.player_name) self.entry.delete(0,tk.END) self.TKresponse.set('What do you want to do?') play(self)
def __init__(self): self.TKplayer_name = tk.StringVar() self.TKturn = tk.IntVar() self.TKcity = tk.StringVar() self.TKhealth = tk.IntVar() self.TKmoney = tk.IntVar() self.TKcapacity = tk.IntVar() self.TKgold = tk.IntVar() self.TKsilk = tk.IntVar() self.TKgeneral = tk.IntVar() self.TKarms = tk.IntVar() self.TKMgold = tk.IntVar() self.TKMsilk = tk.IntVar() self.TKMgeneral = tk.IntVar() self.TKMarms = tk.IntVar() self.TKresponse = tk.StringVar() self.TKresponse.set("Welcome") self.TKgold.set(self.boat['gold']) self.TKsilk.set(self.boat['silk']) self.TKgeneral.set(self.boat['general']) self.TKarms.set(self.boat['arms']) tkfield(aFrame,self.TKhealth,0,self.boat['health'],1) tkfield(aFrame,self.TKmoney,1,self.boat['money'],1) tkfield(aFrame,self.TKcapacity,2,self.boat['capacity'],1) tkfield(aFrame,self.TKgold,3,self.boat['gold'],1) tkfield(aFrame,self.TKsilk,4,self.boat['silk'],1) tkfield(aFrame,self.TKarms,5,self.boat['arms'],1) tkfield(aFrame,self.TKgeneral,6,self.boat['general'],1) tkfield(bFrame,self.TKMgold,0,0,1) tkfield(bFrame,self.TKMsilk,1,0,1) tkfield(bFrame,self.TKMarms,2,0,1) tkfield(bFrame,self.TKMgeneral,3,0,1) tkfield(cFrame,self.TKresponse, 0, self.TKresponse,1) self.user = tk.StringVar() self.entry = tk.Entry(dFrame, textvariable=self.user, font = font1, bg = "#e8eaeb", fg = "#404040") tkfield(nameFrame,self.TKplayer_name,0,self.player_name,2) tkfield(turnFrame,self.TKturn,0,self.turn,2) tkfield(cityFrame,self.TKcity,0,self.cities[self.boat['city']],2) # canvas.create_text(650, 98, textvariable=self.TKcity, fill = "#ffdb00", font = font2) rc = play(self) while rc: rc = play(self)
def makeboard(): pygame.init() d_surf = pygame.display.set_mode((800, 800)) vis = DraughtVisualiser(800, 6) vis.draw_board() d_surf.blit(vis.my_surf, (0, 0)) pygame.display.set_caption("Test!") vis.draw_from_grid(game.board) pygame.display.update() MOVETHISPIECE = 0 while True: # main game loop for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() if event.type == pygame.MOUSEBUTTONUP: pos = pygame.mouse.get_pos() square = find_square((0, 0), pos, 800 / 6) MOVETHISPIECE = square if event.type == pygame.KEYDOWN: key_name = pygame.key.name(event.key) if key_name == 'w': play(MOVETHISPIECE[0], MOVETHISPIECE[1], 0) if key_name == 'a': play(MOVETHISPIECE[0], MOVETHISPIECE[1], 1) if key_name == 's': play(MOVETHISPIECE[0], MOVETHISPIECE[1], 2) if key_name == 'd': play(MOVETHISPIECE[0], MOVETHISPIECE[1], 3) vis.draw_from_grid(game.board) colour = pygame.Color("chocolate1") d_surf.blit(vis.my_surf, (0, 0)) pygame.display.update()
def flow(self,conn): # s = send.client_connect() # while 1: # record.record(self.username) # send.send(s, self.username) # for i in self.userlist: # if self.username != i: # send.recv(s) # t = threading.Thread(target=play.play,args=i) # t.start() while 1: record.record(self.username) send.send(conn, self.username) opp = send.recv(conn) play(opp)
def stations_play(station_id): import xbmc current_track_id = plugin.request.args.get('current_track_id', [None])[0] if current_track_id is None: xbmc.PlayList(xbmc.PLAYLIST_MUSIC).clear() current_track_id = rhapsody.stations.tracks(station_id).tracks[0].id current_track = rhapsody.tracks.detail(current_track_id) current_item = helpers.get_track_item(current_track) plugin.add_to_playlist([current_item], playlist='music') return play(track_id=current_track_id, station_id=station_id)
def main(): """Main flux of the game. """ print('¡Bienvenido al Reversi!') sleep(1) board = create_and_initialize_board() if check_boardsize(): board = play(board) declare_winner(board) else: print('El tamaño del tablero debe ser par')
import play if __name__ == "__main__": play()
import numpy as np import play from play import game, play game.reset() game.board #game.board=np.array([[0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,1,0,0,0],[0,0,0,-1,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0]]) #game.board play(3, 3, 0) play(4, 0, 1) play(1, 1, 2) play(4, 2, 1) play(2, 2, 3) play(5, 1, 1) play(4, 0, 2) play(4, 4, 1) play(5, 1, 0) play(3, 3, 1) play(1, 5, 3) play(3, 3, 3) play(5, 3, 0) play(5, 1, 1) play(5, 5, 0) play(3, 3, 3) play(3, 5, 0) play(1, 3, 2) play(3, 5, 3)
import cv2 from play import * from GUI import * from facerect import * if __name__ == '__main__': video = cv2.VideoCapture(u"video.mp4") play(video_facerect(video)) #MyPaintApp().run()
def start_menu(screen): """ écran principal, menu principal du joueur """ # On met de la musikquent pygame.mixer.music.load(os.path.join("data", "halloween.mp3")) pygame.mixer.music.play(-1) # Loop = infinie pygame.mixer.music.set_volume(0.5) # On réduit le volume # On vérifie le dictionnaire if os.path.exists(os.path.join("data", "dictionary.txt")): dictionary = os.path.join("data", "dictionary.txt") else: pygame.quit() sys.exit('No default dictionnary in data, please add one') # Difficulté : nbr_coup = 15 # Si os path marche pas ben... y'avait qu'a pas delete les fichiers pour rien # os.path.join est cross plateforme (pour les séparations) font = pygame.font.Font(os.path.join("data", "True_Lies.TTF"), 50) # On ajoute notre propre police d'écriture image = pygame.image.load(os.path.join("data", "select.png")) # Curseur cursor = pygame.transform.scale(image, (50, 50)) # On le resize pos = 0 # Position du curseur # On définit les options option0 = font.render("1 PLAYER", True, (255, 255, 255)) option1 = font.render("2 PLAYER", True, (255, 255, 255)) option2 = font.render("IMPORT DICT", True, (255, 255, 255)) option3 = font.render("DIFFICULTY", True, (255, 255, 255)) option4 = font.render("QUIT", True, (255, 255, 255)) # Le petit background bg = pygame.image.load(os.path.join("data", "background.jpg")) # Boucle infinie while 1: # On affiche tout screen.blit(bg, (0, 0)) screen.blit(option0, (150, 10)) screen.blit(option1, (150, 110)) screen.blit(option2, (150, 210)) screen.blit(option3, (150, 310)) screen.blit(option4, (150, 410)) screen.blit(cursor, (80, pos * 100 + 10)) for e in pygame.event.get(): if e.type == QUIT: # Si il ferme la fenêtre on quitte tout pygame.quit() sys.exit("Quitting...") elif e.type == KEYDOWN: # Si il appuie sur une touche if e.key == K_DOWN: # Flèche du bas pos += 1 if pos > 4: pos = 0 # Si TROP haut, on redescend :D elif e.key == K_UP: # Flèche du haut pos -= 1 if pos < 0: pos = 4 # Si TROP bas, on remonte (suspense) elif e.key == K_RETURN: if pos == 0: # 1 PLAYER play(screen, dictionary, nbr_coup) # On lance le jeu! elif pos == 1: # 2 PLAYERS play(screen, dictionary, nbr_coup, True) elif pos == 2: # Si "IMPORT DICT" # On utilise le gestionnaire de fichier Tkinter root = Tk() root.update() dictionary = askopenfilename( title="Ouvrir votre dictionnaire perso", filetypes=[('txt files', '.txt'), ('all files', '.*')]) root.destroy() elif pos == 3: # DIFFICULTY nbr_coup = difficulty_menu(screen, nbr_coup) # On choisit elif pos == 4: # QUIT pygame.quit() sys.exit("Quitting...") # ça parle de lui-même.... pygame.display.update() # On update tout l'écran
def test_win(self): lotto = play() assert lotto.win() == True, "return True"
boardss[i][j].surroundings[0][6] = boardss[i + 1][j] # bottom if j < len(boardss[i]) - 1: boardss[i][j].surroundings[0][7] = boardss[i + 1][j + 1] # bottomright ##################################################################### [gameLocX, gameLocY, _, _] = pyautogui.locateOnScreen(tiles[0], grayscale=False, confidence=.5) # originally (tiles, squares, ... (in case it mattered) update(tiles, boardss, boardholder, gameLocX, gameLocY) pyautogui.click(x=squares[0].left + 10, y=squares[0].top + 10) # Slaps the four corners, opens up a lot of the board update(tiles, boardss, boardholder, gameLocX, gameLocY) if boardss[0][len(boardss[0]) - 1].flagged is False: pyautogui.click(x=boardss[0][len(boardss[0]) - 1].left + 10, y=boardss[0][len(boardss[0]) - 1].top + 10) update(tiles, boardss, boardholder, gameLocX, gameLocY) if boardss[len(boardss) - 2][0].flagged is False: pyautogui.click(x=boardss[len(boardss) - 2][0].left + 10, y=boardss[len(boardss) - 2][0].top + 10) update(tiles, boardss, boardholder, gameLocX, gameLocY) if boardss[len(boardss) - 2][len(boardss[0]) - 1].flagged is False: pyautogui.click(x=boardss[len(boardss) - 2][len(boardss[0]) - 1].left + 10, y=boardss[len(boardss) - 2][len(boardss[0]) - 1].top + 10) update(tiles, boardss, boardholder, gameLocX, gameLocY) update(tiles, boardss, boardholder, gameLocX, gameLocY) play(tiles, boardss, boardholder, gameLocX, gameLocY)
from play import * play(10)
import time import pygame import play import pymedia while True: højre = (" /(ಠ益ಠ)/ ") venstre = (" \(ಠ益ಠ)\ ") skip_1 = time.sleep(1) skip_2 = time.sleep(0.1) play("Nightcore - Rockefeller Street - (Lyrics).wav") pygame.mixer.init() pygame.mixer.music.load("Nightcore - Rockefeller Street - (Lyrics).wav") pygame.mixer.music.play() time.sleep(33) print(højre) skip_1 print(venstre) skip_1 print(højre) skip_1 print(højre) skip_1 print(venstre) skip_1 print(højre) skip_1 print(venstre) skip_1
#!/usr/bin/env python3 from gameState import * from play import * gameState = gameState() play = play(gameState) play.run()
def firm_name(event): self.player_name = self.entry.get() self.TKplayer_name.set(self.player_name) self.entry.delete(0,tk.END) self.TKresponse.set('What do you want to do?') play(self)
print('Player 2 was dealt:', sort_cards(player2.hand)) print('Player 3 was dealt:', sort_cards(player3.hand)) print('Player 4 was dealt:', sort_cards(player4.hand)) print('\n') print(find3d(PLAYERS), 'has the 3 of Diamonds and goes first.') # FIRST TURN # SET PLAYER WITH THE 3 OF DIAMONDS TO ACTIVE PLAYER current_player = find3d(PLAYERS) play_to_beat = [] if current_player == player1: current_play = playerTurn(current_player, current_player.hand, play_to_beat, True) else: current_play = play(current_player, current_player.hand, True, play_to_beat) print(current_player, 'played', current_play) hand = current_player.hand play_to_beat = [] play_to_beat = current_play current_player = nextPlayer(current_player) pass_count = 0 winner = False while not winner: is_start_of_round = False