The sand grid hashes the new generator

The draw is 64 bits now, so every grain lands somewhere else and the old
number could not be right again. Re-taken from a run, which is the one
manual step this case has always had.

sand.flan's two calls say (f32 (rand)).
This commit is contained in:
Joseph Ferano 2026-09-21 11:05:03 +07:00
parent efcee7ea07
commit 6df50e9ce1
2 changed files with 29 additions and 8 deletions

View File

@ -25,6 +25,28 @@
(defonce velocity [rows [cols f32]])
(defonce current-color dyn 0)
(defn insertion-sort [coll [$t]] ()
{:where (ordered? $t)}
(let [i 1
length (len coll)]
(while (and (< i length))
(let [j i]
(while (and (> j 0)
(< (at coll j) (at coll (dec j))))
(let [temp (at coll j)]
(set (at coll j) (at coll (dec j)))
(set (at coll (dec j)) temp))
(-- j)))
(++ i))))
(comment
(insertion-sort [\I \N \S \E \R \T \I \O \N \S \O \R \T])
(insertion-sort (slice [6 2 4 9 1 9 4 5] 0 8))
(let [str (bytes "INSERTIONSORT")]
(insertion-sort str)
(println str))
:-)
(defn clear-grid [] ()
(set grid (zeroed))
(set velocity (zeroed)))
@ -41,7 +63,7 @@
(when (and (>= r 0) (< r (- rows 1))
(>= c 0) (< c (- cols 1))
(= 0 (at grid r c))
(< (rand-f32) 0.5))
(< (f32 (rand)) 0.5))
(set (at grid r c) (dyn->u32 (at colors current-color)))
(set (at velocity r c) 1.0)))))))
@ -61,7 +83,7 @@
(let [side (cond
(not left?) 1
(not right?) -1
:else (if (< (rand-f32) 0.5) 1 -1))]
:else (if (< (f32 (rand)) 0.5) 1 -1))]
(set (at grid y (+ col side)) (at grid row col))
(set (at grid row col) 0)
(set (at velocity y (+ col side)) vel)

View File

@ -2267,12 +2267,11 @@ let () =
libraylib on every target, and this one is the version meant to run on
wasm32 too. The hash is reproducible only because rand is ours.
The number below is the *old* generator's grid and cannot be right
again: a draw is 64 bits now and every grain lands somewhere else. When
sand.flan is brought up to date and these rows run again, the hash is
re-taken from the run that is the one manual step, and it is the
normal one for this case. *)
let sand_out = "15595743031174623232\n" in
The number below was re-taken when the generator changed: a draw is 64
bits now and every grain lands somewhere else, so the old grid's hash
could not be right again. Re-taking it from a run is the one manual
step, and it is the normal one for this case. *)
let sand_out = "7623511701454096497\n" in
if sand_checks then begin
outputs "sand, headless" "programs/sand-headless.flan" sand_out;
outputs ~opt:"-O0" "sand, headless, -O0" "programs/sand-headless.flan"