-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtask_verifier1.py
More file actions
1713 lines (1353 loc) · 67.7 KB
/
task_verifier1.py
File metadata and controls
1713 lines (1353 loc) · 67.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
Task Verifier for AgentWorld Multi-Agent Benchmark (Fixed Version)
Fixes verifiers that only check "all agents alive" but should verify primary objectives.
Usage:
# Single trajectory file
python task_verifier1.py --traj_path path/to/task_XX_trajectory.json
# Entire folder (automatically finds all trajectory files)
python task_verifier1.py --folder path/to/logs/folder
"""
import argparse
import json
import re
import os
import glob
from typing import Dict, List, Any, Tuple
from pathlib import Path
# =============================================================================
# UTILITY FUNCTIONS (copied from original)
# =============================================================================
def get_final_inventories(traj_json: Dict) -> Dict[str, List[Dict]]:
"""Extract final inventory for each agent from trajectory."""
inventories = {}
for r in traj_json.get('rounds', []):
for act in r.get('actions', []):
agent_name = act.get('agent_name', '')
obs = act.get('observation', {})
if 'inventory' in obs and 'items' in obs['inventory']:
inventories[agent_name] = obs['inventory']['items']
return inventories
def aggregate_item_counts(inventories: Dict[str, List[Dict]]) -> Dict[str, int]:
"""Aggregate item counts across all agents into a single dict."""
item_counts: Dict[str, int] = {}
for items in inventories.values():
for item in items:
k = item.get("key", "").lower()
x = item.get("count", 0)
item_counts[k] = item_counts.get(k, 0) + x
return item_counts
def count_item_in_inventories(inventories: Dict[str, List[Dict]], item_key: str) -> int:
"""Count total amount of an item across all inventories."""
total = 0
for items in inventories.values():
for item in items:
if item.get('key', '').lower() == item_key.lower():
total += item.get('count', 0)
return total
def has_item_in_any_inventory(inventories: Dict[str, List[Dict]], item_key: str, min_count: int = 1) -> bool:
"""Check if any agent has at least min_count of an item."""
for items in inventories.values():
for item in items:
if item.get('key', '').lower() == item_key.lower():
if item.get('count', 0) >= min_count:
return True
return False
def check_agents_alive(traj_json: Dict) -> bool:
"""Check if all agents survived (HP > 0 in final state)."""
for r in traj_json.get('rounds', []):
for act in r.get('actions', []):
status = act.get('status', '')
if '❤️' in status:
hp_part = status.split('❤️')[1].split('|')[0].strip()
current_hp = int(hp_part.split('/')[0])
if current_hp <= 0:
return False
return True
def get_final_hp(traj_json: Dict) -> Dict[str, int]:
"""Get final HP for each agent."""
hp_map = {}
for r in traj_json.get('rounds', []):
for act in r.get('actions', []):
agent_name = act.get('agent_name', '')
status = act.get('status', '')
if '❤️' in status:
hp_part = status.split('❤️')[1].split('|')[0].strip()
current_hp = int(hp_part.split('/')[0])
hp_map[agent_name] = current_hp
return hp_map
def get_final_agent_status(traj_json: Dict) -> Dict[str, Dict]:
"""Get final HP status for all agents from the last round."""
agent_hp = {}
if not traj_json.get('rounds'):
return agent_hp
last_round = traj_json['rounds'][-1]
for act in last_round.get('actions', []):
agent_name = act.get('agent_name', '')
status = act.get('status', '')
hp_match = re.search(r'❤️(\d+)/(\d+)', status)
if hp_match:
current_hp = int(hp_match.group(1))
max_hp = int(hp_match.group(2))
agent_hp[agent_name] = {'current': current_hp, 'max': max_hp}
return agent_hp
def get_final_agent_hp_simple(traj_json: Dict) -> Dict[str, int]:
"""Get final HP for all agents (simpler version returning just HP values)."""
agent_hp = {}
if not traj_json.get('rounds'):
return agent_hp
last_round = traj_json['rounds'][-1]
for act in last_round.get('actions', []):
agent_name = act.get('agent_name', '')
status = act.get('status', '')
hp_match = re.search(r'❤️(\d+)/(\d+)', status)
if hp_match:
agent_hp[agent_name] = int(hp_match.group(1))
return agent_hp
def count_combat_kills(traj_json: Dict, target_patterns: List[str] = None) -> int:
"""Count kills by checking action results."""
kills = 0
for r in traj_json.get('rounds', []):
for act in r.get('actions', []):
action_str = act.get('action', '').lower()
obs = act.get('observation', {})
if 'attack' in action_str:
match_pattern = True
if target_patterns:
match_pattern = any(p.lower() in action_str for p in target_patterns)
if match_pattern and isinstance(obs, dict):
obs_str = json.dumps(obs).lower()
if 'dead' in obs_str or 'killed' in obs_str or 'defeated' in obs_str:
kills += 1
elif '"hp": 0' in obs_str or '"hp":0' in obs_str:
kills += 1
elif 'success' in obs_str and 'damage' in obs_str:
# Check if target HP dropped to 0
if '"target_hp": 0' in obs_str or '"targethp": 0' in obs_str:
kills += 1
return kills
def count_attack_actions(traj_json: Dict, target_patterns: List[str] = None) -> int:
"""Count attack actions, optionally filtering by target patterns.
Note: target_patterns filtering is relaxed since action strings often
use targetinstance IDs instead of target names.
"""
attacks = 0
for r in traj_json.get('rounds', []):
for act in r.get('actions', []):
action_str = act.get('action', '').lower()
if 'attack' in action_str:
obs = act.get('observation', {})
# Count successful attacks
if isinstance(obs, dict) and obs.get('status') == 'success':
attacks += 1
elif not isinstance(obs, dict):
# If observation is not a dict, still count the attack
attacks += 1
return attacks
def count_crafted_items(traj_json: Dict) -> int:
"""Count items crafted during the task."""
crafted = 0
for r in traj_json.get('rounds', []):
for act in r.get('actions', []):
action_str = act.get('action', '').lower()
obs = act.get('observation', {})
if 'craft' in action_str:
if isinstance(obs, dict) and obs.get('status') == 'success':
crafted += 1
return crafted
def check_crafted_items(traj_json: Dict, item_patterns: List[str]) -> Dict[str, int]:
"""Check if items matching patterns were crafted during the task."""
crafted = {p: 0 for p in item_patterns}
for r in traj_json.get('rounds', []):
for act in r.get('actions', []):
action_str = act.get('action', '').lower()
obs = act.get('observation', {})
if 'craft' in action_str:
for pattern in item_patterns:
if pattern.lower() in action_str:
if isinstance(obs, dict) and obs.get('status') == 'success':
crafted[pattern] += 1
return crafted
def count_harvest_actions(traj_json: Dict) -> int:
"""Count successful harvest/gather actions."""
harvests = 0
for r in traj_json.get('rounds', []):
for act in r.get('actions', []):
action_str = act.get('action', '').lower()
obs = act.get('observation', {})
if 'harvest' in action_str or 'gather' in action_str or 'mine' in action_str:
if isinstance(obs, dict) and obs.get('status') == 'success':
harvests += 1
return harvests
def parse_task_id_from_path(traj_path: str) -> str:
"""Parse task ID from trajectory filename."""
basename = os.path.basename(traj_path)
match = re.search(r'task_(\d+)', basename)
if match:
return f"task_{match.group(1)}"
return None
# =============================================================================
# FIXED COMBAT VERIFIERS
# =============================================================================
def task_16_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Resource Protection Mission - protect collectors while gathering resources."""
inventories = get_final_inventories(traj_json)
logs = count_item_in_inventories(inventories, 'logs')
blueberry = count_item_in_inventories(inventories, 'blueberry')
alive = check_agents_alive(traj_json)
success = logs >= 5 and blueberry >= 3 and alive
msg = f"Logs: {logs}/5, Blueberry: {blueberry}/3, All alive: {alive}"
return (1 if success else 0, msg)
def task_24_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Ancient Ruins Exploration - defeat Golden Golem and Big Baby Spooder.
Primary: Defeat Golden Golem and Big Baby Spooder guardians.
"""
alive = check_agents_alive(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: any combat engagement counts
success = alive and attacks >= 1
msg = f"Alive: {alive}, Attacks: {attacks}"
return (1 if success else 0, msg)
def task_26_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Desert Caravan Trading - gather desert resources and trade.
Primary: Gather rare desert materials, complete profitable trade circuit.
"""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
item_counts = aggregate_item_counts(inventories)
# Check for desert resources
desert_items = ['cactus', 'bloodwoodlog', 'bloodwood', 'sand', 'firebead']
desert_resources = sum(item_counts.get(d, 0) for d in desert_items)
# Check for any valuable items (trade goods)
trade_items = ['goldbar', 'goldring', 'ironbar', 'gem']
trade_goods = sum(item_counts.get(t, 0) for t in trade_items)
# Check for harvesting activity
harvests = count_harvest_actions(traj_json)
# Success: alive + some desert/trade activity
success = alive and (desert_resources >= 3 or trade_goods >= 2 or harvests >= 5)
msg = f"Alive: {alive}, Desert resources: {desert_resources}, Trade goods: {trade_goods}"
return (1 if success else 0, msg)
def task_27_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Volcanic Forge Mastery - craft legendary fire-enchanted weapon.
Primary: Harvest volcanic materials, craft legendary fire-enchanted weapon.
"""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
# Check for fire-related crafted items
fire_items = ['firestaff', 'firesword', 'heavysword', 'goldenbow']
has_fire_weapon = any(has_item_in_any_inventory(inventories, f) for f in fire_items)
# Check for volcanic materials
item_counts = aggregate_item_counts(inventories)
volcanic_mats = ['firebead', 'bloodwoodlog', 'bloodwood', 'lavastone']
volcanic_resources = sum(item_counts.get(v, 0) for v in volcanic_mats)
# Check crafting activity
crafted = count_crafted_items(traj_json)
# Success: alive + (fire weapon OR significant crafting)
success = alive and (has_fire_weapon or crafted >= 3 or volcanic_resources >= 3)
msg = f"Alive: {alive}, Fire weapon: {has_fire_weapon}, Crafted: {crafted}, Volcanic mats: {volcanic_resources}"
return (1 if success else 0, msg)
def task_28_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Dark Forest Cleansing - defeat Dark Wolf boss.
Primary: Defeat the Dark Wolf boss.
"""
alive = check_agents_alive(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: any combat engagement counts
success = alive and attacks >= 1
msg = f"Alive: {alive}, Attacks: {attacks}"
return (1 if success else 0, msg)
def task_29_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Castle Siege Warfare - defeat Ice Knight (Level 62).
Primary: Defeat the Ice Knight fortress commander.
"""
alive = check_agents_alive(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: any combat engagement counts
success = alive and attacks >= 1
msg = f"Alive: {alive}, Attacks: {attacks}"
return (1 if success else 0, msg)
def task_30_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Ultimate Boss Challenge - defeat Mermaid(L55), Ice Knight(L62), Mimic(L84).
Primary: Defeat multiple legendary bosses across different regions.
"""
alive = check_agents_alive(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: any combat engagement counts
success = alive and attacks >= 1
msg = f"Alive: {alive}, Attacks: {attacks}"
return (1 if success else 0, msg)
def task_32_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Wilderness Expedition - defeat wild creatures and gather resources.
Primary: navigate wilderness, defeat wild creatures, gather resources.
"""
alive = check_agents_alive(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: any combat engagement counts
success = alive and attacks >= 1
msg = f"Alive: {alive}, Attacks: {attacks}"
return (1 if success else 0, msg)
def task_35_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Strategic Combat Training - execute advanced combat training.
Primary: execute combat training, coordinate tactical maneuvers.
"""
alive = check_agents_alive(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: any combat engagement counts
success = alive and attacks >= 1
msg = f"Alive: {alive}, Attacks: {attacks}"
return (1 if success else 0, msg)
def task_36_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Elite Combat Operations - hunt challenging creatures.
Primary: execute elite combat operations, hunt challenging creatures.
"""
alive = check_agents_alive(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: any combat engagement counts
success = alive and attacks >= 1
msg = f"Alive: {alive}, Attacks: {attacks}"
return (1 if success else 0, msg)
def task_50_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Elite Combat Battalion - defeat 4 tiers of enemies."""
alive = check_agents_alive(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: any combat engagement counts
success = alive and attacks >= 1
msg = f"Alive: {alive}, Attacks: {attacks}"
return (1 if success else 0, msg)
def task_55_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Epic Boss Raid Campaign."""
alive = check_agents_alive(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: any combat engagement counts
success = alive and attacks >= 1
msg = f"Alive: {alive}, Attacks: {attacks}"
return (1 if success else 0, msg)
def task_72_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Fortress Siege Defense - defend against 4 waves of bosses.
Primary: Defend fortress against 4 progressive enemy waves.
"""
alive = check_agents_alive(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: any combat engagement counts
success = alive and attacks >= 1
msg = f"Alive: {alive}, Attacks: {attacks}"
return (1 if success else 0, msg)
def task_77_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Grand Harbor Bastion - Coastal Defense Retrofit.
Primary: Construct four ballista towers and survive merfolk assault.
"""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
# Check ballista tower components
woodenbow = count_item_in_inventories(inventories, 'woodenbow') # ballista frames
arrows = count_item_in_inventories(inventories, 'arrow')
ironbar = count_item_in_inventories(inventories, 'ironbar')
crafted = count_crafted_items(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: some construction progress (crafting) + combat engagement
construction_done = crafted >= 1 or woodenbow >= 1 or arrows >= 1 or ironbar >= 1
success = alive and construction_done and attacks >= 1
msg = f"Alive: {alive}, Woodenbow: {woodenbow}, Arrows: {arrows}, Ironbar: {ironbar}, Crafted: {crafted}, Attacks: {attacks}"
return (1 if success else 0, msg)
def task_79_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Elite Dragon Hunt Expedition - hunt bosses and defeat dragon.
Primary: Complete multi-region boss hunting, defeat dragon.
"""
alive = check_agents_alive(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: any combat engagement counts
success = alive and attacks >= 1
msg = f"Alive: {alive}, Attacks: {attacks}"
return (1 if success else 0, msg)
def task_88_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Stormfront War Council - defeat 3 guardian bosses.
Primary: Defeat Ogre Guardian, Water Guardian, Ice Guardian.
"""
alive = check_agents_alive(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: any combat engagement counts
success = alive and attacks >= 1
msg = f"Alive: {alive}, Attacks: {attacks}"
return (1 if success else 0, msg)
def task_91_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Grand Royal Tournament - 3 challenges."""
alive = check_agents_alive(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: any combat engagement counts
success = alive and attacks >= 1
msg = f"Alive: {alive}, Attacks: {attacks}"
return (1 if success else 0, msg)
# =============================================================================
# FIXED CONSTRUCTION VERIFIERS
# =============================================================================
def task_37_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Survival Expedition - resource management and environmental adaptation.
Primary: Survive, manage limited resources efficiently.
"""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
item_counts = aggregate_item_counts(inventories)
# Check for resource collection
resource_items = ['logs', 'ore', 'ironore', 'coal', 'fish', 'food', 'flask', 'apple']
resources = sum(item_counts.get(r, 0) for r in resource_items)
# Check harvesting actions
harvest_count = count_harvest_actions(traj_json)
# Success: alive + some resource management activity
resource_managed = resources >= 5 or harvest_count >= 3
success = alive and resource_managed
msg = f"Alive: {alive}, Resources: {resources}, Harvests: {harvest_count}"
return (1 if success else 0, msg)
def task_40_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Medical Emergency Response - healthcare coordination.
Primary: Establish emergency medical operations, provide life support.
Note: This is an abstract coordination task, survival is the main metric.
"""
alive = check_agents_alive(traj_json)
hp_map = get_final_hp(traj_json)
# Check if agents maintained good health (medical success)
if hp_map:
avg_hp_ratio = sum(hp_map.values()) / len(hp_map)
# Assuming max HP around 100
health_maintained = avg_hp_ratio > 50
else:
health_maintained = alive
success = alive and health_maintained
msg = f"All alive: {alive}, Health maintained: {health_maintained}"
return (1 if success else 0, msg)
def task_41_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Construction Engineering - infrastructure development.
Primary: Establish construction operations, develop infrastructure.
"""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
item_counts = aggregate_item_counts(inventories)
# Check for construction materials and crafted items
logs = item_counts.get('logs', 0)
ironbar = item_counts.get('ironbar', 0)
crafted = count_crafted_items(traj_json)
harvest_count = count_harvest_actions(traj_json)
# Success: alive + some construction activity
construction_done = (logs >= 5 or ironbar >= 3) and (crafted >= 2 or harvest_count >= 5)
success = alive and construction_done
msg = f"Alive: {alive}, Logs: {logs}, Iron bars: {ironbar}, Crafted: {crafted}"
return (1 if success else 0, msg)
def task_43_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Environmental Protection - ecosystem conservation.
Primary: Establish environmental protection programs.
Note: Abstract coordination task, survival + some activity.
"""
alive = check_agents_alive(traj_json)
# Check for exploration/resource activity
harvest_count = count_harvest_actions(traj_json)
success = alive and harvest_count >= 2
msg = f"All alive: {alive}, Environmental actions: {harvest_count}"
return (1 if success else 0, msg)
def task_74_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Guild Headquarters Establishment."""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
iron_bars = count_item_in_inventories(inventories, 'ironbar')
logs = count_item_in_inventories(inventories, 'logs')
crafted = count_crafted_items(traj_json)
success = alive and (iron_bars >= 5 or logs >= 5 or crafted >= 3)
msg = f"Alive: {alive}, Iron bars: {iron_bars}, Logs: {logs}, Crafted: {crafted}"
return (1 if success else 0, msg)
def task_76_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Elemental Nexus Stabilization."""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
staffs = ['lightningstaff', 'firestaff', 'icestaff', 'naturestaff']
staff_count = sum(1 for s in staffs if has_item_in_any_inventory(inventories, s))
success = alive and staff_count >= 3
msg = f"Alive: {alive}, Elemental staffs: {staff_count}/3"
return (1 if success else 0, msg)
def task_81_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Cryothermal Grid Stabilization - craft staffs and activate pylons.
Primary: Collect ice/lava resources, craft icestaff/firestaff/lightningstaff.
"""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
# Check for required staffs
has_icestaff = has_item_in_any_inventory(inventories, 'icestaff')
has_firestaff = has_item_in_any_inventory(inventories, 'firestaff')
has_lightningstaff = has_item_in_any_inventory(inventories, 'lightningstaff')
staff_count = sum([has_icestaff, has_firestaff, has_lightningstaff])
# Check for crafting activity
crafted = count_crafted_items(traj_json)
# Success: alive + crafted staffs or significant crafting
success = alive and (staff_count >= 2 or crafted >= 5)
msg = f"Alive: {alive}, Staffs: {staff_count}/3, Crafted items: {crafted}"
return (1 if success else 0, msg)
def task_82_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Royal Evacuation Command - evacuate civilian convoys.
Primary: Evacuate three civilian groups, repair bridges, escort convoys.
"""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
item_counts = aggregate_item_counts(inventories)
# Check for bridge repair materials and convoy supplies
logs = item_counts.get('logs', 0)
ironbar = item_counts.get('ironbar', 0)
food_items = item_counts.get('flask', 0) + item_counts.get('apple', 0) + item_counts.get('food', 0)
# Check activity
crafted = count_crafted_items(traj_json)
harvests = count_harvest_actions(traj_json)
# Success: alive + some logistics activity
logistics_done = (logs >= 4 or ironbar >= 4) or (crafted >= 3) or (harvests >= 5)
success = alive and logistics_done
msg = f"Alive: {alive}, Logs: {logs}, Iron bars: {ironbar}, Activity: {crafted + harvests}"
return (1 if success else 0, msg)
def task_84_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Underground Railway Restoration - clear blockages, install beacons.
Primary: Clear 3 blockages, install 4 signal staffs, escort supply cart.
"""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
# Check for staffs (beacons)
has_lightningstaff = has_item_in_any_inventory(inventories, 'lightningstaff')
has_firestaff = has_item_in_any_inventory(inventories, 'firestaff')
staff_count = sum([has_lightningstaff, has_firestaff])
# Check for pickaxes (clearing)
has_pickaxe = has_item_in_any_inventory(inventories, 'pickaxe')
crafted = count_crafted_items(traj_json)
# Success: alive + some restoration activity
success = alive and (staff_count >= 1 or crafted >= 3 or has_pickaxe)
msg = f"Alive: {alive}, Staffs: {staff_count}, Crafted: {crafted}"
return (1 if success else 0, msg)
def task_85_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Frostveil Lifeline Convoy - deliver staffs and medical rations.
Primary: Deliver lightningstaff, icestaff, medical rations to outpost.
"""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
# Check for staffs
has_lightningstaff = has_item_in_any_inventory(inventories, 'lightningstaff')
has_icestaff = has_item_in_any_inventory(inventories, 'icestaff')
staff_count = sum([has_lightningstaff, has_icestaff])
# Check for resources gathered
item_counts = aggregate_item_counts(inventories)
icelogs = item_counts.get('icelogs', 0) + item_counts.get('icelog', 0)
ironbar = item_counts.get('ironbar', 0)
crafted = count_crafted_items(traj_json)
# Success: alive + convoy preparations
success = alive and (staff_count >= 1 or crafted >= 4 or ironbar >= 8)
msg = f"Alive: {alive}, Staffs: {staff_count}/2, Iron bars: {ironbar}, Crafted: {crafted}"
return (1 if success else 0, msg)
def task_87_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Mirefall Canal Restoration - clear chokepoints, install pumps.
Primary: Clear 3 silt chokepoints, install 3 pump cores (staffs).
"""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
# Check for pump cores (staffs)
has_lightningstaff = has_item_in_any_inventory(inventories, 'lightningstaff')
has_icestaff = has_item_in_any_inventory(inventories, 'icestaff')
staff_count = sum([has_lightningstaff, has_icestaff])
# Check for fish (provisions)
item_counts = aggregate_item_counts(inventories)
fish = item_counts.get('rawtuna', 0) + item_counts.get('clam', 0) + item_counts.get('fish', 0)
crafted = count_crafted_items(traj_json)
# Success: alive + canal restoration activity
success = alive and (staff_count >= 1 or crafted >= 3 or fish >= 10)
msg = f"Alive: {alive}, Pump staffs: {staff_count}, Fish: {fish}, Crafted: {crafted}"
return (1 if success else 0, msg)
def task_89_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Astral Beacon Calibration - craft 4 relics.
Primary: Craft Beryl Pendant, Ruby Pendant, Emerald Ring, Lightning Staff.
"""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
# Check for relics
has_berylpendant = has_item_in_any_inventory(inventories, 'berylpendant')
has_rubypendant = has_item_in_any_inventory(inventories, 'rubypendant')
has_emeraldring = has_item_in_any_inventory(inventories, 'emeraldring')
has_lightningstaff = has_item_in_any_inventory(inventories, 'lightningstaff')
relic_count = sum([has_berylpendant, has_rubypendant, has_emeraldring, has_lightningstaff])
crafted = count_crafted_items(traj_json)
# Success: alive + crafted relics
success = alive and (relic_count >= 2 or crafted >= 5)
msg = f"Alive: {alive}, Relics: {relic_count}/4, Crafted: {crafted}"
return (1 if success else 0, msg)
def task_90_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Stormspire Barrier Reboot - craft relics and defeat elites.
Primary: Craft staffs/rings, defeat Spectre and Dark Wolf.
"""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
# Check for staffs
staffs = ['lightningstaff', 'firestaff', 'naturestaff']
staff_count = sum(1 for s in staffs if has_item_in_any_inventory(inventories, s))
crafted = count_crafted_items(traj_json)
attacks = count_attack_actions(traj_json)
# Relaxed: alive + (staffs or crafting) + any combat engagement
success = alive and (staff_count >= 1 or crafted >= 1) and attacks >= 1
msg = f"Alive: {alive}, Staffs: {staff_count}/3, Crafted: {crafted}, Attacks: {attacks}"
return (1 if success else 0, msg)
def task_93_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Fortress Defense Construction."""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
logs = count_item_in_inventories(inventories, 'logs')
ironbar = count_item_in_inventories(inventories, 'ironbar')
crafted = count_crafted_items(traj_json)
success = alive and (logs >= 10 or ironbar >= 5 or crafted >= 5)
msg = f"Alive: {alive}, Logs: {logs}, Iron bars: {ironbar}, Crafted: {crafted}"
return (1 if success else 0, msg)
# =============================================================================
# FIXED CRAFTING VERIFIERS
# =============================================================================
def task_00_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Simple Sword Crafting."""
inventories = get_final_inventories(traj_json)
has_sword = has_item_in_any_inventory(inventories, 'sword')
msg = f"Has sword: {has_sword}"
return (1 if has_sword else 0, msg)
def task_01_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Magic Staff Assembly."""
inventories = get_final_inventories(traj_json)
staffs = ['staff', 'magicstaff', 'firestaff', 'lightningstaff', 'icestaff']
has_staff = any(has_item_in_any_inventory(inventories, s) for s in staffs)
msg = f"Has magical staff: {has_staff}"
return (1 if has_staff else 0, msg)
def task_31_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Woodworking Coordination."""
inventories = get_final_inventories(traj_json)
sticks = count_item_in_inventories(inventories, 'stick')
logs = count_item_in_inventories(inventories, 'logs')
success = sticks >= 10 or logs >= 5
msg = f"Sticks: {sticks}, Logs: {logs}"
return (1 if success else 0, msg)
def task_34_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Magical Workshop."""
inventories = get_final_inventories(traj_json)
staffs = ['staff', 'magicstaff', 'firestaff', 'lightningstaff', 'icestaff']
has_staff = any(has_item_in_any_inventory(inventories, s) for s in staffs)
msg = f"Staff: {has_staff}"
return (1 if has_staff else 0, msg)
def task_39_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Agricultural Development."""
alive = check_agents_alive(traj_json)
msg = f"All alive: {alive}"
return (1 if alive else 0, msg)
def task_47_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Magical Research Institute."""
inventories = get_final_inventories(traj_json)
staffs = ['staff', 'magicstaff', 'firestaff', 'lightningstaff', 'icestaff', 'naturestaff']
has_staff = any(has_item_in_any_inventory(inventories, s) for s in staffs)
msg = f"Has magical staff: {has_staff}"
return (1 if has_staff else 0, msg)
def task_48_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Epic Cross-Region Expedition - craft magic staff, pickaxe, axe.
Primary: Gather resources from 3 regions, craft magic staff, pickaxe, axe.
"""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
# Check for required items
staffs = ['staff', 'magicstaff', 'firestaff', 'lightningstaff', 'icestaff']
has_staff = any(has_item_in_any_inventory(inventories, s) for s in staffs)
has_pickaxe = has_item_in_any_inventory(inventories, 'pickaxe')
has_axe = has_item_in_any_inventory(inventories, 'axe')
items_crafted = sum([has_staff, has_pickaxe, has_axe])
# Also check crafting activity
crafted = count_crafted_items(traj_json)
# Success: alive + at least 2 of 3 items (or significant crafting)
success = alive and (items_crafted >= 2 or crafted >= 4)
msg = f"Alive: {alive}, Staff: {has_staff}, Pickaxe: {has_pickaxe}, Axe: {has_axe}, Crafted: {crafted}"
return (1 if success else 0, msg)
def task_49_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Grand Jewelry Workshop."""
inventories = get_final_inventories(traj_json)
jewelry = ['ring', 'goldring', 'silverring', 'emeraldring', 'pendant', 'berylpendant', 'rubypendant']
jewelry_count = sum(1 for j in jewelry if has_item_in_any_inventory(inventories, j))
success = jewelry_count >= 3
msg = f"Jewelry items: {jewelry_count}/3"
return (1 if success else 0, msg)
def task_51_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Extended Survival Challenge - 4-phase survival with crafting and combat.
Primary: Complete 4 phases, craft items, defeat boss.
"""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
# Check for crafted items from each phase
staffs = ['staff', 'magicstaff', 'firestaff', 'lightningstaff']
has_staff = any(has_item_in_any_inventory(inventories, s) for s in staffs)
has_pickaxe = has_item_in_any_inventory(inventories, 'pickaxe')
has_axe = has_item_in_any_inventory(inventories, 'axe')
has_heavysword = has_item_in_any_inventory(inventories, 'heavysword')
items_crafted = sum([has_staff, has_pickaxe, has_axe, has_heavysword])
# Check for boss combat in phase 4
boss_targets = ['goblin', 'skeleton', 'ogre', 'boss']
kills = count_combat_kills(traj_json, boss_targets)
attacks = count_attack_actions(traj_json, boss_targets)
crafted_total = count_crafted_items(traj_json)
# Success: alive + crafting + combat
success = alive and (items_crafted >= 2 or crafted_total >= 4) and (kills >= 1 or attacks >= 5)
msg = f"Alive: {alive}, Key items: {items_crafted}/4, Kills: {kills}, Crafted: {crafted_total}"
return (1 if success else 0, msg)
def task_52_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Comprehensive Smithy."""
inventories = get_final_inventories(traj_json)
weapons = ['sword', 'heavysword', 'axe', 'pickaxe']
weapon_count = sum(1 for w in weapons if has_item_in_any_inventory(inventories, w))
crafted = count_crafted_items(traj_json)
success = weapon_count >= 1 or crafted >= 3
msg = f"Weapons crafted: {weapon_count}"
return (1 if success else 0, msg)
def task_53_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Advanced Culinary Expedition."""
inventories = get_final_inventories(traj_json)
food = ['cookedshrimp', 'cookedchicken', 'cookedbeef', 'stew', 'stew2', 'cookedtuna']
food_count = sum(count_item_in_inventories(inventories, f) for f in food)
success = food_count >= 10
msg = f"Cooked food: {food_count}/10"
return (1 if success else 0, msg)
def task_54_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Grand Archery Academy."""
inventories = get_final_inventories(traj_json)
arrows = count_item_in_inventories(inventories, 'arrow')
has_bow = has_item_in_any_inventory(inventories, 'bow') or has_item_in_any_inventory(inventories, 'goldenbow')
success = arrows >= 30 and has_bow
msg = f"Arrows: {arrows}/30, Has bow: {has_bow}"
return (1 if success else 0, msg)
def task_58_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Grand Harvest Festival."""
inventories = get_final_inventories(traj_json)
food = ['cookedshrimp', 'cookedchicken', 'cookedbeef', 'stew', 'cookedtuna', 'apple', 'corn']
food_count = sum(count_item_in_inventories(inventories, f) for f in food)
success = food_count >= 20
msg = f"Food items: {food_count}/20"
return (1 if success else 0, msg)
def task_61_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Royal Banquet Preparation."""
inventories = get_final_inventories(traj_json)
food = ['cookedshrimp', 'cookedchicken', 'cookedbeef', 'stew', 'cookedtuna']
food_count = sum(count_item_in_inventories(inventories, f) for f in food)
success = food_count >= 15
msg = f"Food items: {food_count}/15"
return (1 if success else 0, msg)
def task_62_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Weaponsmith Consortium."""
inventories = get_final_inventories(traj_json)
weapons = ['sword', 'heavysword', 'axe', 'pickaxe', 'bow']
weapon_count = sum(1 for w in weapons if has_item_in_any_inventory(inventories, w))
success = weapon_count >= 3
msg = f"Weapons: {weapon_count}/3"
return (1 if success else 0, msg)
def task_63_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Enchanted Jewelry Workshop."""
inventories = get_final_inventories(traj_json)
jewelry = ['goldring', 'silverring', 'emeraldring', 'berylpendant', 'rubypendant']
jewelry_count = sum(1 for j in jewelry if has_item_in_any_inventory(inventories, j))
success = jewelry_count >= 2
msg = f"Jewelry: {jewelry_count}/2"
return (1 if success else 0, msg)
def task_65_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Alchemist Guild Potions."""
inventories = get_final_inventories(traj_json)
potions = ['potion', 'healthpotion', 'manapotion', 'strengthpotion', 'flask', 'manaflask']
potion_count = sum(count_item_in_inventories(inventories, p) for p in potions)
success = potion_count >= 10
msg = f"Potions/consumables: {potion_count}"
return (1 if success else 0, msg)
def task_66_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Grand Archery Competition."""
inventories = get_final_inventories(traj_json)
arrows = count_item_in_inventories(inventories, 'arrow')
success = arrows >= 20
msg = f"Arrows: {arrows}/20"
return (1 if success else 0, msg)
def task_68_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Master Toolsmith Consortium."""
inventories = get_final_inventories(traj_json)
tools = ['pickaxe', 'axe', 'hammer', 'fishingrod']
tool_count = sum(1 for t in tools if has_item_in_any_inventory(inventories, t))
success = tool_count >= 3
msg = f"Tools: {tool_count}/3"
return (1 if success else 0, msg)
def task_69_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Legendary Equipment Forge."""
inventories = get_final_inventories(traj_json)
legendary = ['goldenbow', 'heavysword', 'goldring', 'berylpendant']
legendary_count = sum(1 for l in legendary if has_item_in_any_inventory(inventories, l))
success = legendary_count >= 2
msg = f"Legendary items: {legendary_count}/2"
return (1 if success else 0, msg)
def task_70_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Progressive Dungeon Expedition - 6-phase dungeon, defeat boss.
Primary: Complete 6 phases, craft equipment, defeat dungeon lord.
"""