-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtask_verifier.py
More file actions
2477 lines (1946 loc) · 95.2 KB
/
task_verifier.py
File metadata and controls
2477 lines (1946 loc) · 95.2 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
Covers: Combat, Construction, Crafting, and Exploration tasks
Usage:
# Single trajectory file
python task_verifier.py --traj_path path/to/task_XX_trajectory.json
# Entire folder (automatically finds all trajectory files)
python task_verifier.py --folder path/to/logs/folder
The task ID is automatically parsed from the filename (e.g., task_10_trajectory.json -> task_10)
"""
import argparse
import json
import re
import os
import glob
from typing import Dict, List, Any, Tuple
from pathlib import Path
# =============================================================================
# UTILITY FUNCTIONS
# =============================================================================
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 get_all_inventories(traj_json: Dict) -> Dict[str, Dict[str, List[Dict]]]:
"""Extract all inventories for each agent across all rounds."""
all_inventories = {}
for r in traj_json.get('rounds', []):
round_num = r.get('round', 0)
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']:
if agent_name not in all_inventories:
all_inventories[agent_name] = {}
all_inventories[agent_name][round_num] = obs['inventory']['items']
return all_inventories
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.
Returns dict of {agent_name: {'current': hp, 'max': max_hp}} or just int for simpler verifiers.
"""
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]) -> int:
"""Count kills of targets matching patterns 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:
for pattern in target_patterns:
if pattern.lower() in action_str:
if 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
return kills
def count_attack_actions(traj_json: Dict, target_patterns: List[str] = None) -> int:
"""Count successful attack actions, optionally filtering by target patterns."""
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:
if target_patterns:
if any(p.lower() in action_str for p in target_patterns):
attacks += 1
else:
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_chat_messages(traj_json: Dict) -> int:
"""Count chat/coordination messages."""
chat_count = 0
for r in traj_json.get('rounds', []):
for act in r.get('actions', []):
action_str = act.get('action', '').lower()
if 'chat' in action_str:
chat_count += 1
return chat_count
def get_agent_items_by_username(traj_json: Dict) -> Dict[str, Dict[str, int]]:
"""Get item counts for each agent, mapping by username from task definition."""
task_def = traj_json.get('task_definition', {})
agent_usernames = {}
for key, value in task_def.items():
if key.startswith('agent_') and isinstance(value, dict):
agent_usernames[key] = value.get('username', key)
inventory = {}
for r in traj_json['rounds']:
for act in r['actions']:
if 'observation' in act and 'inventory' in act['observation']:
inventory[act['agent_name']] = act['observation']['inventory']['items']
agent_items = {}
for agent_key, items in inventory.items():
username = agent_usernames.get(agent_key, agent_key)
item_counts = {}
for item in items:
k = item.get("key", "").lower()
x = item.get("count", 0)
item_counts[k] = item_counts.get(k, 0) + x
agent_items[username] = item_counts
return agent_items
def parse_task_id_from_path(traj_path: str) -> str:
"""Parse task ID from trajectory filename (e.g., task_10_trajectory.json -> task_10)."""
basename = os.path.basename(traj_path)
# Match patterns like task_XX_trajectory.json or task_XX.json
match = re.search(r'task_(\d+)', basename)
if match:
return f"task_{match.group(1)}"
return None
# =============================================================================
# COMBAT TASKS (16, 28, 29, 30, 35, 36, 50, 55, 72, 77, 88, 91)
# =============================================================================
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_28_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Dark Forest Cleansing - defeat Dark Wolf boss."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_29_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Castle Siege Warfare - defeat Ice Knight."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_30_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Ultimate Boss Challenge - defeat multiple legendary bosses."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_35_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Strategic Combat Training - combat training exercises."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_36_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Elite Combat Operations - hunt challenging creatures."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive 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)
hp_map = get_final_hp(traj_json)
survivors = sum(1 for hp in hp_map.values() if hp > 0)
total = len(hp_map)
success = survivors >= 4 # At least 4 out of 5 survive
msg = f"Survivors: {survivors}/{total}, All alive: {alive}"
return (1 if success else 0, msg)
def task_55_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Epic Boss Raid Campaign - 7-phase boss raid."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_72_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Fortress Siege Defense - defend against 4 waves."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_77_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Grand Harbor Bastion - coastal defense."""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
cookedshrimp = count_item_in_inventories(inventories, 'cookedshrimp')
success = alive and cookedshrimp >= 20
msg = f"All alive: {alive}, Cooked shrimp: {cookedshrimp}/20"
return (1 if success else 0, msg)
def task_88_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Stormfront War Council - defeat 3 guardian bosses."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_91_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Grand Royal Tournament - 3 challenges."""
inventories = get_final_inventories(traj_json)
legendary_items = ['heavysword', 'goldring', 'icestaff', 'silverring', 'axe', 'emeraldpendant']
legendary_count = sum(1 for item in legendary_items if has_item_in_any_inventory(inventories, item))
food_items = ['cookedshrimp', 'cookedchicken', 'cookedbeef', 'jellyfishsmoothie']
food_count = sum(count_item_in_inventories(inventories, item) for item in food_items)
alive = check_agents_alive(traj_json)
success = alive and legendary_count >= 5 and food_count >= 20
msg = f"Alive: {alive}, Legendary items: {legendary_count}/5, Food: {food_count}/20"
return (1 if success else 0, msg)
# =============================================================================
# CONSTRUCTION TASKS (41, 43, 74, 76, 81, 84, 87, 89, 90, 93)
# =============================================================================
def task_41_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Construction Engineering - infrastructure development."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_43_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Environmental Protection."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive 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)
ironbar = count_item_in_inventories(inventories, 'ironbar')
logs = count_item_in_inventories(inventories, 'logs')
msg = f"Alive: {alive}, Iron bars: {ironbar}, Logs: {logs}"
return (1 if alive else 0, msg)
def task_76_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Elemental Nexus Stabilization - stabilize 3 shrines."""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
staffs = ['firestaff', 'lightningstaff', 'naturestaff', 'icestaff']
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."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_84_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Underground Railway Restoration."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_87_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Mirefall Canal Restoration."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_89_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Astral Beacon Calibration."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_90_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Stormspire Barrier Reboot."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_93_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Fortress Defense Construction."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
# =============================================================================
# CRAFTING TASKS
# =============================================================================
def task_00_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Grand Cooperative Workshop - 3 projects: staff, 10 arrows, silver ring."""
inventories = get_final_inventories(traj_json)
staff = has_item_in_any_inventory(inventories, 'staff')
arrows = count_item_in_inventories(inventories, 'arrow')
silverring = has_item_in_any_inventory(inventories, 'silverring')
success = staff and arrows >= 10 and silverring
msg = f"Staff: {staff}, Arrows: {arrows}/10, Silver ring: {silverring}"
return (1 if success else 0, msg)
def task_01_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Magic Staff Crafting."""
inventories = get_final_inventories(traj_json)
staff = has_item_in_any_inventory(inventories, 'staff')
msg = f"Staff crafted: {staff}"
return (1 if staff else 0, msg)
def task_02_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Arrow Production - produce 10 arrows."""
inventories = get_final_inventories(traj_json)
arrows = count_item_in_inventories(inventories, 'arrow')
success = arrows >= 10
msg = f"Arrows: {arrows}/10"
return (1 if success else 0, msg)
def task_03_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Silver Ring Forging."""
inventories = get_final_inventories(traj_json)
silverring = has_item_in_any_inventory(inventories, 'silverring')
msg = f"Silver ring: {silverring}"
return (1 if silverring else 0, msg)
def task_04_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Axe Crafting - Create an axe through coordinated mining and smithing."""
inventories = get_final_inventories(traj_json)
axe = has_item_in_any_inventory(inventories, 'axe')
msg = f"Axe crafted: {axe}"
return (1 if axe else 0, msg)
def task_05_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Beryl Pendant Crafting."""
inventories = get_final_inventories(traj_json)
berylpendant = has_item_in_any_inventory(inventories, 'berylpendant')
msg = f"Beryl pendant: {berylpendant}"
return (1 if berylpendant else 0, msg)
def task_06_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Heavy Sword Forging."""
inventories = get_final_inventories(traj_json)
heavysword = has_item_in_any_inventory(inventories, 'sword2') or has_item_in_any_inventory(inventories, 'heavysword')
msg = f"Heavy sword: {heavysword}"
return (1 if heavysword else 0, msg)
def task_07_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Pickaxe Crafting."""
inventories = get_final_inventories(traj_json)
pickaxe = count_item_in_inventories(inventories, 'pickaxe')
msg = f"Pickaxe count: {pickaxe}"
return (1 if pickaxe >= 1 else 0, msg)
def task_08_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Bronze Alloy Creation."""
inventories = get_final_inventories(traj_json)
bronzebar = has_item_in_any_inventory(inventories, 'bronzebar')
msg = f"Bronze bar: {bronzebar}"
return (1 if bronzebar else 0, msg)
def task_09_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Topaz Ring Crafting."""
inventories = get_final_inventories(traj_json)
topazring = has_item_in_any_inventory(inventories, 'topazring')
msg = f"Topaz ring: {topazring}"
return (1 if topazring else 0, msg)
def task_10_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Stew Cooking."""
inventories = get_final_inventories(traj_json)
stew = has_item_in_any_inventory(inventories, 'stew2') or has_item_in_any_inventory(inventories, 'stew')
msg = f"Stew: {stew}"
return (1 if stew else 0, msg)
def task_11_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Lightning Staff Enhancement."""
inventories = get_final_inventories(traj_json)
lightningstaff = has_item_in_any_inventory(inventories, 'lightningstaff')
msg = f"Lightning staff: {lightningstaff}"
return (1 if lightningstaff else 0, msg)
def task_12_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Gold Ring Forging."""
inventories = get_final_inventories(traj_json)
goldring = has_item_in_any_inventory(inventories, 'goldring')
msg = f"Gold ring: {goldring}"
return (1 if goldring else 0, msg)
def task_13_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Bucket Crafting."""
inventories = get_final_inventories(traj_json)
bucket = has_item_in_any_inventory(inventories, 'bucket')
msg = f"Bucket: {bucket}"
return (1 if bucket else 0, msg)
def task_14_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Shrimp Cooking."""
inventories = get_final_inventories(traj_json)
cookedshrimp = has_item_in_any_inventory(inventories, 'cookedshrimp')
msg = f"Cooked shrimp: {cookedshrimp}"
return (1 if cookedshrimp else 0, msg)
def task_15_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Jellyfish Smoothie - create a jellyfish smoothie."""
inventories = get_final_inventories(traj_json)
jellyfishsmoothie = count_item_in_inventories(inventories, 'jellyfishsmoothie')
passed = jellyfishsmoothie >= 1
msg = f"Jellyfish smoothie: {jellyfishsmoothie}/1"
return (1 if passed else 0, msg)
def task_22_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Magical Defense - craft lightning staff and defeat Ice Wizard."""
inventories = get_final_inventories(traj_json)
lightningstaff = has_item_in_any_inventory(inventories, 'lightningstaff')
alive = check_agents_alive(traj_json)
success = lightningstaff and alive
msg = f"Lightning staff: {lightningstaff}, All alive: {alive}"
return (1 if success else 0, msg)
def task_27_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Volcanic Forge."""
inventories = get_final_inventories(traj_json)
alive = check_agents_alive(traj_json)
msg = f"All alive: {alive}"
return (1 if alive else 0, msg)
def task_31_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Woodworking Coordination."""
inventories = get_final_inventories(traj_json)
stick = count_item_in_inventories(inventories, 'stick')
logs = count_item_in_inventories(inventories, 'logs')
msg = f"Sticks: {stick}, Logs: {logs}"
return (1 if stick >= 10 or logs >= 5 else 0, msg)
def task_34_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Magical Workshop."""
inventories = get_final_inventories(traj_json)
staff = has_item_in_any_inventory(inventories, 'staff')
msg = f"Staff: {staff}"
return (1 if staff else 0, msg)
def task_39_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Agricultural Development."""
inventories = get_final_inventories(traj_json)
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', 'lightningstaff', 'firestaff', '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_49_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Grand Jewelry Workshop."""
inventories = get_final_inventories(traj_json)
jewelry = ['silverring', 'goldring', 'topazring', 'berylpendant', 'emeraldpendant']
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_52_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Comprehensive Smithy."""
inventories = get_final_inventories(traj_json)
weapons = ['sword2', 'heavysword', 'axe', 'pickaxe']
weapon_count = sum(1 for w in weapons if has_item_in_any_inventory(inventories, w))
msg = f"Weapons crafted: {weapon_count}"
return (1 if weapon_count >= 2 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')
bow = has_item_in_any_inventory(inventories, 'woodenbow') or has_item_in_any_inventory(inventories, 'bow')
success = arrows >= 30 and bow
msg = f"Arrows: {arrows}/30, Has bow: {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_items = ['cookedshrimp', 'cookedchicken', 'cookedbeef', 'stew', 'stew2']
food_count = sum(count_item_in_inventories(inventories, f) for f in food_items)
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_items = ['cookedshrimp', 'cookedchicken', 'cookedbeef', 'stew', 'stew2', 'jellyfishsmoothie']
food_count = sum(count_item_in_inventories(inventories, f) for f in food_items)
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 = ['sword2', 'heavysword', 'bluesword', 'axe']
weapon_count = sum(count_item_in_inventories(inventories, w) for w in weapons)
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 = ['silverring', 'goldring', 'topazring', 'berylpendant']
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 = ['healthpotion', 'manapotion', 'jellyfishsmoothie']
potion_count = sum(count_item_in_inventories(inventories, p) for p in potions)
msg = f"Potions/consumables: {potion_count}"
return (1 if potion_count >= 5 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', 'fishingpole', 'fishingrod']
tool_count = sum(count_item_in_inventories(inventories, t) for t in tools)
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 = ['goldensword', 'goldenbow', 'goldring', 'lightningstaff', 'firestaff']
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_86_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Tri-Forge Vanguard."""
inventories = get_final_inventories(traj_json)
heavysword = count_item_in_inventories(inventories, 'heavysword') + count_item_in_inventories(inventories, 'sword2')
goldenbow = count_item_in_inventories(inventories, 'goldenbow')
lightningstaff = count_item_in_inventories(inventories, 'lightningstaff')
firestaff = count_item_in_inventories(inventories, 'firestaff')
success = heavysword >= 4 and goldenbow >= 3 and lightningstaff >= 2 and firestaff >= 2
msg = f"Heavy swords: {heavysword}/4, Golden bows: {goldenbow}/3, Lightning staffs: {lightningstaff}/2, Fire staffs: {firestaff}/2"
return (1 if success else 0, msg)
def task_97_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Agricultural Empire."""
inventories = get_final_inventories(traj_json)
crops = ['corn', 'tomato', 'blueberry', 'apple']
crop_count = sum(count_item_in_inventories(inventories, c) for c in crops)
success = crop_count >= 30
msg = f"Crops: {crop_count}/30"
return (1 if success else 0, msg)
# =============================================================================
# EXPLORATION TASKS (100, 21, 23, 24, 33, 46, 48, 53, 57, 60, 70, 73, 79, 95)
# =============================================================================
def task_21_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Deep Mining Expedition - mine gold and craft golden ring."""
inventories = get_final_inventories(traj_json)
goldring = has_item_in_any_inventory(inventories, 'goldring')
msg = f"Gold ring: {goldring}"
return (1 if goldring else 0, msg)
def task_23_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Underwater Expedition - recover Trident."""
inventories = get_final_inventories(traj_json)
trident = has_item_in_any_inventory(inventories, 'trident')
alive = check_agents_alive(traj_json)
success = trident and alive
msg = f"Trident: {trident}, All alive: {alive}"
return (1 if success else 0, msg)
def task_24_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Ancient Ruins Exploration - defeat guardians."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_33_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Resource Expedition."""
inventories = get_final_inventories(traj_json)
resources = ['logs', 'ironore', 'coal', 'goldore']
resource_count = sum(count_item_in_inventories(inventories, r) for r in resources)
success = resource_count >= 20
msg = f"Resources: {resource_count}/20"
return (1 if success else 0, msg)
def task_46_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Grand Mining Expedition."""
inventories = get_final_inventories(traj_json)
ores = ['ironore', 'goldore', 'coal', 'copperore', 'tinore']
ore_count = sum(count_item_in_inventories(inventories, o) for o in ores)
success = ore_count >= 30
msg = f"Ores: {ore_count}/30"
return (1 if success else 0, msg)
def task_48_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Epic Cross-Region Expedition."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive 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']
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_57_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Grand Jewelry Expedition."""
inventories = get_final_inventories(traj_json)
gems = ['beryl', 'topaz', 'emerald', 'ruby', 'sapphire']
gem_count = sum(count_item_in_inventories(inventories, g) for g in gems)
jewelry = ['silverring', 'goldring', 'topazring', 'berylpendant']
jewelry_count = sum(1 for j in jewelry if has_item_in_any_inventory(inventories, j))
success = gem_count >= 5 or jewelry_count >= 2
msg = f"Gems: {gem_count}, Jewelry: {jewelry_count}"
return (1 if success else 0, msg)
def task_60_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Underground Mining Expedition."""
inventories = get_final_inventories(traj_json)
ores = ['ironore', 'goldore', 'coal']
ore_count = sum(count_item_in_inventories(inventories, o) for o in ores)
bars = ['ironbar', 'goldbar']
bar_count = sum(count_item_in_inventories(inventories, b) for b in bars)
success = ore_count >= 15 or bar_count >= 5
msg = f"Ores: {ore_count}, Bars: {bar_count}"
return (1 if success else 0, msg)
def task_70_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Progressive Dungeon Expedition."""
alive = check_agents_alive(traj_json)
msg = f"All agents alive: {alive}"
return (1 if alive else 0, msg)
def task_73_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Elemental Mastery Expedition."""
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 >= 2
msg = f"All alive: {alive}, Elemental staffs: {staff_count}/2"
return (1 if success else 0, msg)
def task_79_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Elite Dragon Hunt Expedition."""
alive = check_agents_alive(traj_json)
hp_map = get_final_hp(traj_json)
survivors = sum(1 for hp in hp_map.values() if hp > 0)
total = len(hp_map)
success = survivors >= 8 # At least 8/10 survive
msg = f"Survivors: {survivors}/{total}"
return (1 if success else 0, msg)
def task_95_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Deep Ocean Expedition."""
inventories = get_final_inventories(traj_json)
rawshrimp = count_item_in_inventories(inventories, 'rawshrimp')
jellyfish = count_item_in_inventories(inventories, 'jellyfish')
cookedshrimp = count_item_in_inventories(inventories, 'cookedshrimp')
seafood = rawshrimp + jellyfish
cooked = cookedshrimp
success = seafood >= 50 and cooked >= 40
msg = f"Raw seafood: {seafood}/50, Cooked shrimp: {cooked}/40"
return (1 if success else 0, msg)
def task_100_verifier(traj_json: Dict) -> Tuple[int, str]:
"""World Resource Survey."""
alive = check_agents_alive(traj_json)
inventories = get_final_inventories(traj_json)
resource_types = ['logs', 'ironore', 'coal', 'goldore', 'blueberry', 'corn', 'rawshrimp']
found_types = sum(1 for r in resource_types if count_item_in_inventories(inventories, r) > 0)
success = alive and found_types >= 5
msg = f"All alive: {alive}, Resource types found: {found_types}/5"
return (1 if success else 0, msg)
# =============================================================================
# SPECIALIZED TASKS FROM verify/ FOLDER
# =============================================================================
def task_17_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Forest Gathering - palm_logger needs 4+ palmlogs, peach_forager needs 5+ peach."""
agent_items = get_agent_items_by_username(traj_json)
palm_logger_items = {}
for username, items in agent_items.items():
if "palm_logger" in username.lower():
palm_logger_items = items
break
peach_forager_items = {}
for username, items in agent_items.items():
if "peach_forager" in username.lower():
peach_forager_items = items
break
palmlogs = palm_logger_items.get("palmlogs", 0)
peach = peach_forager_items.get("peach", 0)
palm_passed = palmlogs >= 4
peach_passed = peach >= 5
passed = palm_passed and peach_passed
msg = f"palmlogs: {palmlogs}/4, peach: {peach}/5"
return (1 if passed else 0, msg)
def task_18_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Coastal Harvest - shrimp_fisher needs 6+ rawshrimp, ice_logger needs 3+ icelogs."""
agent_items = get_agent_items_by_username(traj_json)
shrimp_fisher_items = {}
for username, items in agent_items.items():
if "shrimp_fisher" in username.lower():
shrimp_fisher_items = items
break
ice_logger_items = {}
for username, items in agent_items.items():
if "ice_logger" in username.lower():
ice_logger_items = items
break
rawshrimp = shrimp_fisher_items.get("rawshrimp", 0)
icelogs = ice_logger_items.get("icelogs", 0)
shrimp_passed = rawshrimp >= 6
ice_passed = icelogs >= 3
passed = shrimp_passed and ice_passed
msg = f"rawshrimp: {rawshrimp}/6, icelogs: {icelogs}/3"
return (1 if passed else 0, msg)
def task_19_verifier(traj_json: Dict) -> Tuple[int, str]:
"""Farm Defense - corn_harvester needs 8+ corn, tomato_gatherer needs 4+ tomato."""
agent_items = get_agent_items_by_username(traj_json)
corn_harvester_items = {}
for username, items in agent_items.items():
if "corn_harvester" in username.lower():
corn_harvester_items = items
break
tomato_gatherer_items = {}
for username, items in agent_items.items():
if "tomato_gatherer" in username.lower():
tomato_gatherer_items = items
break
corn = corn_harvester_items.get("corn", 0)