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
161 stars 47 forks source link

What is the difference between flag_destroyed and wreck? #78

Open cjmdd opened 1 year ago

cjmdd commented 1 year ago

What is the difference between flag_destroyed and wreck?

ErkMkd commented 1 year ago

Wreck is when model is crashing, exploding.... Destroying animations and physics are in progress. When destroying animations are finished, when the model is immobilized on the ground, it's declared as "destroyed". If needed you can display a destroyed mesh when flag_destroyed is true.

cjmdd commented 1 year ago

Wreck is when model is crashing, exploding.... Destroying animations and physics are in progress. When destroying animations are finished, when the model is immobilized on the ground, it's declared as "destroyed". If needed you can display a destroyed mesh when flag_destroyed is true.

Thanks, When setting rewards, which symbols in def get_plane_state() should be used for the punishment of aircraft being hit by missiles and aircraft being completely destroyed? For example: "health_level": machine.health_level, "destroyed": machine.flag_destroyed, "wreck": machine.wreck, "crashed": machine.flag_crashed,

ErkMkd commented 1 year ago

There is no direct information to determines if aircraft has been hit by missile or machinegun. If I correctly understood your need, I think you can set a reward using health_level derivative... Not 100% safe but without add a feature to the simulator, that's what i would do.

ErkMkd commented 1 year ago

Now, You can easily add a list of all objects that hit the aircraft, passing them by Machine.hit function. Just add the source of the hit, and store it in a List of the Machine. Then, in get_state function, add the list of all objects that hit the plane.

cjmdd commented 1 year ago

Now, You can easily add a list of all objects that hit the aircraft, passing them by Machine.hit function. Just add the source of the hit, and store it in a List of the Machine. Then, in get_state function, add the list of all objects that hit the plane.

Thank you for your patience in answering. Can you explain it in more detail? I couldn't find the hit function in the network_server,py. Also, The reward received seems to be a delayed reward since missiles require time to fly for a while. Would the delayed reward mislead the policies of airplanes? If so, how can it be alleviated?

cjmdd commented 1 year ago

Now, You can easily add a list of all objects that hit the aircraft, passing them by Machine.hit function. Just add the source of the hit, and store it in a List of the Machine. Then, in get_state function, add the list of all objects that hit the plane. I modified the program along another line of thought: Main: def update_kinetics: def update_kinetics: dm.update_kinetics for dm in Destoryabke_machine Aircraft Class: def update_kinetics: def update_devices---> DestroyableDevice Class: def update_devices: device.update for device in self.devices----> MachineGun Class: def update: for target in targets: cnds = target.get_collision_nodes() for nd in cnds: if nd == hit.node: target.hit(0.1, hit.P) %%%%we set this flag_hit of gun from aircraft to True%%%%% self.flag_hit=True

                     network_server:get_plane_state: state = {'flag_hit_gun': main.get_device("MachineGun").flag_hit}

Here, We query whether the flag_hit_gun of each plane is True to determine if this plane shoot the enemy.
Missile Class in MissileDevice of Aircraft Class: def update_kinetics: self.update_collisions: if self.target is not None:

                            if collision_object is not None and hasattr(collision_object, "nationality") and collision_object.nationality != self.nationality:
                            self.start_explosion()
                            collision_object.hit(self.get_hit_damages(), hit.P)
                  method1:%%%%we set this flag_hit of missile fired by aircraft to True%%%                  
                            self.flag_hit=True                      
    network_server:get_missile_state: state = {'flag_hit_missile': machine.flag_hit}

At last, We query whether the flag_hit_missile of the missiles launched by each plane is True to determine if this plane hit the enemy. Then, the plane is rewarded.