geek-ai / MAgent

A Platform for Many-Agent Reinforcement Learning
MIT License
1.68k stars 332 forks source link

How to implement different types of food, that gets consumed one by one. Or: How to prevent sampling to stop too early. #42

Open jposor opened 5 years ago

jposor commented 5 years ago

Hey, thanks for publishing this great platform!

Question: During --train mode, sampling seems to stop, if there's no agent of e.g. g_f left. Any tips how to prevent this / implement many different types of agents which get consumed one by one?

Use case: I tried to add food with different types of value to train_gather.py to see if agents gather the more valuable food first. Unfortunately I'm not able to set this up, because sampling simply stops when one of the food agents has been used up.

    g_s = cfg.add_group(agent)
    g_f = cfg.add_group(food)
    g_f_2 = cfg.add_group(food)

    a = gw.AgentSymbol(g_s, index='any')
    b = gw.AgentSymbol(g_f, index='any')
    c = gw.AgentSymbol(g_f_2, index='any')

    cfg.add_reward_rule(gw.Event(a, 'attack', b), receiver=a, value=5.0)
    cfg.add_reward_rule(gw.Event(a, 'attack', c), receiver=a, value=1.0)

Thank you!