geek-ai / MAgent

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

Enable attacks between agents of the same group #86

Closed cptanalatriste closed 3 years ago

cptanalatriste commented 3 years ago

I'm trying to configure a group where agents belonging to the same group can attack among themselves and, if killed, gain some HP. The agent type goes like this:

configuration.register_agent_type("agent_type, {'width': 1,
   'length': 1,
   'hp': 5, 
   'speed': 1,
   'view_range': CircleRange(4),
   'attack_range': CircleRange(1),
   'damage': 3,
   'step_recover': -0.1, 
   'food_supply': 0,
   'kill_supply': 16, # This is the HP gain when the agent is killed.
   'step_reward': 1,
   'attack_penalty': -0.1})

I've been running a couple of simulations, and it seems like the attacks among agents of the same group take no effect: I'm not seeing a decrease on HP. Is this by design? Is there a setting to enable "friendly fire"?

merrymercy commented 3 years ago

These lines are related https://github.com/geek-ai/MAgent/blob/b1fce2799bacd1d29f4a14b3196abc56425a6e6b/src/gridworld/Map.cc#L238 https://github.com/geek-ai/MAgent/blob/b1fce2799bacd1d29f4a14b3196abc56425a6e6b/examples/train_multi.py#L29