瀏覽代碼

prevent bug if subject kill by two other subject at once

Bastien Sevajol 7 年之前
父節點
當前提交
c9d7848198
共有 3 個文件被更改,包括 5 次插入4 次删除
  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 查看文件

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

+ 2 - 2
sandbox/tile/run.py 查看文件

39
     simulation = TileStrategySimulation(config, map_file_path=map_file_path)
39
     simulation = TileStrategySimulation(config, map_file_path=map_file_path)
40
     subjects = TileStrategySubjects(simulation=simulation)
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
         man = TileSubject(
43
         man = TileSubject(
44
             config=config,
44
             config=config,
45
             simulation=simulation,
45
             simulation=simulation,
52
         )
52
         )
53
         subjects.append(man)
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
         man = TileSubject(
56
         man = TileSubject(
57
             config=config,
57
             config=config,
58
             simulation=simulation,
58
             simulation=simulation,

+ 2 - 1
sandbox/tile/simulation/behaviour.py 查看文件

118
         events = list()
118
         events = list()
119
         events.append(FireEvent(shooter_subject_id=self.subject.id, target_position=target_position))
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
             target_subject.collections.remove(COLLECTION_ALIVE)
123
             target_subject.collections.remove(COLLECTION_ALIVE)
123
             # FIXME: Must be automatic when manipulate subject collections !
124
             # FIXME: Must be automatic when manipulate subject collections !
124
             self.simulation.collections[COLLECTION_ALIVE].remove(target_subject_id)
125
             self.simulation.collections[COLLECTION_ALIVE].remove(target_subject_id)