Ejemplo n.º 1
0
 def __init__(self):
     global escrever
     self.screen = None
     self.atraso = 350  # quanto tempo entre os movimentos
     self.game = GameEngine()
     self.novoJogo()
     pass
Ejemplo n.º 2
0
 def run(self):
     game = GameEngine(self)
     while game.run():
         pygame.display.flip()
         self.clock.tick(60)
     self.destroy()
     return self
Ejemplo n.º 3
0
    def send_game_state(self):
        GameEngine().acquire()
        s = GameEngine().get_player_state(self._player_id)
        kills = []  # TODO: Call the right GameEngine method to get the new
        #       kills to display.
        terminals = []  # TODO: Call the right GameEngine method to get the
        #       terminal pirating progressions.
        terminals = [[1, 100], [2, 100], [3, 100]]
        events = []  # TODO: Call the right GameEngine method to get the new
        #       events.
        time = GameEngine().get_remaining_time()
        GameEngine().release()

        self.send({
            'type': 'update',
            'l': s['hp'],
            'p': (s['x'], s['y']),
            'd': s['d'],
            's': s['s'],
            'v': s['v'],
            'k': kills,
            'vp': s['vp'],
            'pi': terminals,
            'vo': s['vo'],
            'ao': s['ao'],
            'ev': events,
            'ti': time
        })
Ejemplo n.º 4
0
    def start_game(self, players):
        """
        (1) initialize and start game engine
        (2) send START to everyone with players in turn order as value
        (3) send TURN to everyone with first to play as value
        (4) send face up cards (hand) separately to each player
        (5) send face down sprite once to everyone
        (6) send discard pile card to everyone
        """
        self.game_engine = GameEngine(players)
        self.game_engine.start()
        # send START and players ordered by turn as value:
        self.send_to_all({"START": [i.name for i in self.game_engine.players]})
        # send current turn:
        player_turn = self.game_engine.players[self.game_engine.turn].name
        self.send_to_all({"TURN": player_turn})

        # send face down sprite to everyone:
        self.send_card(('reverso', ''), '2')
        # send discard pile card to everyone:
        self.send_card(self.game_engine.discard_pile, '1')

        # send hand to each player:
        for socket_, player_name in self.players.items():
            cards = [p.cards for p in self.game_engine.players
                        if p.name == player_name][0]
            opponents_sock = [sock for sock, name in self.players.items() if
                    name != player_name]
            for card in cards:
                self.send_card(card, '0', client_socket=socket_)
                for opponent_sock in opponents_sock:
                    # send OPPONENT_CARD command to each opponent of player
                    message = {"OPPONENT_CARD": [player_name, True]}
                    self.send(message, opponent_sock)
Ejemplo n.º 5
0
    def __init__(self, width: int, height: int, title: str):
        """

        :param width:
        :param height:
        :param title:
        """
        super().__init__(width, height, title, antialiasing=False)

        # Main game engine, where the game is managed
        self.game_engine = GameEngine()

        # Track the current state of what key is pressed
        self.left_pressed = False
        self.right_pressed = False
        self.up_pressed = False
        self.down_pressed = False
        self.up_left_pressed = False
        self.up_right_pressed = False
        self.down_left_pressed = False
        self.down_right_pressed = False

        # Used for auto-repeat of moves
        self.time_since_last_move_check = 0

        # Where is the mouse?
        self.mouse_position: Optional[Tuple[float, float]] = None

        self.mouse_over_text: Optional[str] = None

        # These are sprites that appear as buttons on the character sheet.
        self.character_sheet_buttons = arcade.SpriteList()

        arcade.set_background_color(colors['background'])
Ejemplo n.º 6
0
class RandomAI:
    def __init__(self):
        self.engine = GameEngine()

    def get_action(self, gamestate, player):
        if self.engine.current_phase_string(gamestate) == "Pre-combat main phase":
            # play a land if possible
            for card in player.hand:
                if card.type == "Land" and not gamestate.player_played_land:
                    return {"Play": card, "player": player.ID}
            # tap all lands for mana
            use_cards = []
            for card in player.battlefield:
                if card.untapped and card.type == "Land":
                    use_cards.append(card)
            if use_cards:
                return {"Use": use_cards, "player": player.ID}

            # cast any cards we can
            for card in player.hand:
                if card.type == "Creature":
                    if player.mana_pool >= card.cmc:
                        return {"Play": card, "player": player.ID}
            return "pass_priority"
        elif self.engine.current_phase_string(gamestate) == "Declare attackers step":
            attackers = []
            for card in player.battlefield:
                if card.type == "Creature":
                    if card.summoning_sickness is False:
                        attackers.append(card)
            return {"Attack": attackers, "player": player.ID}
Ejemplo n.º 7
0
class RandomAI():
    def __init__(self):
        self.engine = GameEngine()

    def get_action(self, gamestate, player):
        if self.engine.current_phase_string(gamestate) == 'Pre-combat main phase':
            # play a land if possible
            for card in player.hand:
                if card.type == 'Land' and not gamestate.player_played_land:
                    return {'Play': card, "player": player.ID}
            # tap all lands for mana
            use_cards = []
            for card in player.battlefield:
                if card.untapped and card.type == 'Land':
                    use_cards.append(card)
            if use_cards:
                return {'Use': use_cards, "player": player.ID}

            # cast any cards we can
            for card in player.hand:
                if card.type == "Creature":
                    if player.mana_pool >= card.cmc:
                        return {'Play': card, "player": player.ID}
            return "pass_priority"
        elif self.engine.current_phase_string(gamestate) == 'Declare attackers step':
            attackers = []
            for card in player.battlefield:
                if card.type == "Creature":
                    if card.summoning_sickness is False:
                        attackers.append(card)
            return {'Attack': attackers, "player": player.ID}
Ejemplo n.º 8
0
    def shutdown(self, force=False):
        print 'Shutting down server{}...'.format(
            ' (the hardcore way)' if force else '')

        GameEngine().end_of_game()
        self._tcp_server.shutdown(force)
        GameEngine().stop_auto_mode(force)
        print 'Good bye.'
Ejemplo n.º 9
0
    def run(self):
        force = False
        sleep_time = GameEngine().config.end_game_poll_time

        try:
            while GameEngine().loop:
                sleep(sleep_time)
        except KeyboardInterrupt:
            force = True

        self.shutdown(force)
Ejemplo n.º 10
0
 def __init__(self, chessboard):
     self.chessboard = chessboard
     self.player_piece = {
         Player.HUMAN: ChessBoard.WHITE_PAWN,
         Player.AI: ChessBoard.BLACK_PAWN
     }
     self.move_validator = MoveValidator(self)
     self.turn = Player.HUMAN
     self.was_last_move_a_two_step_move = True
     self.position_of_two_steps_pawn = (4, 'C')
     self.game_engine = GameEngine(self)
     self.mini_max = MinMax(self, self.move_validator)
Ejemplo n.º 11
0
def play():
    store = pydux.create_store(reducer)
    game_engine = GameEngine(store)

    game_engine.request({'type': 'create_state'})
    response = game_engine.request({
        'type': 'play_creature',
        'card_index': 0,
        'player': 'p1',
        'lane': 'field_lane'
    })

    print(pprint(response))
Ejemplo n.º 12
0
def main():
    '''The main programme (to run first)'''
    # create the game engine 'pygame'
    game_engine = GameEngine()
    # create controllers for objects to construct inside the game
    labyrinth_ctrl = LabyrinthController(game_engine)
    guard_ctrl = GuardController(labyrinth_ctrl, game_engine)
    hero_ctrl = HeroController(labyrinth_ctrl, guard_ctrl, game_engine)
    ObjectController(labyrinth_ctrl,
                     hero_ctrl, guard_ctrl,
                     game_engine)
    hero_ctrl.setting_collisions()
    # start the game
    game_engine.start()
Ejemplo n.º 13
0
 def start_game(self):
     if len(self.players_sessions) < 4:
         raise HTTPException(401, "At least 4 players needed")
     self.state = STATE_STARTED
     for session in self.players_sessions:
         session.state = STATE_PLAYING
     self.engine = GameEngine(self)
Ejemplo n.º 14
0
    def __init__(self, width, height, title):
        """
        Args:
            width = 画面の幅
            height = 画面の高さ
            title = タイトル
            antialiasing = 画像にアンチエイリアスを掛けるかどうか
        """
        super().__init__(width, height, title, antialiasing=False)

        self.engine = GameEngine()

        self.player_direction = None
        self.viewports = None
        self.choice = 0 # messagewindowの選択
        self.game_dict = None# saveファイルの格納に使う
Ejemplo n.º 15
0
    def play_game(self):
        print('Welcome to Game of Life !')
        try:
            rows_input = int(input('How many rows for your grid ? '))
            columns_input = int(input('How many columns for your grid ? '))
            rounds_input = int(input('How many rounds for your game ? '))
        except Exception as e:
            print(e)
        else:
            game_engine = GameEngine(rows_input, columns_input)

            while self.rounds_number <= rounds_input:
                print(game_engine)
                game_engine.update_grid()
                print('\n\n')
                self.rounds_number += 1
Ejemplo n.º 16
0
 def reset(self):
     """
     Reset ebvironment. See `GameState.reset()` for detail.    重置环境, GameState.reset()这个函数没看见过, 不知道放在哪里
     """
     state = GameEngine.reset(self)
     self.distance = float(np.linalg.norm(self.rabbit_loc - self.gun_loc)) / self.screen_size
     return state    # reset返回的就是状态
Ejemplo n.º 17
0
    def send_end_stats(self):
        GameEngine().acquire()
        gs = GameEngine().get_game_statistics()
        ps = GameEngine().get_player_state(self._player_id)
        GameEngine().release()

        data = {
            'type': 'end',
            'winners': gs['winners'],
            'ttime': gs['ttime'],
            'lifes': ps['l']
        }
        if self._player_team == MERC_TEAM:
            data['kills'] = ps['kills']
        elif self._player_team == SPY_TEAM:
            data['recap'] = ps['recap']
        self.send(data)
Ejemplo n.º 18
0
    def handle_shoot(self, data):
        try:
            angle = data['v']
            if not isinstance(angle, float) or angle < 0 or angle > 360:
                print 'Wrong input received: invalid message field `v`'
                self.update_status(self.CONNECTION_STOP)
                return
        except KeyError:
            print 'Wrong input received: missing field(s) in message of type \
`shoot`'

            self.update_status(self.CONNECTION_STOP)
            return

        GameEngine().acquire()
        GameEngine().shoot(self._player_id, angle)
        GameEngine().release()
Ejemplo n.º 19
0
class BonkIoGame(gym.Environment):
    def __init__(self):
        self._engine = None

    def reset(self):
        if self._engine is None:
            self._engine = GameEngine()

        obs, info = self._engine.get_obs()
Ejemplo n.º 20
0
 def init_game():
     game = GameEngine()
     game.put_player(1, 0)
     game.put_box(4, 6)
     game.put_box(4, 7)
     game.add_goal(1, 3)
     game.add_goal(9, 9)
     game.build_wall(2, 2, 1, 3)
     game.build_wall(0, 4, 3, 1)
     game.build_wall(5, 3, 2, 1)
     game.build_wall(4, 2, 1, 2)
     game.build_wall(4, 0, 1, 1)
     return game
Ejemplo n.º 21
0
    def handle_move(self, data):
        try:
            angle = data['d']
            speed = data['s']
            if not isinstance(angle, float) or angle < 0 or angle > 360:
                print 'Wrong input received: invalid message field `d`'
                self.update_status(self.CONNECTION_STOP)
                return
            elif not isinstance(speed, float) or speed < 0 or speed > 1:
                print 'Wrong input received: invalid message field `s`'
                self.update_status(self.CONNECTION_STOP)
                return
        except KeyError:
            print 'Wrong input received: missing field(s) in message of type \
`move`'

            self.update_status(self.CONNECTION_STOP)
            return

        GameEngine().acquire()
        GameEngine().set_movement_angle(self._player_id, angle)
        GameEngine().set_movement_speedx(self._player_id, speed)
        GameEngine().set_movement_speedy(self._player_id, speed)
        GameEngine().release()
Ejemplo n.º 22
0
    def handle_init(self, data):
        try:
            if not data['team'] in (MERC_TEAM, SPY_TEAM):
                print 'Wrong input received: invalid message field `team`'
                self.update_status(self.CONNECTION_STOP)
                return
            elif not set(data['nick']).issubset(printable_chars):
                print 'Wrong input received: invalid message field `nick`'
                self.update_status(self.CONNECTION_STOP)
                return
        except KeyError:
            print 'Wrong input received: missing field(s) in message of type \
`init`'

            self.update_status(self.CONNECTION_STOP)
            return

        self._player_id = GameEngine().connect_to_player(
            data['team'], data['nick'])

        if self._player_id is None:
            print 'Initialisation failed: team full'
            self.update_status(self.CONNECTION_STOP)
            return

        self._player_team = data['team']

        player_state = GameEngine().get_player_state(self._player_id)
        pos_x, pos_y, max_hp = (player_state[k] for k in ('x', 'y', 'hp'))

        GameEngine().all_players_connected.wait()

        self.send({
            'type': 'init',
            'id': self._player_id,
            'pos': (pos_x, pos_y),
            'max_hp': max_hp,
            'team': data['team'],
            'map': GameEngine().get_map_name(),
            'map_hash': GameEngine().get_map_hash(),
            'players': GameEngine().get_players_info()
        })

        self.setup_sender(GameEngine().config.send_state_interval)
        self.update_status(self.CONNECTION_RUN)
Ejemplo n.º 23
0
    def setup(self):
        print 'New client connected:', self.client_address[0], \
            self.client_address[1]

        super(SpylightRequestHandler, self).setup()

        self._player_id = None
        self._player_team = None

        self._sender_busy = Event()
        self._sender_interval = -1
        self._sender = None

        self.status = self.CONNECTION_INIT

        if GameEngine().all_players_connected.is_set():
            print 'Connection will be closed: game already launched (both \
teams are full)'

            self.update_status(self.CONNECTION_STOP)
Ejemplo n.º 24
0
from game_engine import GameEngine
from gamestate import GameState
from AI.randomAI import RandomAI
from deck import Deck

game_engine = GameEngine()
AI_1 = RandomAI()
AI_2 = RandomAI()

deck_1 = Deck('goblins.deck').cards
deck_2 = Deck('goblins.deck').cards

gamestate = GameState()

game_engine.setup_game(gamestate, deck_1, deck_2)

while not game_engine.game_over(gamestate):
    if game_engine.who_has_action(gamestate) == 0:
        action = AI_1.get_action(gamestate, gamestate.players[0])
    else:
        action = AI_2.get_action(gamestate, gamestate.players[1])
    game_engine.take_action(gamestate, action)

    print "-------------------------------------------------------------------"
    print "turn: ", gamestate.turn, "phase:", game_engine.current_phase_string(gamestate)
    print "life: ", gamestate.players[1].life, "mana", gamestate.players[1].mana_pool, "library: ", len(gamestate.players[1].library)
    print "player_1_hand", gamestate.players[1].hand
    print "player_1_battlefield", gamestate.players[1].battlefield
    print "player_0_battlefield", gamestate.players[0].battlefield
    print "player_0_hand", gamestate.players[0].hand
    print "life: ", gamestate.players[0].life, "mana", gamestate.players[0].mana_pool, "library: ", len(gamestate.players[0].library)
Ejemplo n.º 25
0
class Game:
    textoX = escrever.render('X', True, (200, 0, 0))

    def __init__(self):
        global escrever
        self.screen = None
        self.atraso = 350  # quanto tempo entre os movimentos
        self.game = GameEngine()
        self.novoJogo()
        pass

    def novoJogo(self, tamanhoCobra=3):
        self.game.iniciar(tamanhoCobra)
        self.width, self.height = self.game.tamanhoX * tamanhoPeca + tamanhoPeca * 2, self.game.tamanhoY * tamanhoPeca + tamanhoPeca * 2
        self.size = self.width, self.height + painelPontuacaoH
        self.proxDir = GameEngine.BAIXO
        self.clock = pygame.time.Clock()
        self.clock.tick()
        self.tempo = 0
        self.frutaIdx = random.randint(0, len(frutas) - 1)
        if self.screen is None:
            self.screen = pygame.display.set_mode(self.size)
        pass

    def esperarTick(self):
        # permitir o movimento da cobra
        self.clock.tick()
        self.tempo += self.clock.get_time()
        if self.tempo >= self.atraso:
            self.tempo = 0
            self.game.moverCobra(self.proxDir)
            return True
        return False

    def draw(self):
        # limpar a tela
        self.screen.fill(branco)

        # pintar linhas dos quadros
        self.screen.fill(
            (200, 200, 200),
            pygame.Rect(tamanhoPeca,
                        (1 + self.game.tamanhoY / 2) * tamanhoPeca,
                        self.game.tamanhoX * tamanhoPeca, 1))
        self.screen.fill(
            (200, 200, 200),
            pygame.Rect((1 + self.game.tamanhoX / 2) * tamanhoPeca,
                        tamanhoPeca, 1, self.game.tamanhoY * tamanhoPeca))
        self.screen.blit(escrever.render('1', True, (200, 200, 200)),
                         (1 * self.width / 4, 1 * self.height / 4))
        self.screen.blit(escrever.render('2', True, (200, 200, 200)),
                         (3 * self.width / 4, 1 * self.height / 4))
        self.screen.blit(escrever.render('3', True, (200, 200, 200)),
                         (1 * self.width / 4, 3 * self.height / 4))
        self.screen.blit(escrever.render('4', True, (200, 200, 200)),
                         (3 * self.width / 4, 3 * self.height / 4))

        # pintar espacos da tela
        for i in range(0, self.game.tamanhoY + 2):
            self.screen.fill(
                marrom,
                pygame.Rect(0, i * tamanhoPeca, tamanhoPeca, tamanhoPeca))
            self.screen.fill(
                marrom,
                pygame.Rect(self.width - tamanhoPeca, i * tamanhoPeca,
                            tamanhoPeca, tamanhoPeca))
            pass
        for i in range(0, self.game.tamanhoX + 2):
            self.screen.fill(
                marrom,
                pygame.Rect(i * tamanhoPeca, 0, tamanhoPeca, tamanhoPeca))
            self.screen.fill(
                marrom,
                pygame.Rect(i * tamanhoPeca, self.height - tamanhoPeca,
                            tamanhoPeca, tamanhoPeca))
            pass

        # pintar fruta
        # self.screen.fill( verm, pygame.Rect( (self.game.comida[0]+1) * tamanhoPeca, (self.game.comida[1]+1) * tamanhoPeca, tamanhoPeca, tamanhoPeca ) )
        self.screen.blit(frutas[self.frutaIdx],
                         ((self.game.comida[0] + 1) * tamanhoPeca,
                          (self.game.comida[1] + 1) * tamanhoPeca))

        # pintar corpo
        for i in range(1, len(self.game.corpo)):
            corpo = self.game.corpo[i]
            self.screen.fill(
                verde2,
                pygame.Rect((corpo[0] + 1) * tamanhoPeca,
                            (corpo[1] + 1) * tamanhoPeca, tamanhoPeca,
                            tamanhoPeca))
            pass
        cabeca = self.game.corpo[0]
        self.screen.fill(
            verde1,
            pygame.Rect((cabeca[0] + 1) * tamanhoPeca,
                        (cabeca[1] + 1) * tamanhoPeca, tamanhoPeca,
                        tamanhoPeca))
        # verificar e pintar 'X' na cabeça da cobra caso o jogo tenha terminado
        if self.game.terminado:
            self.screen.blit(Game.textoX, ((cabeca[0] + 1) * tamanhoPeca + 4,
                                           (cabeca[1] + 1) * tamanhoPeca - 2))
            pass

        # escrever pontuação
        textoPontuacao = escrever.render('Pontos: %d' % (self.game.pontos),
                                         True, (0, 0, 0))
        self.screen.blit(textoPontuacao, (10, self.height + 20))

        # escrever entradas do treinamento para o estado atual
        entradas = ia_engine.criarEntradas(self.game)
        # direção da fruta
        txt = '%d%d%d%d' % (entradas[0], entradas[1], entradas[2], entradas[3])
        self.screen.blit(escrever.render('^ > . <', True, (160, 160, 160)),
                         (110, self.height))
        self.screen.blit(escrever.render(txt, True, (200, 40, 40)),
                         (110, self.height + 20))
        self.screen.blit(escrever.render('fruta', True, (200, 200, 200)),
                         (110, self.height + 40))
        # direção da cobra
        txt = '%d%d%d%d' % (entradas[4], entradas[5], entradas[6], entradas[7])
        self.screen.blit(escrever.render('^ > . <', True, (160, 160, 160)),
                         (180, self.height))
        self.screen.blit(escrever.render(txt, True, (20, 140, 20)),
                         (180, self.height + 20))
        self.screen.blit(escrever.render('cobra', True, (200, 200, 200)),
                         (180, self.height + 40))
        # perigo nas direções de decisão
        txt = '%d%d%d' % (entradas[8], entradas[9], entradas[10])
        self.screen.blit(escrever.render('D F E', True, (160, 160, 160)),
                         (250, self.height))
        self.screen.blit(escrever.render(txt, True, (200, 40, 40)),
                         (250, self.height + 20))
        self.screen.blit(escrever.render('perigo', True, (200, 200, 200)),
                         (250, self.height + 40))
        # espaços vazios
        txt = '%3d %3d %3d %3d' % (entradas[11] * 100, entradas[12] * 100,
                                   entradas[13] * 100, entradas[14] * 100)
        self.screen.blit(
            escrever.render('%3d %3d %3d %3d' % (1, 2, 3, 4), True,
                            (160, 160, 160)), (320, self.height))
        self.screen.blit(escrever.render(txt, True, (200, 40, 40)),
                         (320, self.height + 20))
        self.screen.blit(escrever.render('espaços', True, (200, 200, 200)),
                         (320, self.height + 40))

        pygame.display.flip()
        pass
Ejemplo n.º 26
0
    def __init__(self):
        super(GameScreen, self).__init__(0xBF907A, 0x806052, 0xFFC0A3,
                                         0x403029)

        # Placeholders
        self.answer = "0"
        self.question = None

        # Initialize game
        self.game = Game(
            game_engine=GameEngine.BuildGameEngineFromStatesAndTransitions(
                GAME_STATES_FILENAME, GAME_TRANSITIONS_FILENAME),
            player_name=playerName,
            difficulty_level=difficultyLevel)

        # Create required labels.
        self.timer_label = Label("00",
                                 font_name="Times New Roman",
                                 font_size=32,
                                 anchor_x='center',
                                 anchor_y='center')

        self.question_label = Label("Question Text",
                                    font_name="Times New Roman",
                                    font_size=32,
                                    anchor_x='center',
                                    anchor_y='center')

        self.answer_label = Label("Answer Text",
                                  font_name="Times New Roman",
                                  font_size=32,
                                  anchor_x='center',
                                  anchor_y='center')

        self.score_board_label = Label("Score: ",
                                       font_name="Times New Roman",
                                       font_size=32,
                                       anchor_x='center',
                                       anchor_y='center')

        self.instruction_label = Label("Press Enter to submit answer!",
                                       font_name="Times New Roman",
                                       font_size=32,
                                       anchor_x='center',
                                       anchor_y='center')

        self.timer_label.position = (
            director._window_virtual_width /
            10) * 9, director._window_virtual_height / 10
        self.question_label.position = director._window_virtual_width / 2, director._window_virtual_height / 2
        self.answer_label.position = director._window_virtual_width / 2, director._window_virtual_height / 2 - 50
        self.score_board_label.position = director._window_virtual_width / 10, director._window_virtual_height / 10
        self.instruction_label.position = director._window_virtual_width / 2, (
            director._window_virtual_height / 10) * 9

        self.add(self.instruction_label)
        self.add(self.timer_label)
        self.add(self.question_label)
        self.add(self.score_board_label)
        self.add(self.answer_label)

        self.display_question()
Ejemplo n.º 27
0
#!/usr/bin/env python3
import sys
import rospy
from game_engine import GameEngine
from game_engine_competition import GameEngineCompetition
# useful sudo apt-get install -y python3-rospy

_IN_ROS = True

if __name__ == '__main__':
    if _IN_ROS:
        rospy.init_node("soccer_strategy")
        g = GameEngineCompetition()
        g.run()
    else:
        g = GameEngine()
        g.run_loop()


Ejemplo n.º 28
0
 def __init__(self):
     self.game_engine = GameEngine()
Ejemplo n.º 29
0
"""
PROJECT: CuriosityJar - The Humble-Nishiyama Randomness Game
DESCRIPTION: Explore and Experiment on Penney's game concepts
AUTHOR: Nuttaphat Arunoprayoch
DATE: 09-SEP-2020
"""
# Import libraries
import pandas as pd
import matplotlib.pyplot as plt
from game_engine import GameEngine

# Load Core GameEngine
game_engine = GameEngine()


# Main function
def main() -> None:
    # Without a winning method
    without_winning_method_res = game_engine.start_experiment(
        is_winning_method_used=False)

    # With a winning method
    with_winning_method_res = game_engine.start_experiment(
        is_winning_method_used=True)

    # Prepare DataFrame
    df_without_winning_method = pd.DataFrame([without_winning_method_res])
    df_without_winning_method['cat'] = 'without'
    df_with_winning_method_res = pd.DataFrame([with_winning_method_res])
    df_with_winning_method_res['cat'] = 'with'
    df_final = pd.concat(
Ejemplo n.º 30
0
    def reset(self):
        if self._engine is None:
            self._engine = GameEngine()

        obs, info = self._engine.get_obs()
Ejemplo n.º 31
0
 def __init__(self):
     self.engine = GameEngine()
Ejemplo n.º 32
0
 def game_state() -> dict:
     "Get the current game state"
     return GameEngine().get_game_state()
Ejemplo n.º 33
0
 def submit_entry(user_id: str, entry: Decimal) -> bool:
     "submit a bet"
     return GameEngine().submit_entry(user_id, entry)
Ejemplo n.º 34
0
def main():
    engine = GameEngine()
    engine.main()