Skip to content

Commit e9abdfc

Browse files
committed
BugHuntCamo: Make sure ticks advance before resetting timer
With changes to timer resolution due to various memory attacks, Bug Hunt Camouflage doesn't run as it once did in NetLogo Web. Because the timer returns `0` so often, not much happens when `go` is running. In desktop it runs many more cycles of `go` so you get more of the minimum timer bits coming out, so it's less noticeable. The solution is just to track how far the ticks advanced and only reset if it went somewhere at all.
1 parent ca8e0e1 commit e9abdfc

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

Sample Models/Biology/Evolution/Bug Hunt Camouflage.nlogox

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ globals [
3131
max-number-of-brightness ;; scaling value for initial histograms
3232
avg-red-gene ;; mean avg-red-gene
3333
avg-init-red-gene ;; mean avg-red-gene initial value
34-
avg-green-gene ;; mean avg-green-gene
35-
avg-init-green-gene ;; mean avg-green-gene initial value
36-
avg-blue-gene ;; mean avg-blue-gene
37-
avg-init-blue-gene ;; mean avg-blue-gene initial value
34+
avg-green-gene ;; mean avg-green-gene
35+
avg-init-green-gene ;; mean avg-green-gene initial value
36+
avg-blue-gene ;; mean avg-blue-gene
37+
avg-init-blue-gene ;; mean avg-blue-gene initial value
3838
vector-difference
3939

40+
last-advance ;; track tick advance for timer resolution
4041
]
4142

4243

@@ -58,7 +59,9 @@ end
5859

5960

6061
to go
61-
reset-timer
62+
if last-advance != 0 [
63+
reset-timer
64+
]
6265
grow-bugs
6366
eat-bugs
6467
reproduce-bugs
@@ -68,7 +71,8 @@ to go
6871
;; we don't only want to count the time that passes while the GO
6972
;; button is actually down, so that's why we do RESET-TIMER above,
7073
;; so we can measure how time has actually been spent in GO.
71-
tick-advance timer
74+
set last-advance timer
75+
tick-advance last-advance
7276

7377
;; plotting takes time, so only plot 10 times a second
7478
every 0.1 [ calculate-gene-metrics update-plots ]

0 commit comments

Comments
 (0)