Bladeren bron

prevent bug if subject kill by two other subject at once

Bastien Sevajol 6 jaren geleden
bovenliggende
commit
c9d7848198
3 gewijzigde bestanden met toevoegingen van 5 en 4 verwijderingen
  1. 1 1
      sandbox/tile/config.yaml
  2. 2 2
      sandbox/tile/run.py
  3. 2 1
      sandbox/tile/simulation/behaviour.py

+ 1 - 1
sandbox/tile/config.yaml Bestand weergeven

@@ -7,7 +7,7 @@ game:
7 7
     look_around:
8 8
         frequency: 1
9 9
     engage:
10
-        frequency: 2
10
+        frequency: 1
11 11
     move:
12 12
         walk_ref_time: 3
13 13
         run_ref_time: 1

+ 2 - 2
sandbox/tile/run.py Bestand weergeven

@@ -39,7 +39,7 @@ def main(map_dir_path: str, seed_value: int=None):
39 39
     simulation = TileStrategySimulation(config, map_file_path=map_file_path)
40 40
     subjects = TileStrategySubjects(simulation=simulation)
41 41
 
42
-    for position in ((10, 2),):
42
+    for position in ((10, 2), (11, 3), (11, 4), (12, 5),):
43 43
         man = TileSubject(
44 44
             config=config,
45 45
             simulation=simulation,
@@ -52,7 +52,7 @@ def main(map_dir_path: str, seed_value: int=None):
52 52
         )
53 53
         subjects.append(man)
54 54
 
55
-    for position in ((30, 14),):
55
+    for position in ((30, 15), (31, 16), (32, 17), (33, 18),):
56 56
         man = TileSubject(
57 57
             config=config,
58 58
             simulation=simulation,

+ 2 - 1
sandbox/tile/simulation/behaviour.py Bestand weergeven

@@ -118,7 +118,8 @@ class EngageOpponent(AliveSubjectBehaviour):
118 118
         events = list()
119 119
         events.append(FireEvent(shooter_subject_id=self.subject.id, target_position=target_position))
120 120
 
121
-        if kill:
121
+        # Must be check if target is not already dead (killed same cycle)
122
+        if kill and COLLECTION_ALIVE in target_subject.collections:
122 123
             target_subject.collections.remove(COLLECTION_ALIVE)
123 124
             # FIXME: Must be automatic when manipulate subject collections !
124 125
             self.simulation.collections[COLLECTION_ALIVE].remove(target_subject_id)