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.
Files changed (169) hide show
  1. cogames/cli/client.py +60 -6
  2. cogames/cli/docsync/__init__.py +0 -0
  3. cogames/cli/docsync/_nb_md_directive_processing.py +180 -0
  4. cogames/cli/docsync/_nb_md_sync.py +103 -0
  5. cogames/cli/docsync/_nb_py_sync.py +122 -0
  6. cogames/cli/docsync/_three_way_sync.py +115 -0
  7. cogames/cli/docsync/_utils.py +76 -0
  8. cogames/cli/docsync/docsync.py +156 -0
  9. cogames/cli/leaderboard.py +112 -28
  10. cogames/cli/mission.py +64 -53
  11. cogames/cli/policy.py +46 -10
  12. cogames/cli/submit.py +268 -67
  13. cogames/cogs_vs_clips/cog.py +79 -0
  14. cogames/cogs_vs_clips/cogs_vs_clips_mapgen.md +19 -16
  15. cogames/cogs_vs_clips/cogsguard_reward_variants.py +153 -0
  16. cogames/cogs_vs_clips/cogsguard_tutorial.py +56 -0
  17. cogames/cogs_vs_clips/evals/README.md +10 -16
  18. cogames/cogs_vs_clips/evals/cogsguard_evals.py +81 -0
  19. cogames/cogs_vs_clips/evals/diagnostic_evals.py +49 -444
  20. cogames/cogs_vs_clips/evals/difficulty_variants.py +13 -326
  21. cogames/cogs_vs_clips/evals/integrated_evals.py +5 -45
  22. cogames/cogs_vs_clips/evals/spanning_evals.py +9 -180
  23. cogames/cogs_vs_clips/mission.py +187 -146
  24. cogames/cogs_vs_clips/missions.py +46 -137
  25. cogames/cogs_vs_clips/procedural.py +8 -8
  26. cogames/cogs_vs_clips/sites.py +107 -3
  27. cogames/cogs_vs_clips/stations.py +198 -186
  28. cogames/cogs_vs_clips/tutorial_missions.py +1 -1
  29. cogames/cogs_vs_clips/variants.py +25 -476
  30. cogames/device.py +13 -1
  31. cogames/{policy/scripted_agent/README.md → docs/SCRIPTED_AGENT.md} +82 -58
  32. cogames/evaluate.py +18 -30
  33. cogames/main.py +1434 -243
  34. cogames/maps/canidate1_1000.map +1 -1
  35. cogames/maps/canidate1_1000_stations.map +2 -2
  36. cogames/maps/canidate1_500.map +1 -1
  37. cogames/maps/canidate1_500_stations.map +2 -2
  38. cogames/maps/canidate2_1000.map +1 -1
  39. cogames/maps/canidate2_1000_stations.map +2 -2
  40. cogames/maps/canidate2_500.map +1 -1
  41. cogames/maps/canidate2_500_stations.map +2 -2
  42. cogames/maps/canidate3_1000.map +1 -1
  43. cogames/maps/canidate3_1000_stations.map +2 -2
  44. cogames/maps/canidate3_500.map +1 -1
  45. cogames/maps/canidate3_500_stations.map +2 -2
  46. cogames/maps/canidate4_500.map +1 -1
  47. cogames/maps/canidate4_500_stations.map +2 -2
  48. cogames/maps/cave_base_50.map +2 -2
  49. cogames/maps/diagnostic_evals/diagnostic_agile.map +2 -2
  50. cogames/maps/diagnostic_evals/diagnostic_agile_hard.map +2 -2
  51. cogames/maps/diagnostic_evals/diagnostic_charge_up.map +2 -2
  52. cogames/maps/diagnostic_evals/diagnostic_charge_up_hard.map +2 -2
  53. cogames/maps/diagnostic_evals/diagnostic_chest_navigation1.map +2 -2
  54. cogames/maps/diagnostic_evals/diagnostic_chest_navigation1_hard.map +2 -2
  55. cogames/maps/diagnostic_evals/diagnostic_chest_navigation2.map +2 -2
  56. cogames/maps/diagnostic_evals/diagnostic_chest_navigation2_hard.map +2 -2
  57. cogames/maps/diagnostic_evals/diagnostic_chest_navigation3.map +2 -2
  58. cogames/maps/diagnostic_evals/diagnostic_chest_navigation3_hard.map +2 -2
  59. cogames/maps/diagnostic_evals/diagnostic_chest_near.map +2 -2
  60. cogames/maps/diagnostic_evals/diagnostic_chest_search.map +2 -2
  61. cogames/maps/diagnostic_evals/diagnostic_chest_search_hard.map +2 -2
  62. cogames/maps/diagnostic_evals/diagnostic_extract_lab.map +2 -2
  63. cogames/maps/diagnostic_evals/diagnostic_extract_lab_hard.map +2 -2
  64. cogames/maps/diagnostic_evals/diagnostic_memory.map +2 -2
  65. cogames/maps/diagnostic_evals/diagnostic_memory_hard.map +2 -2
  66. cogames/maps/diagnostic_evals/diagnostic_radial.map +2 -2
  67. cogames/maps/diagnostic_evals/diagnostic_radial_hard.map +2 -2
  68. cogames/maps/diagnostic_evals/diagnostic_resource_lab.map +2 -2
  69. cogames/maps/diagnostic_evals/diagnostic_unclip.map +2 -2
  70. cogames/maps/evals/eval_balanced_spread.map +9 -5
  71. cogames/maps/evals/eval_clip_oxygen.map +9 -5
  72. cogames/maps/evals/eval_collect_resources.map +9 -5
  73. cogames/maps/evals/eval_collect_resources_hard.map +9 -5
  74. cogames/maps/evals/eval_collect_resources_medium.map +9 -5
  75. cogames/maps/evals/eval_divide_and_conquer.map +9 -5
  76. cogames/maps/evals/eval_energy_starved.map +9 -5
  77. cogames/maps/evals/eval_multi_coordinated_collect_hard.map +9 -5
  78. cogames/maps/evals/eval_oxygen_bottleneck.map +9 -5
  79. cogames/maps/evals/eval_single_use_world.map +9 -5
  80. cogames/maps/evals/extractor_hub_100x100.map +9 -5
  81. cogames/maps/evals/extractor_hub_30x30.map +9 -5
  82. cogames/maps/evals/extractor_hub_50x50.map +9 -5
  83. cogames/maps/evals/extractor_hub_70x70.map +9 -5
  84. cogames/maps/evals/extractor_hub_80x80.map +9 -5
  85. cogames/maps/machina_100_stations.map +2 -2
  86. cogames/maps/machina_200_stations.map +2 -2
  87. cogames/maps/machina_200_stations_small.map +2 -2
  88. cogames/maps/machina_eval_exp01.map +2 -2
  89. cogames/maps/machina_eval_template_large.map +2 -2
  90. cogames/maps/machinatrainer4agents.map +2 -2
  91. cogames/maps/machinatrainer4agentsbase.map +2 -2
  92. cogames/maps/machinatrainerbig.map +2 -2
  93. cogames/maps/machinatrainersmall.map +2 -2
  94. cogames/maps/planky_evals/aligner_avoid_aoe.map +28 -0
  95. cogames/maps/planky_evals/aligner_full_cycle.map +28 -0
  96. cogames/maps/planky_evals/aligner_gear.map +24 -0
  97. cogames/maps/planky_evals/aligner_hearts.map +24 -0
  98. cogames/maps/planky_evals/aligner_junction.map +26 -0
  99. cogames/maps/planky_evals/exploration_distant.map +28 -0
  100. cogames/maps/planky_evals/maze.map +32 -0
  101. cogames/maps/planky_evals/miner_best_resource.map +26 -0
  102. cogames/maps/planky_evals/miner_deposit.map +24 -0
  103. cogames/maps/planky_evals/miner_extract.map +26 -0
  104. cogames/maps/planky_evals/miner_full_cycle.map +28 -0
  105. cogames/maps/planky_evals/miner_gear.map +24 -0
  106. cogames/maps/planky_evals/multi_role.map +28 -0
  107. cogames/maps/planky_evals/resource_chain.map +30 -0
  108. cogames/maps/planky_evals/scout_explore.map +32 -0
  109. cogames/maps/planky_evals/scout_gear.map +24 -0
  110. cogames/maps/planky_evals/scrambler_full_cycle.map +28 -0
  111. cogames/maps/planky_evals/scrambler_gear.map +24 -0
  112. cogames/maps/planky_evals/scrambler_target.map +26 -0
  113. cogames/maps/planky_evals/stuck_corridor.map +32 -0
  114. cogames/maps/planky_evals/survive_retreat.map +26 -0
  115. cogames/maps/training_facility_clipped.map +2 -2
  116. cogames/maps/training_facility_open_1.map +2 -2
  117. cogames/maps/training_facility_open_2.map +2 -2
  118. cogames/maps/training_facility_open_3.map +2 -2
  119. cogames/maps/training_facility_tight_4.map +2 -2
  120. cogames/maps/training_facility_tight_5.map +2 -2
  121. cogames/maps/vanilla_large.map +2 -2
  122. cogames/maps/vanilla_small.map +2 -2
  123. cogames/pickup.py +183 -0
  124. cogames/play.py +166 -33
  125. cogames/policy/chaos_monkey.py +54 -0
  126. cogames/policy/nim_agents/__init__.py +27 -10
  127. cogames/policy/nim_agents/agents.py +121 -60
  128. cogames/policy/nim_agents/thinky_eval.py +35 -222
  129. cogames/policy/pufferlib_policy.py +67 -32
  130. cogames/policy/starter_agent.py +184 -0
  131. cogames/policy/trainable_policy_template.py +4 -1
  132. cogames/train.py +51 -13
  133. cogames/verbose.py +2 -2
  134. cogames-0.3.64.dist-info/METADATA +1842 -0
  135. cogames-0.3.64.dist-info/RECORD +159 -0
  136. cogames-0.3.64.dist-info/licenses/LICENSE +21 -0
  137. cogames-0.3.64.dist-info/top_level.txt +2 -0
  138. metta_alo/__init__.py +0 -0
  139. metta_alo/job_specs.py +17 -0
  140. metta_alo/policy.py +16 -0
  141. metta_alo/pure_single_episode_runner.py +75 -0
  142. metta_alo/py.typed +0 -0
  143. metta_alo/rollout.py +322 -0
  144. metta_alo/scoring.py +168 -0
  145. cogames/maps/diagnostic_evals/diagnostic_assembler_near.map +0 -49
  146. cogames/maps/diagnostic_evals/diagnostic_assembler_search.map +0 -49
  147. cogames/maps/diagnostic_evals/diagnostic_assembler_search_hard.map +0 -89
  148. cogames/policy/nim_agents/common.nim +0 -887
  149. cogames/policy/nim_agents/install.sh +0 -1
  150. cogames/policy/nim_agents/ladybug_agent.nim +0 -984
  151. cogames/policy/nim_agents/nim_agents.nim +0 -55
  152. cogames/policy/nim_agents/nim_agents.nims +0 -14
  153. cogames/policy/nim_agents/nimby.lock +0 -3
  154. cogames/policy/nim_agents/racecar_agents.nim +0 -884
  155. cogames/policy/nim_agents/random_agents.nim +0 -68
  156. cogames/policy/nim_agents/test_agents.py +0 -53
  157. cogames/policy/nim_agents/thinky_agents.nim +0 -717
  158. cogames/policy/scripted_agent/baseline_agent.py +0 -1049
  159. cogames/policy/scripted_agent/demo_policy.py +0 -244
  160. cogames/policy/scripted_agent/pathfinding.py +0 -126
  161. cogames/policy/scripted_agent/starter_agent.py +0 -136
  162. cogames/policy/scripted_agent/types.py +0 -235
  163. cogames/policy/scripted_agent/unclipping_agent.py +0 -476
  164. cogames/policy/scripted_agent/utils.py +0 -385
  165. cogames-0.3.49.dist-info/METADATA +0 -406
  166. cogames-0.3.49.dist-info/RECORD +0 -136
  167. cogames-0.3.49.dist-info/top_level.txt +0 -1
  168. {cogames-0.3.49.dist-info → cogames-0.3.64.dist-info}/WHEEL +0 -0
  169. {cogames-0.3.49.dist-info → cogames-0.3.64.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,24 @@
1
+ type: mettagrid.map_builder.ascii.AsciiMapBuilder.Config
2
+ map_data: |-
3
+ ###########
4
+ #.........#
5
+ #..@......#
6
+ #.........#
7
+ #..M..&...#
8
+ #.........#
9
+ ###########
10
+ char_to_map_name:
11
+ "#": wall
12
+ ".": empty
13
+ "@": agent.agent
14
+ "M": miner_station
15
+ "S": scout_station
16
+ "A": aligner_station
17
+ "X": scrambler_station
18
+ "C": carbon_extractor
19
+ "O": oxygen_extractor
20
+ "G": germanium_extractor
21
+ "I": silicon_extractor
22
+ "J": junction
23
+ "&": hub
24
+ "=": chest
@@ -0,0 +1,26 @@
1
+ type: mettagrid.map_builder.ascii.AsciiMapBuilder.Config
2
+ map_data: |-
3
+ #########
4
+ #.......#
5
+ #..@....#
6
+ #.......#
7
+ #..M....#
8
+ #.......#
9
+ #..C....#
10
+ #.......#
11
+ #########
12
+ char_to_map_name:
13
+ "#": wall
14
+ ".": empty
15
+ "@": agent.agent
16
+ "M": miner_station
17
+ "S": scout_station
18
+ "A": aligner_station
19
+ "X": scrambler_station
20
+ "C": carbon_extractor
21
+ "O": oxygen_extractor
22
+ "G": germanium_extractor
23
+ "I": silicon_extractor
24
+ "J": junction
25
+ "&": hub
26
+ "=": chest
@@ -0,0 +1,28 @@
1
+ type: mettagrid.map_builder.ascii.AsciiMapBuilder.Config
2
+ map_data: |-
3
+ #############
4
+ #...........#
5
+ #..@........#
6
+ #...........#
7
+ #..M........#
8
+ #...........#
9
+ #..C........#
10
+ #...........#
11
+ #..&........#
12
+ #...........#
13
+ #############
14
+ char_to_map_name:
15
+ "#": wall
16
+ ".": empty
17
+ "@": agent.agent
18
+ "M": miner_station
19
+ "S": scout_station
20
+ "A": aligner_station
21
+ "X": scrambler_station
22
+ "C": carbon_extractor
23
+ "O": oxygen_extractor
24
+ "G": germanium_extractor
25
+ "I": silicon_extractor
26
+ "J": junction
27
+ "&": hub
28
+ "=": chest
@@ -0,0 +1,24 @@
1
+ type: mettagrid.map_builder.ascii.AsciiMapBuilder.Config
2
+ map_data: |-
3
+ #######
4
+ #.....#
5
+ #..@..#
6
+ #.....#
7
+ #..M..#
8
+ #.....#
9
+ #######
10
+ char_to_map_name:
11
+ "#": wall
12
+ ".": empty
13
+ "@": agent.agent
14
+ "M": miner_station
15
+ "S": scout_station
16
+ "A": aligner_station
17
+ "X": scrambler_station
18
+ "C": carbon_extractor
19
+ "O": oxygen_extractor
20
+ "G": germanium_extractor
21
+ "I": silicon_extractor
22
+ "J": junction
23
+ "&": hub
24
+ "=": chest
@@ -0,0 +1,28 @@
1
+ type: mettagrid.map_builder.ascii.AsciiMapBuilder.Config
2
+ map_data: |-
3
+ #################
4
+ #...............#
5
+ #..@.@.@.@......#
6
+ #...............#
7
+ #..M..S..A..X...#
8
+ #...............#
9
+ #..C..=..J..&...#
10
+ #...............#
11
+ #...............#
12
+ #...............#
13
+ #################
14
+ char_to_map_name:
15
+ "#": wall
16
+ ".": empty
17
+ "@": agent.agent
18
+ "M": miner_station
19
+ "S": scout_station
20
+ "A": aligner_station
21
+ "X": scrambler_station
22
+ "C": carbon_extractor
23
+ "O": oxygen_extractor
24
+ "G": germanium_extractor
25
+ "I": silicon_extractor
26
+ "J": junction
27
+ "&": hub
28
+ "=": chest
@@ -0,0 +1,30 @@
1
+ type: mettagrid.map_builder.ascii.AsciiMapBuilder.Config
2
+ map_data: |-
3
+ ###############
4
+ #.............#
5
+ #..@..........#
6
+ #.............#
7
+ #..M..........#
8
+ #.............#
9
+ #..C..O.......#
10
+ #.............#
11
+ #..G..I.......#
12
+ #.............#
13
+ #..&..........#
14
+ #.............#
15
+ ###############
16
+ char_to_map_name:
17
+ "#": wall
18
+ ".": empty
19
+ "@": agent.agent
20
+ "M": miner_station
21
+ "S": scout_station
22
+ "A": aligner_station
23
+ "X": scrambler_station
24
+ "C": carbon_extractor
25
+ "O": oxygen_extractor
26
+ "G": germanium_extractor
27
+ "I": silicon_extractor
28
+ "J": junction
29
+ "&": hub
30
+ "=": chest
@@ -0,0 +1,32 @@
1
+ type: mettagrid.map_builder.ascii.AsciiMapBuilder.Config
2
+ map_data: |-
3
+ ###############
4
+ #.............#
5
+ #.............#
6
+ #.............#
7
+ #.............#
8
+ #.............#
9
+ #.............#
10
+ #..@..........#
11
+ #.............#
12
+ #..S..........#
13
+ #.............#
14
+ #.............#
15
+ #.............#
16
+ #.............#
17
+ ###############
18
+ char_to_map_name:
19
+ "#": wall
20
+ ".": empty
21
+ "@": agent.agent
22
+ "M": miner_station
23
+ "S": scout_station
24
+ "A": aligner_station
25
+ "X": scrambler_station
26
+ "C": carbon_extractor
27
+ "O": oxygen_extractor
28
+ "G": germanium_extractor
29
+ "I": silicon_extractor
30
+ "J": junction
31
+ "&": hub
32
+ "=": chest
@@ -0,0 +1,24 @@
1
+ type: mettagrid.map_builder.ascii.AsciiMapBuilder.Config
2
+ map_data: |-
3
+ #########
4
+ #.......#
5
+ #..@....#
6
+ #.......#
7
+ #..S....#
8
+ #.......#
9
+ #########
10
+ char_to_map_name:
11
+ "#": wall
12
+ ".": empty
13
+ "@": agent.agent
14
+ "M": miner_station
15
+ "S": scout_station
16
+ "A": aligner_station
17
+ "X": scrambler_station
18
+ "C": carbon_extractor
19
+ "O": oxygen_extractor
20
+ "G": germanium_extractor
21
+ "I": silicon_extractor
22
+ "J": junction
23
+ "&": hub
24
+ "=": chest
@@ -0,0 +1,28 @@
1
+ type: mettagrid.map_builder.ascii.AsciiMapBuilder.Config
2
+ map_data: |-
3
+ #################
4
+ #...............#
5
+ #..@............#
6
+ #...............#
7
+ #..X............#
8
+ #...............#
9
+ #..=............#
10
+ #...............#
11
+ #..........J....#
12
+ #...............#
13
+ #################
14
+ char_to_map_name:
15
+ "#": wall
16
+ ".": empty
17
+ "@": agent.agent
18
+ "M": miner_station
19
+ "S": scout_station
20
+ "A": aligner_station
21
+ "X": scrambler_station
22
+ "C": carbon_extractor
23
+ "O": oxygen_extractor
24
+ "G": germanium_extractor
25
+ "I": silicon_extractor
26
+ "J": junction
27
+ "&": hub
28
+ "=": chest
@@ -0,0 +1,24 @@
1
+ type: mettagrid.map_builder.ascii.AsciiMapBuilder.Config
2
+ map_data: |-
3
+ #########
4
+ #.......#
5
+ #..@....#
6
+ #.......#
7
+ #..X....#
8
+ #.......#
9
+ #########
10
+ char_to_map_name:
11
+ "#": wall
12
+ ".": empty
13
+ "@": agent.agent
14
+ "M": miner_station
15
+ "S": scout_station
16
+ "A": aligner_station
17
+ "X": scrambler_station
18
+ "C": carbon_extractor
19
+ "O": oxygen_extractor
20
+ "G": germanium_extractor
21
+ "I": silicon_extractor
22
+ "J": junction
23
+ "&": hub
24
+ "=": chest
@@ -0,0 +1,26 @@
1
+ type: mettagrid.map_builder.ascii.AsciiMapBuilder.Config
2
+ map_data: |-
3
+ #############
4
+ #...........#
5
+ #..@........#
6
+ #...........#
7
+ #..X..=.....#
8
+ #...........#
9
+ #........J..#
10
+ #...........#
11
+ #############
12
+ char_to_map_name:
13
+ "#": wall
14
+ ".": empty
15
+ "@": agent.agent
16
+ "M": miner_station
17
+ "S": scout_station
18
+ "A": aligner_station
19
+ "X": scrambler_station
20
+ "C": carbon_extractor
21
+ "O": oxygen_extractor
22
+ "G": germanium_extractor
23
+ "I": silicon_extractor
24
+ "J": junction
25
+ "&": hub
26
+ "=": chest
@@ -0,0 +1,32 @@
1
+ type: mettagrid.map_builder.ascii.AsciiMapBuilder.Config
2
+ map_data: |-
3
+ #########
4
+ #..@....#
5
+ #.......#
6
+ #.####..#
7
+ #.......#
8
+ #..####.#
9
+ #.......#
10
+ #.####..#
11
+ #.......#
12
+ #..####.#
13
+ #.......#
14
+ #.####..#
15
+ #.......#
16
+ #..M..C.#
17
+ #########
18
+ char_to_map_name:
19
+ "#": wall
20
+ ".": empty
21
+ "@": agent.agent
22
+ "M": miner_station
23
+ "S": scout_station
24
+ "A": aligner_station
25
+ "X": scrambler_station
26
+ "C": carbon_extractor
27
+ "O": oxygen_extractor
28
+ "G": germanium_extractor
29
+ "I": silicon_extractor
30
+ "J": junction
31
+ "&": hub
32
+ "=": chest
@@ -0,0 +1,26 @@
1
+ type: mettagrid.map_builder.ascii.AsciiMapBuilder.Config
2
+ map_data: |-
3
+ ###############
4
+ #.............#
5
+ #.............#
6
+ #.............#
7
+ #..&..........#
8
+ #.............#
9
+ #...........@.#
10
+ #..M..........#
11
+ ###############
12
+ char_to_map_name:
13
+ "#": wall
14
+ ".": empty
15
+ "@": agent.agent
16
+ "M": miner_station
17
+ "S": scout_station
18
+ "A": aligner_station
19
+ "X": scrambler_station
20
+ "C": carbon_extractor
21
+ "O": oxygen_extractor
22
+ "G": germanium_extractor
23
+ "I": silicon_extractor
24
+ "J": junction
25
+ "&": hub
26
+ "=": chest
@@ -36,9 +36,9 @@ char_to_map_name:
36
36
  ".": empty
37
37
  "B": clipped_carbon_extractor
38
38
  "N": clipped_oxygen_extractor
39
- "+": charger
39
+ "+": junction
40
40
  "@": agent.agent
41
- "&": assembler
41
+ "&": hub
42
42
  "=": chest
43
43
  "F": clipped_germanium_extractor
44
44
  "R": clipped_silicon_extractor
@@ -25,10 +25,10 @@ char_to_map_name:
25
25
  "#": wall
26
26
  ".": empty
27
27
  "c": carbon_extractor
28
- "+": charger
28
+ "+": junction
29
29
  "o": oxygen_extractor
30
30
  "@": agent.agent
31
- "&": assembler
31
+ "&": hub
32
32
  "g": germanium_extractor
33
33
  "=": chest
34
34
  "s": silicon_extractor
@@ -36,9 +36,9 @@ char_to_map_name:
36
36
  ".": empty
37
37
  "C": carbon_extractor
38
38
  "O": oxygen_extractor
39
- "+": charger
39
+ "+": junction
40
40
  "@": agent.agent
41
- "&": assembler
41
+ "&": hub
42
42
  "=": chest
43
43
  "G": germanium_extractor
44
44
  "S": silicon_extractor
@@ -25,8 +25,8 @@ char_to_map_name:
25
25
  "#": wall
26
26
  ".": empty
27
27
  "@": agent.agent
28
- "+": charger
29
- "&": assembler
28
+ "+": junction
29
+ "&": hub
30
30
  "=": chest
31
31
  "C": carbon_extractor
32
32
  "O": oxygen_extractor
@@ -25,8 +25,8 @@ char_to_map_name:
25
25
  "#": wall
26
26
  ".": empty
27
27
  "@": agent.agent
28
- "+": charger
29
- "&": assembler
28
+ "+": junction
29
+ "&": hub
30
30
  "=": chest
31
31
  "C": carbon_extractor
32
32
  "O": oxygen_extractor
@@ -25,8 +25,8 @@ char_to_map_name:
25
25
  "#": wall
26
26
  ".": empty
27
27
  "@": agent.agent
28
- "+": charger
29
- "&": assembler
28
+ "+": junction
29
+ "&": hub
30
30
  "=": chest
31
31
  "C": carbon_extractor
32
32
  "O": oxygen_extractor
@@ -45,7 +45,7 @@ map_data: |-
45
45
  char_to_map_name:
46
46
  "#": wall
47
47
  ".": empty
48
- "+": charger
48
+ "+": junction
49
49
  "@": agent.agent
50
- "&": assembler
50
+ "&": hub
51
51
  "=": chest
@@ -22,7 +22,7 @@ map_data: |-
22
22
  char_to_map_name:
23
23
  "#": wall
24
24
  ".": empty
25
- "+": charger
25
+ "+": junction
26
26
  "@": agent.agent
27
- "&": assembler
27
+ "&": hub
28
28
  "=": chest
cogames/pickup.py ADDED
@@ -0,0 +1,183 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from pathlib import Path
5
+ from typing import Optional
6
+
7
+ import numpy as np
8
+ import typer
9
+ from rich.console import Console
10
+ from rich.table import Table
11
+
12
+ from metta_alo.rollout import run_multi_episode_rollout
13
+ from metta_alo.scoring import (
14
+ VorTotals,
15
+ allocate_counts,
16
+ overall_value_over_replacement,
17
+ summarize_vor_scenario,
18
+ value_over_replacement,
19
+ )
20
+ from mettagrid import MettaGridConfig
21
+ from mettagrid.mapgen.mapgen import MapGen
22
+ from mettagrid.policy.policy import PolicySpec
23
+
24
+
25
+ @dataclass(frozen=True)
26
+ class PickupScenario:
27
+ candidate_count: int
28
+ pool_counts: list[int]
29
+
30
+
31
+ @dataclass(frozen=True)
32
+ class PickupScenarioResult:
33
+ scenario: PickupScenario
34
+ candidate_mean: Optional[float]
35
+ replacement_mean: Optional[float]
36
+ replay_paths: list[str]
37
+
38
+
39
+ def pickup(
40
+ console: Console,
41
+ candidate_spec: PolicySpec,
42
+ pool_specs: list[PolicySpec],
43
+ *,
44
+ env_cfg: MettaGridConfig,
45
+ mission_name: str,
46
+ episodes: int,
47
+ seed: int,
48
+ map_seed: Optional[int],
49
+ action_timeout_ms: int,
50
+ save_replay_dir: Optional[Path],
51
+ candidate_label: Optional[str] = None,
52
+ pool_labels: Optional[list[str]] = None,
53
+ ) -> None:
54
+ num_cogs = env_cfg.game.num_agents
55
+ effective_map_seed = map_seed if map_seed is not None else seed
56
+ if effective_map_seed is not None:
57
+ map_builder = getattr(env_cfg.game, "map_builder", None)
58
+ if isinstance(map_builder, MapGen.Config):
59
+ map_builder.seed = effective_map_seed
60
+ policy_specs = [candidate_spec, *pool_specs]
61
+
62
+ scenarios: list[PickupScenario] = [
63
+ PickupScenario(
64
+ candidate_count=candidate_count,
65
+ pool_counts=allocate_counts(num_cogs - candidate_count, [1.0] * len(pool_specs), allow_zero_total=True),
66
+ )
67
+ for candidate_count in range(num_cogs, -1, -1)
68
+ ]
69
+
70
+ console.print("[bold cyan]Pickup Evaluation[/bold cyan]")
71
+ console.print(f"[dim]Mission: {mission_name} | cogs={num_cogs} | episodes={episodes} | seed={seed}[/dim]")
72
+ candidate_display = candidate_label or candidate_spec.name
73
+ pool_display = pool_labels or [spec.name for spec in pool_specs]
74
+
75
+ console.print(f"Candidate: [bold]{candidate_display}[/bold]")
76
+ console.print("Pool: " + ", ".join(f"{idx + 1}:{label}" for idx, label in enumerate(pool_display)))
77
+
78
+ results: list[PickupScenarioResult] = []
79
+ totals = VorTotals()
80
+ rng = np.random.default_rng(seed)
81
+
82
+ with typer.progressbar(scenarios, label="Simulating") as progress:
83
+ for scenario in progress:
84
+ assignments = np.repeat(np.arange(len(policy_specs)), [scenario.candidate_count, *scenario.pool_counts])
85
+
86
+ rollout, replay_paths = run_multi_episode_rollout(
87
+ policy_specs=policy_specs,
88
+ assignments=assignments,
89
+ env_cfg=env_cfg,
90
+ episodes=episodes,
91
+ seed=seed,
92
+ max_action_time_ms=action_timeout_ms,
93
+ replay_dir=save_replay_dir,
94
+ rng=rng,
95
+ device="cpu",
96
+ )
97
+ summary = summarize_vor_scenario(
98
+ rollout,
99
+ candidate_policy_index=0,
100
+ candidate_count=scenario.candidate_count,
101
+ )
102
+ results.append(
103
+ PickupScenarioResult(
104
+ scenario=scenario,
105
+ candidate_mean=summary.candidate_mean,
106
+ replacement_mean=summary.replacement_mean,
107
+ replay_paths=replay_paths,
108
+ )
109
+ )
110
+ totals.update(scenario.candidate_count, summary)
111
+
112
+ table = Table(show_header=True, header_style="bold magenta")
113
+ table.add_column("Scenario")
114
+ table.add_column("Candidate", justify="right")
115
+ table.add_column("Pool Mix", justify="right")
116
+ table.add_column("Score", justify="right")
117
+
118
+ for result in results:
119
+ scenario = result.scenario
120
+ pool_mix = "/".join(str(count) for count in scenario.pool_counts)
121
+ short_mission = mission_name.split(".")[-1] if "." in mission_name else mission_name
122
+ scenario_name = f"{short_mission}-c{scenario.candidate_count}-r{sum(scenario.pool_counts)}"
123
+ if scenario.candidate_count == 0:
124
+ score = result.replacement_mean
125
+ else:
126
+ score = result.candidate_mean
127
+ score_text = f"{score:.2f}" if score is not None else "-"
128
+ table.add_row(
129
+ scenario_name,
130
+ str(scenario.candidate_count),
131
+ pool_mix,
132
+ score_text,
133
+ )
134
+
135
+ console.print("\n[bold cyan]Scenario Scores[/bold cyan]")
136
+ console.print(table)
137
+
138
+ if totals.replacement_mean is None:
139
+ console.print("[yellow]No replacement baseline available (missing c0 scenario).[/yellow]")
140
+ if save_replay_dir:
141
+ console.print(f"[dim]Replays saved to {save_replay_dir}[/dim]")
142
+ return
143
+
144
+ console.print(f"\n[bold cyan]Replacement Baseline[/bold cyan] {totals.replacement_mean:.2f}")
145
+
146
+ vor_table = Table(show_header=True, header_style="bold magenta")
147
+ vor_table.add_column("Candidate Count", justify="right")
148
+ vor_table.add_column("Candidate Score", justify="right")
149
+ vor_table.add_column("VOR", justify="right")
150
+
151
+ for result in results:
152
+ scenario = result.scenario
153
+ if scenario.candidate_count == 0:
154
+ continue
155
+ if result.candidate_mean is None:
156
+ candidate_score = None
157
+ vor = None
158
+ else:
159
+ candidate_score = result.candidate_mean
160
+ vor = value_over_replacement(candidate_score, totals.replacement_mean)
161
+
162
+ candidate_text = f"{candidate_score:.2f}" if candidate_score is not None else "-"
163
+ vor_text = f"{vor:.2f}" if vor is not None else "-"
164
+ vor_table.add_row(str(scenario.candidate_count), candidate_text, vor_text)
165
+
166
+ console.print("\n[bold cyan]Value Over Replacement[/bold cyan]")
167
+ console.print(vor_table)
168
+
169
+ overall_vor = overall_value_over_replacement(
170
+ totals.total_candidate_weighted_sum,
171
+ totals.total_candidate_agents,
172
+ totals.replacement_mean,
173
+ )
174
+
175
+ if overall_vor is not None:
176
+ console.print(f"\n[bold cyan]Overall VOR[/bold cyan] {overall_vor:.2f}")
177
+
178
+ if pool_specs:
179
+ pool_names = ", ".join(spec.name for spec in pool_specs)
180
+ console.print(f"[dim]Pool order for mix column: {pool_names}[/dim]")
181
+
182
+ if save_replay_dir:
183
+ console.print(f"[dim]Replays saved to {save_replay_dir}[/dim]")