From b7a8d1527c7002295a8b421f83e64a6334222c0f Mon Sep 17 00:00:00 2001 From: Tiziano Zito Date: Wed, 1 Jul 2026 16:29:42 +0200 Subject: [PATCH 1/7] Remove the concept of non-fatal errors: CLI --- pelita/scripts/pelita_main.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pelita/scripts/pelita_main.py b/pelita/scripts/pelita_main.py index 1729f820a..dcb6773f4 100755 --- a/pelita/scripts/pelita_main.py +++ b/pelita/scripts/pelita_main.py @@ -248,8 +248,6 @@ def long_help(s): dest='timeout_length', help='Run game without timeouts.') game_settings.add_argument('--initial-timeout', type=float, metavar="SEC", default=pelita.game.INITIAL_TIMEOUT_SECS, dest='initial_timeout_length', help=long_help('Timeout to load a team')) -game_settings.add_argument('--error-limit', type=int, default=5, - dest='error_limit', help='Error limit. Reaching this limit disqualifies a team (default: 5).') parser.set_defaults(timeout_length=pelita.game.TIMEOUT_SECS) game_settings.add_argument('--stop-at', dest='stop_at', type=int, metavar="N", help='Stop before playing round N.') @@ -457,7 +455,7 @@ def main(): pelita.game.run_game(team_specs=team_specs, max_rounds=args.rounds, layout_dict=layout_dict, rng=rng, allow_camping=args.allow_camping, timeout_length=args.timeout_length, - initial_timeout_length=args.initial_timeout_length, error_limit=args.error_limit, + initial_timeout_length=args.initial_timeout_length, viewers=viewers, store_output=args.store_output, team_infos=(args.append_blue, args.append_red)) From 0c20071e71177bf3440bbd18ca61e2db3737eda2 Mon Sep 17 00:00:00 2001 From: Tiziano Zito Date: Wed, 1 Jul 2026 16:30:10 +0200 Subject: [PATCH 2/7] Remove the concept of non-fatal errors: team and bot objects --- pelita/team.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pelita/team.py b/pelita/team.py index 4169223a6..1e9abb5c3 100644 --- a/pelita/team.py +++ b/pelita/team.py @@ -676,7 +676,6 @@ def __init__(self, *, bot_index, is_blue, team_name, team_time, - num_timeouts, is_noisy, bot_turn=None): self._bots = None @@ -708,7 +707,6 @@ def __init__(self, *, bot_index, self.is_blue = is_blue self.team_name = team_name self.team_time = team_time - self.timeouts = num_timeouts self.is_noisy = is_noisy self.has_exact_position = not is_noisy self.graph = graph @@ -894,8 +892,7 @@ def __str__(self): header = ("{blue}{you_blue} vs {red}{you_red}.\n" + "Playing on {col} side. Current turn: {turn}. "+ - "Bot: {bot_char}. Round: {round}, score: {blue_score}:{red_score}. " + - "timeouts: {blue_timeouts}:{red_timeouts}\n").format( + "Bot: {bot_char}. Round: {round}, score: {blue_score}:{red_score}.\n").format( blue=blue.team_name, red=red.team_name, turn=bot.turn, @@ -906,8 +903,6 @@ def __str__(self): col="blue" if bot.is_blue else "red", you_blue=" (you)" if bot.is_blue else "", you_red=" (you)" if not bot.is_blue else "", - blue_timeouts=blue.timeouts, - red_timeouts=red.timeouts, ) footer = ("Bots: {bots}\nExact: {exact}\nFood: {food}\n").format( @@ -950,7 +945,6 @@ def make_bots(*, walls, shape, initial_positions, homezone, team, enemy, round, kills=team['kills'][idx], was_killed=team['bot_was_killed'][idx], is_noisy=False, - num_timeouts=team['num_timeouts'], food=_ensure_list_tuples(team['food']), shaded_food=_ensure_list_tuples(team['shaded_food']), walls=walls, @@ -978,7 +972,6 @@ def make_bots(*, walls, shape, initial_positions, homezone, team, enemy, round, deaths=enemy['deaths'][idx], was_killed=enemy['bot_was_killed'][idx], is_noisy=enemy['is_noisy'][idx], - num_timeouts=enemy['num_timeouts'], food=_ensure_list_tuples(enemy['food']), shaded_food=[], walls=walls, From 47f2d59c71be3009f48d5a92be2ed8666c454ca4 Mon Sep 17 00:00:00 2001 From: Tiziano Zito Date: Wed, 1 Jul 2026 16:30:27 +0200 Subject: [PATCH 3/7] Remove the concept of non-fatal errors: GUI --- pelita/ui/tk_canvas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pelita/ui/tk_canvas.py b/pelita/ui/tk_canvas.py index a3993dc4b..f9a66ea2a 100644 --- a/pelita/ui/tk_canvas.py +++ b/pelita/ui/tk_canvas.py @@ -870,7 +870,7 @@ def status(team_idx): # sum the deaths of both bots in this team deaths = game_state['deaths'][team_idx] + game_state['deaths'][team_idx+2] kills = game_state['kills'][team_idx] + game_state['kills'][team_idx+2] - ret = "Timeouts: %d, Kills: %d, Deaths: %d, Time: %.2f" % (game_state["num_timeouts"][team_idx], kills, deaths, game_state["team_time"][team_idx]) + ret = "Kills: %d, Deaths: %d, Time: %.2f" % (kills, deaths, game_state["team_time"][team_idx]) return ret except TypeError: return "" From eebbccb38bf38a509e331c029eb0ecb3dcdc9713 Mon Sep 17 00:00:00 2001 From: Tiziano Zito Date: Wed, 1 Jul 2026 16:31:32 +0200 Subject: [PATCH 4/7] Remove the concept of non-fatal errors: setup_test_game --- pelita/utils.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pelita/utils.py b/pelita/utils.py index a42044068..5d6a9f01f 100644 --- a/pelita/utils.py +++ b/pelita/utils.py @@ -117,8 +117,6 @@ def run_background_game(*, blue_move, red_move, layout=None, max_rounds=300, see out['red_bots'] = game_state['bots'][1::2] out['blue_score'] = game_state['score'][0] out['red_score'] = game_state['score'][1] - out['blue_errors'] = game_state['timeouts'][0] - out['red_errors'] = game_state['timeouts'][1] out['blue_deaths'] = game_state['deaths'][::2] out['red_deaths'] = game_state['deaths'][1::2] out['blue_kills'] = game_state['kills'][::2] @@ -230,7 +228,6 @@ def setup_test_game(*, layout, is_blue=True, round=None, score=None, seed=None, 'kills': [0]*2, 'deaths': [0]*2, 'bot_was_killed' : [False]*2, - 'num_timeouts': 0, 'food': food[team_index], 'shaded_food': list(shaded_food(bot_positions, food[team_index], radius=SHADOW_DISTANCE)), 'name': "blue" if is_blue else "red", @@ -243,7 +240,6 @@ def setup_test_game(*, layout, is_blue=True, round=None, score=None, seed=None, 'kills': [0]*2, 'deaths': [0]*2, 'bot_was_killed': [False]*2, - 'num_timeouts': 0, 'food': food[enemy_index], 'shaded_food': [], 'is_noisy': is_noisy_enemy, From 2a5afe429acf50989324863551a72da4d3e2bdf1 Mon Sep 17 00:00:00 2001 From: Tiziano Zito Date: Wed, 1 Jul 2026 16:31:54 +0200 Subject: [PATCH 5/7] Remove the concept of non-fatal errors: game logic --- pelita/game.py | 71 ++++++-------------------------------------------- 1 file changed, 8 insertions(+), 63 deletions(-) diff --git a/pelita/game.py b/pelita/game.py index acd9d767f..11c8ab74e 100644 --- a/pelita/game.py +++ b/pelita/game.py @@ -124,7 +124,7 @@ def controller_await(state, await_action='play_step'): return False def run_game(team_specs, *, layout_dict, max_rounds=300, - rng=None, allow_camping=False, error_limit=5, timeout_length=TIMEOUT_SECS, + rng=None, allow_camping=False, timeout_length=TIMEOUT_SECS, initial_timeout_length=INITIAL_TIMEOUT_SECS, viewers=None, store_output=False, team_names=(None, None), team_infos=(None, None), @@ -156,17 +156,10 @@ def run_game(team_specs, *, layout_dict, max_rounds=300, rng : random.Random | int | None random number generator or a seed used to initialize a new one. - error_limit : int - The limit of non fatal errors to reach for a team before the - game is over and the team is disqualified. Non fatal errors are - timeouts and returning an illegal move. Fatal errors are raising - Exceptions. An error_limit of 0 will disable the limit. - Default: 5. - timeout_length : int or float Time in seconds to wait for the move function (or for the remote client) to return. After timeout_length seconds are elapsed a - non-fatal error is recorded for the team. + fatal error is recorded for the team. initial_timeout_length : int or float Time in seconds to wait for a remote player to have started @@ -229,7 +222,7 @@ def run_game(team_specs, *, layout_dict, max_rounds=300, # we create the initial game state state = setup_game(team_specs, layout_dict=layout_dict, max_rounds=max_rounds, allow_camping=allow_camping, - error_limit=error_limit, timeout_length=timeout_length, + timeout_length=timeout_length, initial_timeout_length=initial_timeout_length, rng=rng, viewers=viewers, store_output=store_output, team_names=team_names, @@ -304,7 +297,7 @@ def setup_viewers(viewers, print_result=True): def setup_game(team_specs, *, layout_dict, max_rounds=300, rng=None, - allow_camping=False, error_limit=5, timeout_length=TIMEOUT_SECS, initial_timeout_length=INITIAL_TIMEOUT_SECS, + allow_camping=False, timeout_length=TIMEOUT_SECS, initial_timeout_length=INITIAL_TIMEOUT_SECS, viewers=None, store_output=False, team_names=(None, None), team_infos=(None, None), raise_bot_exceptions=False, print_result=True): @@ -394,9 +387,6 @@ def setup_game(team_specs, *, layout_dict, max_rounds=300, rng=None, #: Fatal errors fatal_errors=[[], []], - #: Number of timeouts for a team - timeouts=[{}, {}], - ### Configuration #: Maximum number of rounds, int max_rounds=max_rounds, @@ -469,9 +459,6 @@ def setup_game(team_specs, *, layout_dict, max_rounds=300, rng=None, #: Random number generator rng=rng, - #: Error limit. A team loses when the limit is reached, int - error_limit=error_limit, - #: Viewers, list viewers=viewer_state['viewers'], @@ -626,8 +613,6 @@ def send_initial(game_state, raise_bot_exceptions=False): def request_new_position(game_state): - round = game_state['round'] - turn = game_state['turn'] team_idx = game_state['turn'] % 2 _bot_turn = game_state['turn'] // 2 team = game_state['teams'][team_idx] @@ -651,28 +636,11 @@ def request_new_position(game_state): } except RemotePlayerRecvTimeout: - if game_state['error_limit'] != 0 and len(game_state['timeouts'][team_idx]) + 1 >= game_state['error_limit']: - # We had too many timeouts already. Trigger a fatal_error. - # If error_limit is 0, the game will go on. + # Trigger a fatal_error. bot_reply = { - 'error': 'Timeout error', - 'error_msg': 'Too many timeouts' + 'error': 'TimeoutError', + 'error_msg': 'Timeout error' } - else: - # There was a timeout. Execute a random move - legal_positions = get_legal_positions(game_state["walls"], game_state["shape"], - game_state["bots"][game_state["turn"]]) - req_position = game_state['rng'].choice(legal_positions) - game_print(turn, f"Player timeout. Setting a legal position at random: {req_position}") - - bot_reply = { - 'move': req_position - } - timeout_event = { - 'type': 'timeout', - 'description': f"Player timeout. Setting a legal position at random: {req_position}" - } - game_state['timeouts'][team_idx][(round, turn)] = timeout_event duration = time.monotonic() - start_time @@ -736,7 +704,6 @@ def prepare_bot_state(game_state, team_idx=None): 'kills': game_state['kills'][own_team::2], 'deaths': game_state['deaths'][own_team::2], 'bot_was_killed': game_state['bot_was_killed'][own_team::2], - 'num_timeouts': len(game_state['timeouts'][own_team]), 'food': list(game_state['food'][own_team]), 'shaded_food': shaded_food, 'name': game_state['team_names'][own_team], @@ -751,7 +718,6 @@ def prepare_bot_state(game_state, team_idx=None): 'kills': game_state['kills'][enemy_team::2], 'deaths': game_state['deaths'][enemy_team::2], 'bot_was_killed': game_state['bot_was_killed'][enemy_team::2], - 'num_timeouts': 0, # TODO. Could be left out for the enemy 'food': list(game_state['food'][enemy_team]), 'shaded_food': [], 'name': game_state['team_names'][enemy_team], @@ -806,26 +772,6 @@ def prepare_viewer_state(game_state): viewer_state['food_age'] = [item for team_food_age in viewer_state['food_age'] for item in team_food_age.items()] - # game_state["timeouts"] has a tuple as a dict key - # that cannot be serialized in json. - # To fix this problem, we only send the current error - # and add another attribute "num_timeouts" - # to the final dict. - - # the key for the current round, turn - round_turn = (game_state["round"], game_state["turn"]) - viewer_state["timeouts"] = [ - # retrieve the current error or None - team_errors.get(round_turn) - for team_errors in game_state["timeouts"] - ] - - # add the number of errors - viewer_state["num_timeouts"] = [ - len(team_errors) - for team_errors in game_state["timeouts"] - ] - # remove unserializable values del viewer_state['teams'] del viewer_state['rng'] @@ -855,7 +801,6 @@ def play_turn(game_state, raise_bot_exceptions=False): game_state.update(next_round_turn(game_state)) turn = game_state['turn'] - round = game_state['round'] team = turn % 2 # update food age and relocate expired food for the current team @@ -907,7 +852,7 @@ def play_turn(game_state, raise_bot_exceptions=False): game_state = apply_move(game_state, position) # If there was no error, we claim a success in requested_moves - if (round, turn) not in game_state['timeouts'][team] and not game_state['fatal_errors'][team]: + if not game_state['fatal_errors'][team]: game_state['requested_moves'][turn]['success'] = True # Send updated game state with team names to the viewers From 7a2ceb80c0aad7cd6627d81c925f0402e6341720 Mon Sep 17 00:00:00 2001 From: Tiziano Zito Date: Wed, 1 Jul 2026 16:32:11 +0200 Subject: [PATCH 6/7] Remove the concept of non-fatal errors: CI engine --- contrib/ci_engine.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/contrib/ci_engine.py b/contrib/ci_engine.py index 7fc2d19a0..56d69446d 100755 --- a/contrib/ci_engine.py +++ b/contrib/ci_engine.py @@ -471,7 +471,6 @@ def pretty_print_results(self, full=False, team=None, highlight=None, html_expor table.add_column("# Losses") table.add_column("Score") table.add_column("ELO") - table.add_column("# Timeouts") table.add_column("# Fatal Errors") elo = dict(self.dbwrapper.get_elo()) @@ -669,7 +668,6 @@ def create_tables(self): ( id INTEGER PRIMARY KEY, player1 text, player2 text, result int, final_state text, - player1_num_timeouts int, player2_num_timeouts int, player1_had_fatal_error bool, player2_had_fatal_error bool, FOREIGN KEY(player1) REFERENCES players(name) ON DELETE CASCADE, FOREIGN KEY(player2) REFERENCES players(name) ON DELETE CASCADE) @@ -797,7 +795,6 @@ def add_gameresult(self, p1_name, p2_name, result, final_state, std, p1_out, p2_ return final_state_str = json.dumps(final_state) - player1_num_timeouts, player2_num_timeouts = final_state['num_timeouts'] player1_had_fatal_error = len(final_state['fatal_errors'][0]) != 0 player2_had_fatal_error = len(final_state['fatal_errors'][1]) != 0 @@ -805,12 +802,10 @@ def add_gameresult(self, p1_name, p2_name, result, final_state, std, p1_out, p2_ self.cursor.execute(""" INSERT INTO games (player1, player2, result, final_state, - player1_num_timeouts, player2_num_timeouts, player1_had_fatal_error, player2_had_fatal_error) - VALUES (?, ?, ?, ?, ?, ?, ?, ?) + VALUES (?, ?, ?, ?, ?, ?) RETURNING id """, [p1_name, p2_name, result, final_state_str, - player1_num_timeouts, player2_num_timeouts, player1_had_fatal_error, player2_had_fatal_error]) game_id, = self.cursor.fetchone() @@ -943,10 +938,9 @@ def get_errorcount(self, p1_name): error_count, fatalerror_count : errorcount """ self.cursor.execute(""" - SELECT sum(timeouts), sum(fatal_errors) FROM + SELECT sum(fatal_errors) FROM ( SELECT - sum(player1_num_timeouts) AS timeouts, sum(player1_had_fatal_error) AS fatal_errors FROM games WHERE player1 = :p1 @@ -954,16 +948,15 @@ def get_errorcount(self, p1_name): UNION ALL SELECT - sum(player2_num_timeouts) AS timeouts, sum(player2_had_fatal_error) AS fatal_errors FROM games WHERE player2 = :p1 ) """, dict(p1=p1_name)) - timeouts, fatal_errorcount = self.cursor.fetchone() + fatal_errorcount = self.cursor.fetchone() - return timeouts, fatal_errorcount + return fatal_errorcount def get_wins_losses(self, team=None): """ Get all wins and losses combined in a table of From f96e1ca7acfa76fe255fa2c38843386b8d556314 Mon Sep 17 00:00:00 2001 From: Tiziano Zito Date: Wed, 1 Jul 2026 16:32:31 +0200 Subject: [PATCH 7/7] Remove the concept of non-fatal errors: adapt all tests --- contrib/test_ci_engine.py | 2 +- test/fixtures/remote_timeout_red.py | 2 +- test/test_game.py | 67 ++++++++++------------------- test/test_network.py | 2 - test/test_players.py | 2 - test/test_remote_game.py | 27 +++++------- test/test_team.py | 10 +---- test/test_utils.py | 4 -- 8 files changed, 37 insertions(+), 79 deletions(-) diff --git a/contrib/test_ci_engine.py b/contrib/test_ci_engine.py index cc3939d0f..0e7223e2e 100644 --- a/contrib/test_ci_engine.py +++ b/contrib/test_ci_engine.py @@ -9,7 +9,7 @@ def db_wrapper(): return wrapper def make_simple_gameresult(p1, p2, result): - return [p1, p2, result, {'num_timeouts': [0, 0], 'fatal_errors': [[], []]}, ['', ''], ['', ''], ['', '']] + return [p1, p2, result, {'fatal_errors': [[], []]}, ['', ''], ['', ''], ['', '']] """Tests for the DB_Wrapper class.""" diff --git a/test/fixtures/remote_timeout_red.py b/test/fixtures/remote_timeout_red.py index 23f1a6615..6c9fe5fda 100644 --- a/test/fixtures/remote_timeout_red.py +++ b/test/fixtures/remote_timeout_red.py @@ -5,4 +5,4 @@ def move(b, s): if b.round == 2 and b.turn == 1: return (-2, 0) time.sleep(0.5) - return b.position \ No newline at end of file + return b.position diff --git a/test/test_game.py b/test/test_game.py index 68e22c706..c0c8fd4ae 100644 --- a/test/test_game.py +++ b/test/test_game.py @@ -753,7 +753,6 @@ def test_play_turn_move(): "kills":[0]*4, "deaths": [0]*4, "bot_was_killed": [False]*4, - "timeouts": [[], []], "fatal_errors": [{}, {}], "rng": Random(), "game_phase": "RUNNING", @@ -844,7 +843,6 @@ def test_last_round_check(max_rounds, current_round, turn, game_phase, gameover) 'turn': turn, 'error_limit': 5, 'fatal_errors': [[],[]], - 'timeouts': [[],[]], 'gameover': False, 'score': [0, 0], 'food': [{(1,1)}, {(1,1)}], # dummy food @@ -855,57 +853,38 @@ def test_last_round_check(max_rounds, current_round, turn, game_phase, gameover) @pytest.mark.parametrize( - 'team_errors, team_wins', [ - (((0, 0), (0, 0)), False), - (((0, 1), (0, 0)), False), - (((0, 0), (0, 1)), False), - (((0, 2), (0, 2)), False), - (((0, 4), (0, 0)), False), - (((0, 0), (0, 4)), False), - (((0, 4), (0, 4)), False), - (((0, 5), (0, 0)), 1), - (((0, 0), (0, 5)), 0), - (((0, 5), (0, 5)), 1), # earlier team fails first - (((1, 0), (0, 0)), 1), - (((0, 0), (1, 0)), 0), - (((1, 0), (1, 0)), 1), # earlier team fails first - (((1, 1), (1, 0)), 1), # earlier team fails first - (((1, 0), (0, 5)), 1), - (((0, 5), (1, 0)), 0), - ] + 'team_errors', [ + (0, 0, False), + (None, 0, 1), + (0, None, 0), + (None, None, 1), # earlier team fails first + (RemotePlayerRecvTimeout, 0, 1), + (0, RemotePlayerRecvTimeout, 0), + (RemotePlayerRecvTimeout, RemotePlayerRecvTimeout, 1), # earlier team fails first + ] ) -def test_error_finishes_game(team_errors, team_wins): +def test_error_finishes_game(team_errors): # the mapping is as follows: - # [(num_fatal_0, num_errors_0), (num_fatal_1, num_errors_1), result_flag] + # [fatal_0, fatal_1, result_flag] # the result flag: 0/1: team 0/1 wins, 2: draw, False: draw after 20 rounds - (fatal_0, timeouts_0), (fatal_1, timeouts_1) = team_errors + fatal_0, fatal_1, team_wins = team_errors def move0(b, s): - if not s: - s['count'] = 0 - s['count'] += 1 - - if s['count'] <= fatal_0: + if fatal_0 == 0: + return b.position + elif fatal_0 is None: return None - - if s['count'] <= timeouts_0: - raise RemotePlayerRecvTimeout - - return b.position + else: + raise fatal_0 def move1(b, s): - if not s: - s['count'] = 0 - s['count'] += 1 - - if s['count'] <= fatal_1: + if fatal_1 == 0: + return b.position + elif fatal_1 is None: return None - - if s['count'] <= timeouts_1: - raise RemotePlayerRecvTimeout - - return b.position + else: + raise fatal_1 l = maze_generator.generate_maze() state = game.setup_game([move0, move1], max_rounds=20, layout_dict=l) @@ -934,8 +913,6 @@ def apply_move_fn(move_fn, bot, state): assert res["whowins"] == 2 assert res["gameover"] is True assert state["round"] == 20 - assert len(state['timeouts'][0]) == timeouts_0 - assert len(state['timeouts'][1]) == timeouts_1 else: assert res["whowins"] == team_wins assert res["gameover"] is True diff --git a/test/test_network.py b/test/test_network.py index 83f71ff29..967c420b4 100644 --- a/test/test_network.py +++ b/test/test_network.py @@ -91,7 +91,6 @@ def stopping(bot, state): 'kills': [0]*2, 'deaths': [0]*2, 'bot_was_killed': [False]*2, - 'num_timeouts': 0, 'food': [(1, 1)], 'shaded_food': [(1, 1)], 'name': 'dummy', @@ -109,7 +108,6 @@ def stopping(bot, state): 'name': 'other dummy', 'team_time': 0, 'is_noisy': [False, False], - 'num_timeouts': 0 }, 'round': 1, 'bot_turn': 0, diff --git a/test/test_players.py b/test/test_players.py index 9b31b1928..c11c4f2c5 100644 --- a/test/test_players.py +++ b/test/test_players.py @@ -304,6 +304,4 @@ def test_players(player): assert state['gameover'] # ensure that all test players ran correctly assert state['fatal_errors'] == [[], []] - # our test players should never return invalid moves - assert state['timeouts'] == [{}, {}] diff --git a/test/test_remote_game.py b/test/test_remote_game.py index ac868e97c..2f599abdd 100644 --- a/test/test_remote_game.py +++ b/test/test_remote_game.py @@ -56,9 +56,6 @@ def test_remote_call_pelita(remote_teams): res, stdout, stderr = call_pelita(remote_teams, rounds=10, size='tiny', viewer='null', seed='2') assert res['whowins'] == 1 assert res['fatal_errors'] == [[], []] - # errors for call_pelita only contains the last thrown error, hence None - # TODO: should be aligned so that call_pelita and run_game return the same thing - assert res['timeouts'] == [None, None] def test_remote_run_game(remote_teams, dummy_layout_dict): @@ -67,7 +64,6 @@ def test_remote_run_game(remote_teams, dummy_layout_dict): state = pelita.game.run_game(remote_teams, max_rounds=30, layout_dict=dummy_layout_dict) assert state['whowins'] == 1 assert state['fatal_errors'] == [[], []] - assert state['timeouts'] == [{}, {}] def test_remote_timeout(dummy_layout_dict): @@ -82,19 +78,24 @@ def test_remote_timeout(dummy_layout_dict): state = pelita.game.run_game([str(blue), str(red)], max_rounds=8, layout_dict=dummy_layout_dict, - timeout_length=0.4) + timeout_length=0.7) assert state['whowins'] == 0 assert state['fatal_errors'][0] == [] assert state['fatal_errors'][1][0]['type'] == 'IllegalPosition' assert state['fatal_errors'][1][0]['turn'] == 3 assert state['fatal_errors'][1][0]['round'] == 2 - assert state['timeouts'][0] == {} - assert set(state['timeouts'][1].keys()) == {(1, 1), (1, 3), (2, 1)} - assert state['timeouts'][1][(1, 1)]['type'] == 'timeout' - assert state['timeouts'][1][(1, 3)]['type'] == 'timeout' - assert state['timeouts'][1][(2, 1)]['type'] == 'timeout' + state = pelita.game.run_game([str(blue), str(red)], + max_rounds=8, + layout_dict=dummy_layout_dict, + timeout_length=0.4) + + assert state['whowins'] == 0 + assert state['fatal_errors'][0] == [] + assert state['fatal_errors'][1][0]['type'] == 'TimeoutError' + assert state['fatal_errors'][1][0]['turn'] == 1 + assert state['fatal_errors'][1][0]['round'] == 1 def test_remote_dumps_are_written(dummy_layout_dict): @@ -111,7 +112,6 @@ def test_remote_dumps_are_written(dummy_layout_dict): assert state['whowins'] == 2 assert state['fatal_errors'] == [[], []] - assert state['timeouts'] == [{}, {}] path = Path(out_folder.name) blue_lines = (path / 'blue.out').read_text().split('\n') @@ -154,7 +154,6 @@ def test_remote_dumps_with_failure(failing_team, dummy_layout_dict): 'turn': fail_turn, 'round': 2} assert state['fatal_errors'][1 - failing_team] == [] - assert state['timeouts'] == [{}, {}] path = Path(out_folder.name) @@ -225,7 +224,6 @@ def test_remote_move_failures(player_name, is_setup_error, error_type, dummy_lay assert state['fatal_errors'][0][0]['turn'] == 0 assert state['fatal_errors'][0][0]['round'] is None assert state['fatal_errors'][1] == [] - assert state['timeouts'] == [{}, {}] else: state = pelita.game.run_game([str(failing_player), str(good_player)], @@ -239,7 +237,6 @@ def test_remote_move_failures(player_name, is_setup_error, error_type, dummy_lay assert state['fatal_errors'][0][0]['turn'] == 0 assert state['fatal_errors'][0][0]['round'] == 1 assert state['fatal_errors'][1] == [] - assert state['timeouts'] == [{}, {}] def test_cleanup_timeout(dummy_layout_dict): @@ -258,7 +255,6 @@ def test_cleanup_timeout(dummy_layout_dict): assert state['whowins'] == 2 assert state['game_phase'] == 'FINISHED' - assert state['timeouts'] == [{}, {}] # 1s is the current RemoteTeam.shutdown_timeout # 10s is the cleanup time in player_long_cleanup.py @@ -277,7 +273,6 @@ def test_remote_initial_timeout_zero(dummy_layout_dict): assert state['game_phase'] == 'FINISHED' assert state['whowins'] == 2 - assert state['timeouts'] == [{}, {}] state = pelita.game.run_game(teams, max_rounds=2, diff --git a/test/test_team.py b/test/test_team.py index f6a5edfa3..9afbaa356 100644 --- a/test/test_team.py +++ b/test/test_team.py @@ -435,7 +435,6 @@ def asserting_team(bot, state): state = run_game([asserting_team, asserting_team], max_rounds=1, layout_dict=parsed) # assertions might have been caught in run_game # check that all is good - assert state['timeouts'] == [{}, {}] assert state['fatal_errors'] == [[], []] def test_bot_graph(): @@ -465,7 +464,6 @@ def rough_bot(bot, state): state = run_game([rough_bot, stopping], max_rounds=1, layout_dict=parse_layout(layout)) # assertions might have been caught in run_game # check that all is good - assert state['timeouts'] == [{}, {}] assert state['fatal_errors'] == [[], []] def test_bot_graph_is_half_mutable(): @@ -508,7 +506,6 @@ def red(bot, state): state = run_game([blue, red], max_rounds=2, layout_dict=parse_layout(layout)) # assertions might have been caught in run_game # check that all is good - assert state['timeouts'] == [{}, {}] assert state['fatal_errors'] == [[], []] assert "".join(observer) == 'BRbrbrbr' @@ -544,12 +541,10 @@ def team_2(bot, state): state = play_turn(state) # check that player did not fail - assert state['timeouts'] == [{}, {}] assert state['fatal_errors'] == [[], []] state = play_turn(state) # check that player did not fail - assert state['timeouts'] == [{}, {}] assert state['fatal_errors'] == [[], []] @@ -644,7 +639,6 @@ def team_2(bot, state): assert check == old_time # check that player did not fail - assert state['timeouts'] == [{}, {}] assert state['fatal_errors'] == [[], []] assert state['team_time'][0] >= 1.0 assert state['team_time'][1] >= 2.0 @@ -656,10 +650,10 @@ def asserting_team(bot, state): bot_str = str(bot).split('\n') if bot.is_blue and bot.round == 1: assert bot_str[0] == "local-team (asserting_team) (you) vs local-team (asserting_team)." - assert bot_str[1] == f"Playing on blue side. Current turn: {bot.turn}. Bot: {bot.char}. Round: 1, score: 0:0. timeouts: 0:0" + assert bot_str[1] == f"Playing on blue side. Current turn: {bot.turn}. Bot: {bot.char}. Round: 1, score: 0:0." elif not bot.is_blue and bot.round == 1: assert bot_str[0] == "local-team (asserting_team) vs local-team (asserting_team) (you)." - assert bot_str[1] == f"Playing on red side. Current turn: {bot.turn}. Bot: {bot.char}. Round: 1, score: 0:0. timeouts: 0:0" + assert bot_str[1] == f"Playing on red side. Current turn: {bot.turn}. Bot: {bot.char}. Round: 1, score: 0:0." else: assert False, "Should never be here." diff --git a/test/test_utils.py b/test/test_utils.py index bf7a8f147..aace6adb3 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -100,8 +100,6 @@ def test_run_background_game(): 'red_bots': [(30, 2), (30, 1)], 'blue_score': 0, 'red_score': 0, - 'blue_errors': {}, - 'red_errors': {}, 'blue_deaths': [0, 0], 'red_deaths': [0, 0], 'blue_kills': [0, 0], @@ -132,8 +130,6 @@ def test_run_background_game_with_layout(): 'red_bots': [(16, 2), (16, 3)], 'blue_score': 0, 'red_score': 0, - 'blue_errors': {}, - 'red_errors': {}, 'blue_deaths': [0, 0], 'red_deaths': [0, 0], 'blue_kills': [0, 0],