def standings(count: int = -1):

        if not PlayManager._initialized:
            PlayManager.init()

        if count == -1:
            count = len(PlayManager._bank_of_plays)

        Debug.evolution(f'Top {count} exemplars of evolution:')

        for place, play in enumerate(
                sorted([
                    play for play in PlayManager._bank_of_plays
                    if len(play.plays_history) > 10 and play.value() > 1
                ],
                       key=lambda p: p.value(),
                       reverse=True)[:count]):
            Debug.evolution(f'{place + 1:<2}) {play}')
Exemple #2
0
    def run(self) -> None:

        for num in range(self.games):

            game = Game(0, self.players, self.seats, self.money, self.blinds_scheme)

            for _ in range(game.total_players):
                game.add_bot_player()

            Debug.evolution(f'Start game #{num + 1}')

            game.start_game()

            PlayManager.standings(10)
            PlayManager.delete_bad_plays()

            if (num + 1) % 100 == 0:
                PlayManager.save_all_plays()

        PlayManager.save_all_plays()
Exemple #3
0
    def print_places(self) -> None:

        for player in self.players:
            if player.lose_time is None:
                player.set_lose_time()
                if player.controlled:
                    player.network.win()
                Debug.evolution(f'Game wins {player.name}')

        sorted_players = sorted(self.players, key=lambda p: p.lose_time, reverse=True)

        if not Debug.Standings:
            for place, player in enumerate(sorted_players[:10]):
                Debug.evolution(f'{place+1:>4}) {player.play}')

        plays = {}

        if Settings.game_mode == Mode.Testing:
            if exists('networks/plays'):
                plays = load(open('networks/plays', 'rb'))

        for place, player in enumerate(sorted_players):
            Debug.standings(f'{place+1:>4}) {player.name}')
            if not player.controlled:
                player.play.set_place(place + 1, self.players_count)
            if Settings.game_mode == Mode.Testing:
                if player.play.name in plays:
                    plays[player.play.name] += [place + 1]
                else:
                    plays[player.play.name] = [place + 1]
                if player.play.exemplar == 0:
                    print('Net', player.play.name, ':', place + 1, f'  ({round(mean(plays[player.play.name]), 2)})')

        if Settings.game_mode == Mode.Testing:
            dump(plays, open('networks/plays', 'wb'))

        self.game_finished = True