PolyEnv¶
PolyEnv is an unofficial Polytopia-like game engine with a C++ core and Python bindings. It is intended for AI training, external bots, MCTS, and inspecting saved games.
The supported ruleset contains the 12 regular tribes. Aquarion, Elyrion, Polaris, and Cymanti are not supported.
Start Here¶
from PolyEnv import GameEnv, Bardur, Imperius, Lakes
env = GameEnv(seed=1234, map_size=11, players=(Bardur, Imperius), map_type=Lakes)
packet = env.model_request_numpy()
action_id = int(packet["actions"]["action_id"][0])
ok, done, reward, winner, current_player = env.step_fast(action_id)
Use only action ids returned in the current packet. The legal set changes after every step.
Important Concepts¶
| Need | API |
|---|---|
| Model input and legal actions | env.model_request_numpy() |
| Readable debug packet | env.model_request() |
| Player-view map | env.player_map_numpy() |
| Full ground-truth map | env.full_map_numpy() |
| Fast action execution | env.step_fast(action_id) |
| Batched high-throughput RL | VectorGameEnv(num_envs=...).step(action_ids) |
| Batched neural MCTS | MctsPool |
| Belief-MCTS self-play with external AI | SelfPlayPool |
| Perfect-information/debug branch | env.clone() |
| Fog-of-war MCTS rollout | env.make_belief_env(completed_map_tokens) |
| Portable replay | env.save(path) / env.load(path) |
The normal model and observation APIs expose only the current player's view.
full_map_numpy() is deliberately separate and is meant for debugging or
supervised hidden-map prediction.
Next Pages¶
- Installation
- Core Python API
- Model input and actions
- Maps and fog of war
- Hidden-map predictions
- Replays and GUI
- VectorGameEnv: Native Batched Training
- MctsPool: Native Batched PUCT
- SelfPlayPool: Native Belief-MCTS Self-Play
Attribution¶
Map generation is based on QuasiStellar/Polytopia-Map-Generator and was modified for PolyEnv.