Browse Source

Enhancement of dirvar score

Now the collect interval is incremented at each dirvar update
Yann Weber 6 years ago
parent
commit
6c85234338
1 changed files with 13 additions and 5 deletions
  1. 13
    5
      gte/world.py

+ 13
- 5
gte/world.py View File

@@ -203,9 +203,12 @@ class LivingTurmit(Turmit):
203 203
         self._absx = self._absy = 0
204 204
         self._prev_abs = (0, 0)
205 205
         self._dirvar = 0
206
+        self._dirsum = (0,0)
206 207
         self._prev_dirvar = None
207 208
         self._dirvar_res = 64
208
-        self._steps = 1
209
+        self._dirvar_res_inc = 1
210
+        self._steps = 5
211
+        self._dirvar_cnt = self._dirvar_res
209 212
         
210 213
 
211 214
     def __call__(self):
@@ -218,16 +221,21 @@ class LivingTurmit(Turmit):
218 221
         self.move(tdir)
219 222
 
220 223
         # direction variation handling
221
-        if self._steps % self._dirvar_res == 0:
224
+        #if self._steps % self._dirvar_res == 0:
225
+        if self._dirvar_cnt <= 0:
222 226
             dy = self._absy - self._prev_abs[0]
223 227
             dx = self._absx - self._prev_abs[1]
224 228
             self._prev_abs = (self._absy, self._absx)
225 229
             if self._prev_dirvar is not None:
226 230
                 pdvar = self._prev_dirvar
227
-                self._dirvar += abs(pdvar[0] - dy) + abs(pdvar[1] - dx)
231
+                var = abs(pdvar[0] - dy), abs(pdvar[1] - dx)
232
+                var = [ v if v > 1 else 0 for v in var ]
233
+                self._dirvar += sum(var)
228 234
             self._prev_dirvar = (dy, dx)
229
-            self._dirvar_res += 1
230
-            
235
+            self._dirvar_cnt = self._dirvar_res
236
+            self._dirvar_res += self._dirvar_res_inc
237
+        
238
+        self._dirvar_cnt -= 1
231 239
         self._steps += 1
232 240
 
233 241
     def dirvar(self):

Loading…
Cancel
Save