Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6a8b9b6
ENH: Add default_zmq_context
Debilski Jan 29, 2025
81006a4
BF: Do not crash tk when no team name is passed
Debilski Jun 9, 2025
8646bf7
BF: Keyboard interrupt should not cause a freeze
Debilski Jun 6, 2025
05aec98
ENH: Better bot repr
Debilski Jun 20, 2025
bba5358
RF: New network/subprocess protocol
Debilski Jun 20, 2025
037f20f
BF: Fix remote test
Debilski Jun 20, 2025
7397f86
RF: New error handling mechanism, errors renamed to timeouts
Debilski Jun 22, 2025
c949728
BF: Playing with bad rounds or no food should trigger FAILURE
Debilski Jun 22, 2025
19bf9c1
RF: Use game_phase in prepare_bot_state
Debilski Jun 22, 2025
ed66c4a
RF: Rename allow_exceptions → raise_bot_exceptions
Debilski Jun 22, 2025
1c523b4
ENH: When a UI controller exits in init, we go into failure mode
Debilski Jun 22, 2025
289a2b8
ENH: Rename Errors to Timeouts in Tk
Debilski Jun 23, 2025
5157fb7
RF: Remove timeout handling from apply_move
Debilski Jun 23, 2025
c57f72b
RF: Use more game_phases
Debilski Jun 23, 2025
f4b557e
BF: Fix timeout counting
Debilski Jul 2, 2025
78375e4
TST: Test that long team names are detected
Debilski Jul 3, 2025
cf17dbe
UI: Show failure
Debilski Jul 3, 2025
b42f710
RF: Cleanup superfluous functions
Debilski Jul 3, 2025
0f7cbcc
RF: Raise (if needed) from add_fatal_error
Debilski Jul 3, 2025
1941050
RF: Print the error before potential exceptions are raised
Debilski Jul 3, 2025
ac9ad35
TST: Add network protocol test
Debilski Jul 30, 2025
e7e3dec
ENH: Add 60*60 second timeout to pelita_player
Debilski Jul 30, 2025
6925dc0
ENH: Reorganise remote Team classes
Debilski Jul 30, 2025
4595c22
ENH: Remove xfail
Debilski Aug 26, 2025
a26625c
TST: Add test for --no-timeout cli option
Debilski Aug 26, 2025
0455642
BF: Fix --no-timeout
Debilski Aug 26, 2025
d4ce537
BF: Fix default_zmq_context
Debilski Aug 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pelita/base_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from random import Random

import zmq

def default_rng(seed=None):
"""Construct a new RNG from a given seed or return the same RNG.
Expand All @@ -12,3 +13,6 @@ def default_rng(seed=None):
if isinstance(seed, Random):
return seed
return Random(seed)

def default_zmq_context(zmq_context=None):
return zmq.Context()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean this?

def default_zmq_context(zmq_context=None):
    return zmq_context or zmq.Context()

12 changes: 5 additions & 7 deletions pelita/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import zmq

from .base_utils import default_zmq_context

_logger = logging.getLogger(__name__)

# 41736 is the word PELI(T)A when read upside down in reverse without glasses
Expand Down Expand Up @@ -305,10 +307,8 @@ def show_state(self, game_state):
class Controller:
def __init__(self, address='tcp://127.0.0.1', zmq_context=None):
self.address = address
if zmq_context:
self.context = zmq_context
else:
self.context = zmq.Context()
self.context = default_zmq_context(zmq_context)

# We use a ROUTER which we bind.
# This means other DEALERs can connect and
# each one can take over control.
Expand Down Expand Up @@ -363,8 +363,6 @@ def recv_start(self, timeout=None):


def setup_controller(zmq_context=None):
if not zmq_context:
import zmq
zmq_context = zmq.Context()
zmq_context = default_zmq_context(zmq_context)
controller = Controller(zmq_context=zmq_context)
return controller
7 changes: 3 additions & 4 deletions pelita/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import zmq

from . import layout
from .base_utils import default_zmq_context
from .exceptions import PlayerDisconnected, PlayerTimeout
from .layout import BOT_I2N, layout_as_str, wall_dimensions
from .network import (PELITA_PORT, ZMQClientError, ZMQConnection,
Expand Down Expand Up @@ -308,8 +309,7 @@ class RemoteTeam:
the remote clients will be suppressed.
"""
def __init__(self, team_spec, *, team_name=None, zmq_context=None, idx=None, store_output=False):
if zmq_context is None:
zmq_context = zmq.Context()
zmq_context = default_zmq_context(zmq_context)

self._team_spec = team_spec
self._team_name = team_name
Expand Down Expand Up @@ -535,8 +535,7 @@ def make_team(team_spec, team_name=None, zmq_context=None, idx=None, store_outpu
elif isinstance(team_spec, str):
_logger.info("Making a remote team for %s", team_spec)
# set up the zmq connections and build a RemoteTeam
if not zmq_context:
zmq_context = zmq.Context()
zmq_context = default_zmq_context(zmq_context)
team_player = RemoteTeam(team_spec=team_spec, zmq_context=zmq_context, idx=idx, store_output=store_output)
else:
raise TypeError(f"Not possible to create team from {team_spec} (wrong type).")
Expand Down