branchless experiments (failed and reverted, see commented code)

This commit is contained in:
2024-06-05 23:51:55 +02:00
parent 162d141b34
commit a5dbd69976
2 changed files with 17 additions and 1 deletions

View File

@@ -133,9 +133,13 @@ func (scene *ScenePlay) UpdateCells() {
// set history to current generation so we can infer the // set history to current generation so we can infer the
// age of the cell's state during rendering and use it to // age of the cell's state during rendering and use it to
// deduce the color to use if evolution tracing is enabled // deduce the color to use if evolution tracing is enabled
// 60FPS:
if state != nextstate { if state != nextstate {
scene.History.Data[y][x] = scene.Generations 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), 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] { switch scene.Grids[scene.Index].Data[y][x] {
case Alive: case Alive:

View File

@@ -252,6 +252,17 @@ func main() {
ym := y & (c - 1) ym := y & (c - 1)
fmt.Println(xm & ym) 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() { func _main() {