From ed32bba8c6bd17696165dbf0bf64e3ed7de88b1c Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Tue, 16 Feb 2016 19:37:50 +0100 Subject: [PATCH] bug fix + more waterlike + more detail --- water_sim.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/water_sim.py b/water_sim.py index 239fe13..fba92a1 100644 --- a/water_sim.py +++ b/water_sim.py @@ -12,7 +12,7 @@ class WaterSim(Game): def init_data(self, middle): self.C = [50] * self.N for i in range(middle - self.N//4,middle + self.N//4): - if i < 0 or i > self.N: continue + if i < 0 or i >= self.N: continue self.C[i] += (1-math.cos(2 * math.pi * (i - middle + self.N//4) / (self.N//2))) * 100 self.C1 = [0] * self.N @@ -30,7 +30,7 @@ class WaterSim(Game): C2[-1] = 100 * (self.C[-2] - self.C[-1]) * 100/self.N for i in range(1,self.N-1): - C2[i] = 100 * (self.C[i+1] + self.C[i-1] - 2*self.C[i]) * 0.5 * 100 /(self.N) + C2[i] = 1000 * (self.C[i+1] + self.C[i-1] - 2*self.C[i]) * 0.5 * 100 /(self.N) for i in range(0,self.N): self.C1[i] = (self.C1[i] + C2[i] * dtime) @@ -60,4 +60,4 @@ class WaterSim(Game): prev_point = new_point if __name__ == '__main__': - WaterSim(100).on_execute() + WaterSim(50).on_execute()