From a5dbd69976d0868940aa8ec3205e24e7ee9d0101 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Wed, 5 Jun 2024 23:51:55 +0200 Subject: [PATCH] branchless experiments (failed and reverted, see commented code) --- src/play.go | 7 ++++++- various-tests/writepixel/main.go | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/play.go b/src/play.go index 6f109e1..a41497c 100644 --- a/src/play.go +++ b/src/play.go @@ -133,9 +133,13 @@ func (scene *ScenePlay) UpdateCells() { // set history to current generation so we can infer the // age of the cell's state during rendering and use it to // deduce the color to use if evolution tracing is enabled + // 60FPS: if state != nextstate { scene.History.Data[y][x] = scene.Generations } + + // 10FPS: + //scene.History.Data[y][x] = (state ^ (1 ^ nextstate)) * (scene.Generations - scene.History.Data[y][x]) } } @@ -446,7 +450,8 @@ func (scene *ScenePlay) Draw(screen *ebiten.Image) { float64(y*scene.Config.Cellsize), ) - age = scene.Generations - scene.History.Data[y][x] + //age = scene.Generations - scene.History.Data[y][x] + age = scene.History.Data[y][x] switch scene.Grids[scene.Index].Data[y][x] { case Alive: diff --git a/various-tests/writepixel/main.go b/various-tests/writepixel/main.go index edc7497..dabe5b7 100644 --- a/various-tests/writepixel/main.go +++ b/various-tests/writepixel/main.go @@ -252,6 +252,17 @@ func main() { ym := y & (c - 1) fmt.Println(xm & ym) + + a := 1 + b := 1 + //gen := 100 + hist := 0 + for gen := 0; gen < 50; gen++ { + fmt.Println((a ^ (1 ^ b)) * (gen - hist)) + if gen == 25 { + a = 0 + } + } } func _main() {