瀏覽代碼

fix default list in dict

Bastien Sevajol 7 年之前
父節點
當前提交
b9199e131b
共有 2 個文件被更改,包括 3 次插入3 次删除
  1. 2 2
      sandbox/engulf/simulation.py
  2. 1 1
      synergine2/xyz.py

+ 2 - 2
sandbox/engulf/simulation.py 查看文件

30
         super().append(p_object)
30
         super().append(p_object)
31
 
31
 
32
         if isinstance(p_object, Cell):
32
         if isinstance(p_object, Cell):
33
-            self.cell_xyz.get(p_object.position, []).append(p_object)
33
+            self.cell_xyz.setdefault(p_object.position, []).append(p_object)
34
 
34
 
35
         if isinstance(p_object, Grass):
35
         if isinstance(p_object, Grass):
36
-            self.grass_xyz.get(p_object.position, []).append(p_object)
36
+            self.grass_xyz.setdefault(p_object.position, []).append(p_object)
37
 
37
 
38
 
38
 
39
 class Engulf(XYZSimulation):
39
 class Engulf(XYZSimulation):

+ 1 - 1
synergine2/xyz.py 查看文件

232
                 str(p_object),
232
                 str(p_object),
233
             ))
233
             ))
234
 
234
 
235
-        self.xyz.get(p_object.position, []).append(p_object)
235
+        self.xyz.setdefault(p_object.position, []).append(p_object)
236
 
236
 
237
 
237
 
238
 class XYZSimulation(BaseSimulation):
238
 class XYZSimulation(BaseSimulation):