games: add pursuit-evasion game (2-player zero-sum, continuous 2D space) - #1553
games: add pursuit-evasion game (2-player zero-sum, continuous 2D space)#1553aeyjeyaryan wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
14c084c to
861319b
Compare
861319b to
e91503a
Compare
|
@aeyjeyaryan could you add the game to the games list? (in |
29af2e0 to
f4f282d
Compare
| """Pursuit-evasion game in 2D continuous space. | ||
|
|
||
| A 2-player zero-sum game where a pursuer (Player 0) attempts to capture an | ||
| evader (Player 1) within a bounded 2D grid. The evader follows one of four |
There was a problem hiding this comment.
Since the game takes place in a continuous space and the players don't snap to discrete cells, consider changing "grid" to "box" or "space" to avoid confusion.
There was a problem hiding this comment.
Similarly elsewhere in the file (grid_size_ should be renamed)
| class PursuitEvasionGame(pyspiel.Game): | ||
| """2-player zero-sum pursuit-evasion game in continuous 2D space. | ||
|
|
||
| The pursuer (Player 0) takes discrete directional actions each turn. The |
There was a problem hiding this comment.
Hardcoding the opponent's strategy into the game state and hiding stochasticity behind a dummy action breaks OpenSpiel's tree-search assumptions.
Because _EVADER_RANDOM uses self._rng, applying action 0 is stochastic. In OpenSpiel, stochastic transitions should be explicitly modeled as chance nodes so search algorithms can branch correctly. Furthermore, without a custom clone() method, duplicating this state in a search tree will share the same RNG object or fail to copy it correctly.
If this is meant to be a 2-player game, consider exposing the 9 actions to Player 1 and moving these hardcoded strategies (random, zigzag, etc.) into external pyspiel.Bot implementations. If it's meant to be a 1-player environment against a fixed behavior, Player 1's turn should be formally implemented as a chance node.
There was a problem hiding this comment.
Thanks for the feedback, Marc! I've addressed both points in the most recent push.
d909843 to
7ec847b
Compare
| self._is_chance = False | ||
| self._is_terminal = False | ||
| self.pursuer_reward = 0.0 | ||
| self._rng = np.random.RandomState(game.seed) |
There was a problem hiding this comment.
There should be no random number generator in the state or the game. All randomness should be controlled externally and change events handelled by chance nodes.
There was a problem hiding this comment.
Seems to no longer be used, right? Please remove.
| each pursuer action the evader moves via a chance node whose probability | ||
| distribution is determined by the ``evader_strategy`` parameter. The game | ||
| ends when the pursuer captures the evader (distance < capture_radius) or | ||
| after ``max_steps`` rounds. |
There was a problem hiding this comment.
I don't understand this.
First: why make this a single-player game instead of a two-player game?
Second: in the case where it is a single player game, then bots should not be acting at chance nodes (i.e. see the test where several different types of evaders are tested). Chance nodes have fixed distributions: you should only sample from their (categorical) distribution.
I think the better choice here is keep the evader bots and make it proper two-player game. Then use the bots when it's the evader's turn.
There was a problem hiding this comment.
Thanks for the clear direction, addressed all three points in the recent push!
7ec847b to
e8bd22c
Compare
This PR adds a new Python game,
python_pursuit_evasion, to address issue #843 (Call for New Games).Game overview
A 2-player zero-sum pursuit-evasion game in bounded 2D continuous space:
capture_radius(default 1.0).max_stepsrounds, −1 otherwise (zero-sum).grid_size(default 10.0),max_steps(default 50),capture_radius(default 1.0),evader_strategy(0–3).Evader strategies
Implementation details
pyspiel.Game,pyspiel.State, observer class, registration).[pursuer_x/grid_size, pursuer_y/grid_size, evader_x/grid_size, evader_y/grid_size, step/max_steps].Tests
12 tests covering API conformance (
pyspiel.random_sim_test), all 4 evader strategies, both terminal conditions, legal action counts, zero-sum property, observation tensor shape/range, and deterministic replay.Additional context
This game accompanies a research paper comparing NEAT and PPO under non-stationary opponent strategies (IEEE Access, under submission). The adaptive evader strategy shifts the evasion policy during an episode, creating a non-stationary environment where population-based methods (NEAT) outperform gradient-based methods (PPO). The game is designed for use with OpenSpiel's Python algorithms and can serve as a benchmark for multi-agent RL under strategy distribution shifts.