cogames 0.3.49__py3-none-any.whl → 0.3.64__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cogames/cli/client.py +60 -6
- cogames/cli/docsync/__init__.py +0 -0
- cogames/cli/docsync/_nb_md_directive_processing.py +180 -0
- cogames/cli/docsync/_nb_md_sync.py +103 -0
- cogames/cli/docsync/_nb_py_sync.py +122 -0
- cogames/cli/docsync/_three_way_sync.py +115 -0
- cogames/cli/docsync/_utils.py +76 -0
- cogames/cli/docsync/docsync.py +156 -0
- cogames/cli/leaderboard.py +112 -28
- cogames/cli/mission.py +64 -53
- cogames/cli/policy.py +46 -10
- cogames/cli/submit.py +268 -67
- cogames/cogs_vs_clips/cog.py +79 -0
- cogames/cogs_vs_clips/cogs_vs_clips_mapgen.md +19 -16
- cogames/cogs_vs_clips/cogsguard_reward_variants.py +153 -0
- cogames/cogs_vs_clips/cogsguard_tutorial.py +56 -0
- cogames/cogs_vs_clips/evals/README.md +10 -16
- cogames/cogs_vs_clips/evals/cogsguard_evals.py +81 -0
- cogames/cogs_vs_clips/evals/diagnostic_evals.py +49 -444
- cogames/cogs_vs_clips/evals/difficulty_variants.py +13 -326
- cogames/cogs_vs_clips/evals/integrated_evals.py +5 -45
- cogames/cogs_vs_clips/evals/spanning_evals.py +9 -180
- cogames/cogs_vs_clips/mission.py +187 -146
- cogames/cogs_vs_clips/missions.py +46 -137
- cogames/cogs_vs_clips/procedural.py +8 -8
- cogames/cogs_vs_clips/sites.py +107 -3
- cogames/cogs_vs_clips/stations.py +198 -186
- cogames/cogs_vs_clips/tutorial_missions.py +1 -1
- cogames/cogs_vs_clips/variants.py +25 -476
- cogames/device.py +13 -1
- cogames/{policy/scripted_agent/README.md → docs/SCRIPTED_AGENT.md} +82 -58
- cogames/evaluate.py +18 -30
- cogames/main.py +1434 -243
- cogames/maps/canidate1_1000.map +1 -1
- cogames/maps/canidate1_1000_stations.map +2 -2
- cogames/maps/canidate1_500.map +1 -1
- cogames/maps/canidate1_500_stations.map +2 -2
- cogames/maps/canidate2_1000.map +1 -1
- cogames/maps/canidate2_1000_stations.map +2 -2
- cogames/maps/canidate2_500.map +1 -1
- cogames/maps/canidate2_500_stations.map +2 -2
- cogames/maps/canidate3_1000.map +1 -1
- cogames/maps/canidate3_1000_stations.map +2 -2
- cogames/maps/canidate3_500.map +1 -1
- cogames/maps/canidate3_500_stations.map +2 -2
- cogames/maps/canidate4_500.map +1 -1
- cogames/maps/canidate4_500_stations.map +2 -2
- cogames/maps/cave_base_50.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_agile.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_agile_hard.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_charge_up.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_charge_up_hard.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_chest_navigation1.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_chest_navigation1_hard.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_chest_navigation2.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_chest_navigation2_hard.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_chest_navigation3.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_chest_navigation3_hard.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_chest_near.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_chest_search.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_chest_search_hard.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_extract_lab.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_extract_lab_hard.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_memory.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_memory_hard.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_radial.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_radial_hard.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_resource_lab.map +2 -2
- cogames/maps/diagnostic_evals/diagnostic_unclip.map +2 -2
- cogames/maps/evals/eval_balanced_spread.map +9 -5
- cogames/maps/evals/eval_clip_oxygen.map +9 -5
- cogames/maps/evals/eval_collect_resources.map +9 -5
- cogames/maps/evals/eval_collect_resources_hard.map +9 -5
- cogames/maps/evals/eval_collect_resources_medium.map +9 -5
- cogames/maps/evals/eval_divide_and_conquer.map +9 -5
- cogames/maps/evals/eval_energy_starved.map +9 -5
- cogames/maps/evals/eval_multi_coordinated_collect_hard.map +9 -5
- cogames/maps/evals/eval_oxygen_bottleneck.map +9 -5
- cogames/maps/evals/eval_single_use_world.map +9 -5
- cogames/maps/evals/extractor_hub_100x100.map +9 -5
- cogames/maps/evals/extractor_hub_30x30.map +9 -5
- cogames/maps/evals/extractor_hub_50x50.map +9 -5
- cogames/maps/evals/extractor_hub_70x70.map +9 -5
- cogames/maps/evals/extractor_hub_80x80.map +9 -5
- cogames/maps/machina_100_stations.map +2 -2
- cogames/maps/machina_200_stations.map +2 -2
- cogames/maps/machina_200_stations_small.map +2 -2
- cogames/maps/machina_eval_exp01.map +2 -2
- cogames/maps/machina_eval_template_large.map +2 -2
- cogames/maps/machinatrainer4agents.map +2 -2
- cogames/maps/machinatrainer4agentsbase.map +2 -2
- cogames/maps/machinatrainerbig.map +2 -2
- cogames/maps/machinatrainersmall.map +2 -2
- cogames/maps/planky_evals/aligner_avoid_aoe.map +28 -0
- cogames/maps/planky_evals/aligner_full_cycle.map +28 -0
- cogames/maps/planky_evals/aligner_gear.map +24 -0
- cogames/maps/planky_evals/aligner_hearts.map +24 -0
- cogames/maps/planky_evals/aligner_junction.map +26 -0
- cogames/maps/planky_evals/exploration_distant.map +28 -0
- cogames/maps/planky_evals/maze.map +32 -0
- cogames/maps/planky_evals/miner_best_resource.map +26 -0
- cogames/maps/planky_evals/miner_deposit.map +24 -0
- cogames/maps/planky_evals/miner_extract.map +26 -0
- cogames/maps/planky_evals/miner_full_cycle.map +28 -0
- cogames/maps/planky_evals/miner_gear.map +24 -0
- cogames/maps/planky_evals/multi_role.map +28 -0
- cogames/maps/planky_evals/resource_chain.map +30 -0
- cogames/maps/planky_evals/scout_explore.map +32 -0
- cogames/maps/planky_evals/scout_gear.map +24 -0
- cogames/maps/planky_evals/scrambler_full_cycle.map +28 -0
- cogames/maps/planky_evals/scrambler_gear.map +24 -0
- cogames/maps/planky_evals/scrambler_target.map +26 -0
- cogames/maps/planky_evals/stuck_corridor.map +32 -0
- cogames/maps/planky_evals/survive_retreat.map +26 -0
- cogames/maps/training_facility_clipped.map +2 -2
- cogames/maps/training_facility_open_1.map +2 -2
- cogames/maps/training_facility_open_2.map +2 -2
- cogames/maps/training_facility_open_3.map +2 -2
- cogames/maps/training_facility_tight_4.map +2 -2
- cogames/maps/training_facility_tight_5.map +2 -2
- cogames/maps/vanilla_large.map +2 -2
- cogames/maps/vanilla_small.map +2 -2
- cogames/pickup.py +183 -0
- cogames/play.py +166 -33
- cogames/policy/chaos_monkey.py +54 -0
- cogames/policy/nim_agents/__init__.py +27 -10
- cogames/policy/nim_agents/agents.py +121 -60
- cogames/policy/nim_agents/thinky_eval.py +35 -222
- cogames/policy/pufferlib_policy.py +67 -32
- cogames/policy/starter_agent.py +184 -0
- cogames/policy/trainable_policy_template.py +4 -1
- cogames/train.py +51 -13
- cogames/verbose.py +2 -2
- cogames-0.3.64.dist-info/METADATA +1842 -0
- cogames-0.3.64.dist-info/RECORD +159 -0
- cogames-0.3.64.dist-info/licenses/LICENSE +21 -0
- cogames-0.3.64.dist-info/top_level.txt +2 -0
- metta_alo/__init__.py +0 -0
- metta_alo/job_specs.py +17 -0
- metta_alo/policy.py +16 -0
- metta_alo/pure_single_episode_runner.py +75 -0
- metta_alo/py.typed +0 -0
- metta_alo/rollout.py +322 -0
- metta_alo/scoring.py +168 -0
- cogames/maps/diagnostic_evals/diagnostic_assembler_near.map +0 -49
- cogames/maps/diagnostic_evals/diagnostic_assembler_search.map +0 -49
- cogames/maps/diagnostic_evals/diagnostic_assembler_search_hard.map +0 -89
- cogames/policy/nim_agents/common.nim +0 -887
- cogames/policy/nim_agents/install.sh +0 -1
- cogames/policy/nim_agents/ladybug_agent.nim +0 -984
- cogames/policy/nim_agents/nim_agents.nim +0 -55
- cogames/policy/nim_agents/nim_agents.nims +0 -14
- cogames/policy/nim_agents/nimby.lock +0 -3
- cogames/policy/nim_agents/racecar_agents.nim +0 -884
- cogames/policy/nim_agents/random_agents.nim +0 -68
- cogames/policy/nim_agents/test_agents.py +0 -53
- cogames/policy/nim_agents/thinky_agents.nim +0 -717
- cogames/policy/scripted_agent/baseline_agent.py +0 -1049
- cogames/policy/scripted_agent/demo_policy.py +0 -244
- cogames/policy/scripted_agent/pathfinding.py +0 -126
- cogames/policy/scripted_agent/starter_agent.py +0 -136
- cogames/policy/scripted_agent/types.py +0 -235
- cogames/policy/scripted_agent/unclipping_agent.py +0 -476
- cogames/policy/scripted_agent/utils.py +0 -385
- cogames-0.3.49.dist-info/METADATA +0 -406
- cogames-0.3.49.dist-info/RECORD +0 -136
- cogames-0.3.49.dist-info/top_level.txt +0 -1
- {cogames-0.3.49.dist-info → cogames-0.3.64.dist-info}/WHEEL +0 -0
- {cogames-0.3.49.dist-info → cogames-0.3.64.dist-info}/entry_points.txt +0 -0
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Data types and structures for scripted agents.
|
|
3
|
-
|
|
4
|
-
This module contains all the dataclasses, enums, and type definitions
|
|
5
|
-
used by the baseline and unclipping agents.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
from __future__ import annotations
|
|
9
|
-
|
|
10
|
-
from dataclasses import dataclass, field
|
|
11
|
-
from enum import Enum
|
|
12
|
-
from typing import Optional
|
|
13
|
-
|
|
14
|
-
from mettagrid.simulator import Action
|
|
15
|
-
from mettagrid.simulator.interface import AgentObservation
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@dataclass
|
|
19
|
-
class BaselineHyperparameters:
|
|
20
|
-
"""Hyperparameters controlling baseline agent behavior."""
|
|
21
|
-
|
|
22
|
-
# Energy management (recharge timing)
|
|
23
|
-
recharge_threshold_low: int = 35 # Enter RECHARGE phase when energy < this
|
|
24
|
-
recharge_threshold_high: int = 85 # Exit RECHARGE phase when energy >= this
|
|
25
|
-
|
|
26
|
-
# Stuck detection and escape
|
|
27
|
-
stuck_detection_enabled: bool = True # Enable loop detection
|
|
28
|
-
stuck_escape_distance: int = 12 # Minimum distance for escape target
|
|
29
|
-
|
|
30
|
-
# Exploration parameters
|
|
31
|
-
position_history_size: int = 30 # Size of position history buffer
|
|
32
|
-
exploration_area_check_window: int = 30 # Steps to check for stuck area
|
|
33
|
-
exploration_area_size_threshold: int = 7 # Max area size (height/width) to trigger escape
|
|
34
|
-
exploration_escape_duration: int = 10 # Steps to navigate to assembler when stuck
|
|
35
|
-
exploration_direction_persistence: int = 10 # Steps to persist in one direction
|
|
36
|
-
exploration_assembler_distance_threshold: int = 10 # Min distance from assembler to trigger escape
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
# Hyperparameter Presets for Ensemble Creation
|
|
40
|
-
BASELINE_HYPERPARAMETER_PRESETS = {
|
|
41
|
-
"default": BaselineHyperparameters(
|
|
42
|
-
recharge_threshold_low=35, # Moderate energy management
|
|
43
|
-
recharge_threshold_high=85,
|
|
44
|
-
stuck_detection_enabled=True,
|
|
45
|
-
stuck_escape_distance=12,
|
|
46
|
-
position_history_size=40, # Thorough exploration: longer history
|
|
47
|
-
exploration_area_check_window=35, # Thorough exploration: longer check window
|
|
48
|
-
exploration_area_size_threshold=9, # Thorough exploration: larger area tolerance
|
|
49
|
-
exploration_escape_duration=8, # Thorough exploration: shorter escape duration
|
|
50
|
-
exploration_direction_persistence=18, # Thorough exploration: longer persistence
|
|
51
|
-
exploration_assembler_distance_threshold=12, # Thorough exploration: larger distance threshold
|
|
52
|
-
),
|
|
53
|
-
"conservative": BaselineHyperparameters(
|
|
54
|
-
recharge_threshold_low=50, # Recharge early
|
|
55
|
-
recharge_threshold_high=95, # Stay charged
|
|
56
|
-
stuck_detection_enabled=True,
|
|
57
|
-
stuck_escape_distance=8, # Shorter escape distance
|
|
58
|
-
position_history_size=30,
|
|
59
|
-
exploration_area_check_window=30,
|
|
60
|
-
exploration_area_size_threshold=7,
|
|
61
|
-
exploration_escape_duration=10,
|
|
62
|
-
exploration_direction_persistence=10,
|
|
63
|
-
exploration_assembler_distance_threshold=10,
|
|
64
|
-
),
|
|
65
|
-
"aggressive": BaselineHyperparameters(
|
|
66
|
-
recharge_threshold_low=20, # Low energy tolerance
|
|
67
|
-
recharge_threshold_high=80, # Don't wait for full charge
|
|
68
|
-
stuck_detection_enabled=True,
|
|
69
|
-
stuck_escape_distance=15, # Longer escape distance
|
|
70
|
-
position_history_size=30,
|
|
71
|
-
exploration_area_check_window=30,
|
|
72
|
-
exploration_area_size_threshold=7,
|
|
73
|
-
exploration_escape_duration=10,
|
|
74
|
-
exploration_direction_persistence=10,
|
|
75
|
-
exploration_assembler_distance_threshold=10,
|
|
76
|
-
),
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
class CellType(Enum):
|
|
81
|
-
"""Occupancy map cell states."""
|
|
82
|
-
|
|
83
|
-
FREE = 1 # Passable (can walk through)
|
|
84
|
-
OBSTACLE = 2 # Impassable (walls, stations, extractors)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
class Phase(Enum):
|
|
88
|
-
"""Goal-driven phases for the baseline agent."""
|
|
89
|
-
|
|
90
|
-
GATHER = "gather" # Collect resources (explore if needed)
|
|
91
|
-
ASSEMBLE = "assemble" # Make hearts at assembler
|
|
92
|
-
DELIVER = "deliver" # Deposit hearts to chest
|
|
93
|
-
RECHARGE = "recharge" # Recharge energy at charger
|
|
94
|
-
CRAFT_UNCLIP = "craft_unclip" # Craft unclip items at assembler
|
|
95
|
-
UNCLIP = "unclip" # Unclip extractors
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
@dataclass
|
|
99
|
-
class ExtractorInfo:
|
|
100
|
-
"""Tracks a discovered extractor with full state."""
|
|
101
|
-
|
|
102
|
-
position: tuple[int, int]
|
|
103
|
-
resource_type: str # "carbon", "oxygen", "germanium", "silicon"
|
|
104
|
-
last_seen_step: int
|
|
105
|
-
times_used: int = 0
|
|
106
|
-
|
|
107
|
-
# Extractor state from observations
|
|
108
|
-
cooldown_remaining: int = 0 # Steps until ready
|
|
109
|
-
clipped: bool = False # Is it depleted?
|
|
110
|
-
remaining_uses: int = 999 # How many uses left
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
@dataclass
|
|
114
|
-
class ObjectState:
|
|
115
|
-
"""State of a single object at a position."""
|
|
116
|
-
|
|
117
|
-
name: str
|
|
118
|
-
|
|
119
|
-
# Extractor/station features
|
|
120
|
-
cooldown_remaining: int = 0
|
|
121
|
-
clipped: int = 0
|
|
122
|
-
remaining_uses: int = 999
|
|
123
|
-
|
|
124
|
-
# Protocol details (recipes for assemblers/extractors)
|
|
125
|
-
protocol_inputs: dict[str, int] = field(default_factory=dict)
|
|
126
|
-
protocol_outputs: dict[str, int] = field(default_factory=dict)
|
|
127
|
-
|
|
128
|
-
# Agent features (when object is another agent)
|
|
129
|
-
agent_id: int = -1 # Which agent (-1 if not an agent) - NOT in observations, kept for API
|
|
130
|
-
agent_group: int = -1 # Team/group
|
|
131
|
-
agent_frozen: int = 0 # Is frozen?
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
@dataclass
|
|
135
|
-
class ParsedObservation:
|
|
136
|
-
"""Parsed observation data in a clean format."""
|
|
137
|
-
|
|
138
|
-
# Agent state
|
|
139
|
-
row: int
|
|
140
|
-
col: int
|
|
141
|
-
energy: int
|
|
142
|
-
|
|
143
|
-
# Inventory
|
|
144
|
-
carbon: int
|
|
145
|
-
oxygen: int
|
|
146
|
-
germanium: int
|
|
147
|
-
silicon: int
|
|
148
|
-
hearts: int
|
|
149
|
-
decoder: int
|
|
150
|
-
modulator: int
|
|
151
|
-
resonator: int
|
|
152
|
-
scrambler: int
|
|
153
|
-
|
|
154
|
-
# Nearby objects with full state (position -> ObjectState)
|
|
155
|
-
nearby_objects: dict[tuple[int, int], ObjectState]
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
@dataclass
|
|
159
|
-
class SimpleAgentState:
|
|
160
|
-
"""State for a single agent."""
|
|
161
|
-
|
|
162
|
-
agent_id: int
|
|
163
|
-
|
|
164
|
-
phase: Phase = Phase.GATHER # Start gathering immediately
|
|
165
|
-
step_count: int = 0
|
|
166
|
-
|
|
167
|
-
# Current position (origin-relative, starting at (0, 0))
|
|
168
|
-
row: int = 0
|
|
169
|
-
col: int = 0
|
|
170
|
-
energy: int = 100
|
|
171
|
-
|
|
172
|
-
# Per-agent discovered extractors and stations (no shared state, each agent tracks independently)
|
|
173
|
-
extractors: dict[str, list[ExtractorInfo]] = field(
|
|
174
|
-
default_factory=lambda: {"carbon": [], "oxygen": [], "germanium": [], "silicon": []}
|
|
175
|
-
)
|
|
176
|
-
stations: dict[str, tuple[int, int] | None] = field(
|
|
177
|
-
default_factory=lambda: {"assembler": None, "chest": None, "charger": None}
|
|
178
|
-
)
|
|
179
|
-
|
|
180
|
-
# Inventory
|
|
181
|
-
carbon: int = 0
|
|
182
|
-
oxygen: int = 0
|
|
183
|
-
germanium: int = 0
|
|
184
|
-
silicon: int = 0
|
|
185
|
-
hearts: int = 0
|
|
186
|
-
decoder: int = 0
|
|
187
|
-
modulator: int = 0
|
|
188
|
-
resonator: int = 0
|
|
189
|
-
scrambler: int = 0
|
|
190
|
-
|
|
191
|
-
# Current target
|
|
192
|
-
target_position: Optional[tuple[int, int]] = None
|
|
193
|
-
target_resource: Optional[str] = None
|
|
194
|
-
|
|
195
|
-
# Map knowledge
|
|
196
|
-
map_height: int = 0
|
|
197
|
-
map_width: int = 0
|
|
198
|
-
occupancy: list[list[int]] = field(default_factory=list) # 1=free, 2=obstacle (initialized in reset)
|
|
199
|
-
|
|
200
|
-
# Track last action for position updates
|
|
201
|
-
last_action: Action = field(default_factory=lambda: Action(name="noop"))
|
|
202
|
-
|
|
203
|
-
# Current glyph (vibe) for interacting with assembler
|
|
204
|
-
current_glyph: str = "default"
|
|
205
|
-
|
|
206
|
-
# Discovered assembler recipe (dynamically discovered from observations)
|
|
207
|
-
heart_recipe: Optional[dict[str, int]] = None
|
|
208
|
-
|
|
209
|
-
# Extractor activation state
|
|
210
|
-
waiting_at_extractor: Optional[tuple[int, int]] = None
|
|
211
|
-
wait_steps: int = 0
|
|
212
|
-
pending_use_resource: Optional[str] = None
|
|
213
|
-
pending_use_amount: int = 0
|
|
214
|
-
|
|
215
|
-
# Directional exploration state
|
|
216
|
-
exploration_target: Optional[str] = None # Current direction ("north", "south", "east", "west")
|
|
217
|
-
exploration_target_step: int = 0 # When we set the direction
|
|
218
|
-
exploration_escape_until_step: int = 0 # If > 0, we're in escape mode until this step
|
|
219
|
-
|
|
220
|
-
# Agent positions (for collision detection)
|
|
221
|
-
agent_occupancy: set[tuple[int, int]] = field(default_factory=set)
|
|
222
|
-
|
|
223
|
-
# Stuck detection
|
|
224
|
-
position_history: list[tuple[int, int]] = field(default_factory=list) # Last 30 positions
|
|
225
|
-
stuck_loop_detected: bool = False
|
|
226
|
-
stuck_escape_step: int = 0
|
|
227
|
-
|
|
228
|
-
# Path caching for efficient navigation (per-agent)
|
|
229
|
-
cached_path: Optional[list[tuple[int, int]]] = None
|
|
230
|
-
cached_path_target: Optional[tuple[int, int]] = None
|
|
231
|
-
cached_path_reach_adjacent: bool = False
|
|
232
|
-
using_object_this_step: bool = False # Flag to prevent position update when using objects
|
|
233
|
-
|
|
234
|
-
# Current observation (for collision detection and state updates)
|
|
235
|
-
current_obs: Optional[AgentObservation] = None
|