harfang3d / dogfight-sandbox-hg2

Air to air combat sandbox, created in Python 3 using the HARFANG 3D 2 framework.
GNU General Public License v3.0
145 stars 44 forks source link

About Multiagent Dogfight #67

Open 123456djtdjt opened 1 year ago

123456djtdjt commented 1 year ago

Hey,I'm interested in Multiagent Dogfight,I'd appreciate it if you can share me the code of the multiagent-agent reinforcement learning.

muraatozbek commented 1 year ago

Hi @123456djtdjt ,

you can add second agent as;

1-Copy line https://github.com/harfang3d/dogfight-sandbox-hg2/blob/main/Agent/Train.py#L52 paste to line 53, change name to "agent_2" .

in line https://github.com/harfang3d/dogfight-sandbox-hg2/blob/main/Agent/HarfangEnv_GYM.py#L11 and Line 12 as you can see we define 2 aircraft, oppo and ally. we have 2 aircraft but only single agent. if you want to add second agent, check functions in line https://github.com/harfang3d/dogfight-sandbox-hg2/blob/main/Agent/HarfangEnv_GYM.py#L65. you need to modify these lines.

if you undestand single agent code, you can easily add second agent.

123456djtdjt commented 1 year ago

Hi @123456djtdjt ,

you can add second agent as;

1-Copy line https://github.com/harfang3d/dogfight-sandbox-hg2/blob/main/Agent/Train.py#L52 paste to line 53, change name to "agent_2" .

in line https://github.com/harfang3d/dogfight-sandbox-hg2/blob/main/Agent/HarfangEnv_GYM.py#L11 and Line 12 as you can see we define 2 aircraft, oppo and ally. we have 2 aircraft but only single agent. if you want to add second agent, check functions in line https://github.com/harfang3d/dogfight-sandbox-hg2/blob/main/Agent/HarfangEnv_GYM.py#L65. you need to modify these lines.

if you undestand single agent code, you can easily add second agent.

It is kind of you to tell me that,but I'm interested in how to control a team of agents to fight against another team of agents contolled by IA.Maybe I need to think about it more.Thanks for your advice anyway!

cjmdd commented 1 year ago

Hi @123456djtdjt ,

you can add second agent as;

1-Copy line https://github.com/harfang3d/dogfight-sandbox-hg2/blob/main/Agent/Train.py#L52 paste to line 53, change name to "agent_2" .

in line https://github.com/harfang3d/dogfight-sandbox-hg2/blob/main/Agent/HarfangEnv_GYM.py#L11 and Line 12 as you can see we define 2 aircraft, oppo and ally. we have 2 aircraft but only single agent. if you want to add second agent, check functions in line https://github.com/harfang3d/dogfight-sandbox-hg2/blob/main/Agent/HarfangEnv_GYM.py#L65. you need to modify these lines.

if you undestand single agent code, you can easily add second agent.

Hi, there is a problem when I run Train.py as follows: dogfight_sandbox_hg2/Agent/HarfangEnv_GYM.py", line 130, in _get_observation target_angle = plane_state['target_angle']/360 KeyError: 'target_angle'

WangKeji commented 8 months ago

Hi @123456djtdjt , you can add second agent as; 1-Copy line https://github.com/harfang3d/dogfight-sandbox-hg2/blob/main/Agent/Train.py#L52 paste to line 53, change name to "agent_2" . in line https://github.com/harfang3d/dogfight-sandbox-hg2/blob/main/Agent/HarfangEnv_GYM.py#L11 and Line 12 as you can see we define 2 aircraft, oppo and ally. we have 2 aircraft but only single agent. if you want to add second agent, check functions in line https://github.com/harfang3d/dogfight-sandbox-hg2/blob/main/Agent/HarfangEnv_GYM.py#L65. you need to modify these lines. if you undestand single agent code, you can easily add second agent.

Hi, there is a problem when I run Train.py as follows: dogfight_sandbox_hg2/Agent/HarfangEnv_GYM.py", line 130, in _get_observation target_angle = plane_state['target_angle']/360 KeyError: 'target_angle'

Same problem,did you solve it?