def main(): myGame = Game() while myGame.playing: myGame.view() myGame.accept_input() myGame.control()
def test_valid(): game = Game((1)) block_list = [Block("enemy", [80, 40]), Block("enemy", [40, 40])] new_block = Block("enemy", [120, 120]) assert game.validate_position(block_list, new_block) new_block = Block("enemy", [70, 40]) assert not (game.validate_position(block_list, new_block))
def main(): """ Main function of quoridor. Create a game instance and launch game rounds. """ startTime = time.time() time_to_run = int( sys.argv[1]) * 60 #time you want program to run for in minutes game = Game( [ # 2 or 4 My_Bot("Justin"), My_Bot1("Alain") #BuilderBot("Benoit"), #BuilderBot("Clément"), #Human("Pierre") #RandomBot("Justin"), #RandomBot("Nick") ], totalFenceCount=20, cols=9, rows=9) game.start(startTime, time_to_run) # rounds game.end() global TRACE
def main(): game = Game() last_move = 'something' while True: move = game.generate_move() print(move) if last_move == '' and move == '': # Game Finished! break last_move = move
def step_impl(context): game_list = [] for row in context.table: elenco = [] idiomas = [] game = Game(row['NAME'], row['RELEASE DATE'], row['DEVELOPER'], row['RATE']) game_list.append(game) context.games = game_list
def buttons_click(self, x, y, wd, hg, mouse, click): if x + wd > mouse[0] > x and y + hg > mouse[1] > y: if click[0] == 1: # Intenta conectar 2 jugadores self.connect_player() # Si la partida no tiene 2 jugadores, se elimina la partida creada y la pantalla se refresca self.verify_multi_out() Game(self.display, self.user, self.num_match)
def start_game(self, map_to_load: str): self.root.destroy() logger.info("Start Game") map_path = map_to_load logger.info("The map_path to load is " + map_path) level = Game.LevelParser(map_path).get_level() logger.debug("The loaded Level is " + level.__str__()) new_game = Game.Game(level) #new_game.level = level new_game.execute()
def main(): """ Main function of quoridor. Create a game instance and launch game rounds. """ players, rounds, cols, rows, totalFenceCount, squareSize = readArguments() game = Game(players, cols, rows, totalFenceCount, squareSize) game.start(rounds) game.end() global TRACE print("TRACE") for i in TRACE: print("%s: %s" % (i, TRACE[i]))
def test_board_setup(self): game = Game(6, Mode.suspicion) show = [["back", "back", "back", "back", "back"], \ ["back", "back", "back", "back", "back"], \ ["back", "back", "center", "back", "back"], \ ["back", "back", "back", "back", "back"], \ ["back", "back", "back", "back", "back"]] board = game.get_board() self.assertEqual(show, board.show()) tile = board.get_tile(2, 3) self.assertRaises(IndexError, board.get_tile, 3, 6) self.assertRaises(IndexError, board.get_tile, 7, 4) self.assertIsInstance(tile, Tile) board.turn_all_tiles() self.assertTrue("exit" not in board[0][2] and board[1][1:3] \ and board[2] and board[3][1:3]and board[4][2])
def run(width, height, num_bombs): pygame.init() game = Game(width, height, num_bombs) player = Player() win = pygame.display.set_mode((width * 32, height * 32)) running = True while running: events = pygame.event.get() for event in events: if event.type == pygame.QUIT: running = False pygame.quit() quit() player.update(events, game) game.draw(win)
def test_set_turn_and_character_per_player(self): game1 = Game(6, Mode.suspicion) self.assertEqual(game1.turn, 10) self.assertEqual(game1.character, 1) game2 = Game(1, Mode.solo) self.assertEqual(game2.turn, 8) self.assertEqual(game2.character, 4) game3 = Game(4, Mode.team) self.assertEqual(game3.turn, 10) self.assertEqual(game3.character, 1) game4 = Game(3, Mode.competition) self.assertEqual(game4.turn, 10) self.assertEqual(game4.character, 2) game5 = Game(3, Mode.cooperation) self.assertEqual(game5.turn, 8) self.assertEqual(game5.character, 2) game6 = Game(5, Mode.cooperation) self.assertEqual(game6.character, 1)
from src.Game import * from src.Board import * if __name__ == "__main__": p1_board = Board() p2_board = Board() p1 = Player(p1_board) p2 = Player(p2_board) p1.add_opponent(p2) p2.add_opponent(p1) ShootyBoats = Game(p1, p2) ShootyBoats.run_game()
from src import Game from src import GameState from src import Button gs = GameState() g = Game(gs) def f(): print("Clicked!") width = 14 height = 24 for x in range(0, width): for y in range(0, height): button = Button( g.canvas, (x / width, y / height), 1 / width, 1 / height, anchor="NW", text="(" + str(x) + "," + str(y) + ")", textHighlight=(1, 0, 0) ) g.addGameObject(button) # o = Oval( # g.canvas, # (.5, .5),
from __future__ import print_function from __future__ import division import sys import pygame pygame.init() from pygame.locals import * from src import Fossa, CanvasState, Game fossa = Fossa() game = Game() canvas_state = CanvasState(game.screen) game.set_start_state(canvas_state) game.mainloop()
import pygame as pg import src.Game as game if __name__ == '__main__': app = game.Game() app.game_loop() pg.quit() quit()
from src import Game # game = Game(4) if __name__ == '__main__': # game.init() Game()
from src import Game import pygame gamesize = 20 tile_size = 50 control_type = "PLAYER" # "AI" color_dict = { 0: (0, 0, 0), # black for empty field 1: (52, 235, 52), # green for snakepart 2: (52, 235, 52), # green for snakehead 3: (235, 52, 52) # red for apple } if __name__ == "__main__": game = Game(size=gamesize) pygame.init() screen = pygame.display.set_mode( (gamesize * tile_size, gamesize * tile_size)) pygame.display.set_caption("Snake") running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False # key is pressed if event.type == pygame.KEYDOWN: if event.key == pygame.K_UP:
### Aquí debe de comenzar el trabajo from src.Game import * Juego = Game(9, 2) Juego.main()
def main(): display = pygame.display.set_mode( (config["game"]["height"], config["game"]["width"])) pygame.display.set_caption('Rycerz') game = Game(display) game.loop()
parser.add_argument('-p', '--puzzle', help="Puzzle to solve", default=argparse.SUPPRESS) parser.add_argument( '-g', '--generate', help="X/Y size of the generated map. (Pointless with -p option)", type=int, default=0, choices=range(1, 10)) parser.add_argument('-b', '--bench', help="Mode benchmark. Disable visual and game aspect.", action='store_false') args = parser.parse_args() try: puzzle = args.puzzle except AttributeError: puzzle = None finally: size = 3 if (args.generate == 0) else args.generate iMode = args.bench grid = Board(size, puzzle, False) solvedGrid = Board(size, puzzle, True) game = Game(grid, solvedGrid, grid.lenX, iMode) game.run()
def run_game(): g = Game() g.execute()
"""Play against the random bot as a human!""" import sys from src import Game from src.model.Game import InvalidMove_Error sys.path.append('.') game = Game({'SZ': 5}) while True: print(game) print('Your move:') location = input() try: game.b(location) print(game) # time.sleep(1) move = game.generate_move(apply=True, show_board=False) if move != '': print(f'Bot plays {move}') else: print('Bot passes') except InvalidMove_Error as e: print(' '.join(e.args))
import argparse from src import Game p = argparse.ArgumentParser(description="TickTacToe Game") p.add_argument("skip", metavar="skip", type=bool, default=False, help="Human Player Name") a = p.parse_args() g = Game() # Skip intro screen if a.skip: g.update_settings({ "state": 1, "human_name": "James", "human_figure": "X", "computer_name": "Tom", "computer_figure": "0", "board_size": 3 }) g.play_game_main()
import random import numpy as np from src import Game import glob # create game client game = Game.Game() # file to store custom commands cmd_file = "../private/replies.txt" lenny_file = "../text-files/lenny.txt" # get the borg client from broskibot # client = Parameters.Parameters.client # command prefix prefix = "!" class Replies: def __init__(self): self.count = 0 def getreply(self, message): msg = message.content self.count += 1 print('messages received: ', self.count) # Chat sent in the 'game' channel are sent to Game.py # Other commands will not work in the game channel - good or bad thing? # MUST receive an array/list
player2Name = input('Choose name for Player 2: ') b1 = B.Board(player1Name, 1) b2 = B.Board(player2Name, 1) elif chosenModeInt == 2: player1Name = input('Choose name for Player 1: ') b1 = B.Board(player1Name, 1) b2 = B.Board('Computer') elif chosenModeInt == 3: b1 = B.Board('Computer 1') b2 = B.Board('Computer 2') else: configured = False else: print('Incorrect choice! Try again.') g = G.Game(b1, b2) print('\n' * 5, '################################ GAME ##############################', sep='') endGame = False count = 0 while not endGame: print('\n\nRound: ', count) count += 1 for i in range(2): winner = g.goRound() if winner != None: endGame = True break count -= 1
from src.Catalogue import * from src.Game import * if __name__ == '__main__': game_A = Game( "Devil May Cry 5", 2019, "Capcom", "M") game_B = Game( "Uncharted 4: A Thief's End", 2016, "Naughtt Dog", "T") game_C = Game( "The Legend of Zelda: Breath of the Wild",2017,"Nintendo","E") game_D = Game( "Final Fantasy XV", 2016,"Square Enix", "T") game_E = Game( "Marvel's Spider-Man",2018,"Insomniac Games","T") game_list = [game_A, game_B, game_C, game_D, game_E] result, msj = get_game_name(game_list, "Devil") print(msj) for x in result: print(x) print("-"*20) result, msj, error = get_game_rating(game_list, ["T"]) print(msj) for x in result: print(x) print("-"*20) result, msj, error = get_game_rating(game_list, ["E", "M"]) print(msj) for x in result: print(x) print("-"*20)