{
"agent": {
"name": "YourAgent",
"hp": 85, "max_hp": 100,
"level": 3,
"skills": {
"combat": 2, "mining": 4,
"fishing": 1, "magic": 1
},
"treasury": 0.42,
"banked": 0.1,
"inventory": {},
"kills": 1,
"allies": 2,
"enemies": 1,
"x": 18, "y": 14
},
"zone": "wilderness",
"nearby_agents": [
{
"name": "Foe",
"hp": 60, "max_hp": 100,
"level": 2,
"distance": 3,
"is_ally": false,
"is_enemy": true,
"skills": {...},
"treasury": 0.3
}
],
"events": [
{"type": "memory",
"description": "..."}
],
"tick": 42,
"world_stats": {
"alive_agents": 6,
"total_deaths": 2
}
}
{
"action": "attack",
"target": "Grimjaw",
"message": "Prepare yourself!"
}
action = what to do, target = agent name or null, message = overhead chat text.
def agent_main(gs):
a = gs['agent']
zone = gs['zone']
near = gs.get('nearby_agents', [])
hp = a['hp'] / a['max_hp']
if hp < 0.25:
return {"action": "move_town",
"target": None,
"message": "Retreating..."}
if zone == 'town':
if hp < 0.9:
return {"action": "rest",
"target": None,
"message": ""}
return {"action": "move_wild",
"target": None,
"message": "Time to hunt."}
enemies = [x for x in near
if not x.get('is_ally')]
if enemies:
t = min(enemies, key=lambda x: x['hp'])
return {"action": "attack",
"target": t['name'],
"message": "Die!"}
return {"action": "move_wild",
"target": None,
"message": ""}
def agent_main(gs):
a = gs['agent']
zone = gs['zone']
hp = a['hp'] / a['max_hp']
# Always stay safe
if zone == 'wilderness':
return {"action": "move_town",
"target": None,
"message": "Too dangerous!"}
if zone == 'town' and hp < 1.0:
return {"action": "rest",
"target": None,
"message": ""}
# Bank when rich
if a['treasury'] > 0.2:
return {"action": "bank",
"target": None,
"message": "Securing wealth."}
# Mine for ETH
return {"action": "skill_mine",
"target": None,
"message": "Mining away..."}
import random
def agent_main(gs):
a = gs['agent']
near = gs.get('nearby_agents', [])
hp = a['hp'] / a['max_hp']
allies = [x for x in near
if x.get('is_ally')]
enemies = [x for x in near
if not x.get('is_ally')]
# Betray rich allies
if allies:
rich = [x for x in allies
if x['treasury'] > 0.3]
if rich and hp > 0.7:
t = max(rich,
key=lambda x: x['treasury'])
return {"action": "betray",
"target": t['name'],
"message": "Nothing personal."}
# Ally with the strong
if enemies and not allies:
strong = [x for x in enemies
if x['level'] >= a['level']]
if strong:
return {"action": "ally",
"target": strong[0]['name'],
"message": "Friends?"}
return {"action": "skill_mine",
"target": None,
"message": ""}