diff --git a/README.md b/README.md index 9b04523..4a1fd9f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,21 @@ +# Cellular Automata Demo -The demo simply consists of a 36x36 tilemap of blue and white tiles. Blue tiles represent the walls, and white tiles represent the floor tiles. There are two buttons, one that resets the simulation, and the other button triggers the CA algorithm and uses the tilemap to demonstrate the results. +cover image -Also added to the demo is access to some of the variables that manipulate the simulation. We can now modify the behavior of the OOB indexes. For instance, instead of the default 'walls', you can now change the sim to use random setting, mirror the edge tile, or set it constant to 'wall' or 'floor'. +## Description -You also have to ability to see what happens when you unbalance the trigger points. Above we defined 3 and 5 as the trigger points for flipping a tile's state. You have the ability to modify that and see the results it has on the simulation. +The demo simply consists of a 36x36 tilemap of blue and white tiles. Blue tiles represent the walls, and white tiles represent the +floor tiles. There are two buttons, one that resets the simulation, and the other button triggers the CA algorithm and uses the tilemap +to demonstrate the results. -The demo starts with a noise field which is a plugin for Excalibur. Using a numbered array representing the 36x36 tilemap, which has ones and zeroes we can feed this array into the CA function. You can repeatedly press the 'CA Generation Step' button and the same array can be re-fed into the algorithm to see the step by step iteration, and then can be reset to a new noise field again to start over. +Also added to the demo is access to some of the variables that manipulate the simulation. We can now modify the behavior of the OOB +indexes. For instance, instead of the default 'walls', you can now change the sim to use random setting, mirror the edge tile, or set +it constant to 'wall' or 'floor'. + +You also have to ability to see what happens when you unbalance the trigger points. Above we defined 3 and 5 as the trigger points for +flipping a tile's state. You have the ability to modify that and see the results it has on the simulation. + +The demo starts with a noise field which is a plugin for Excalibur. Using a numbered array representing the 36x36 tilemap, which has +ones and zeroes we can feed this array into the CA function. You can repeatedly press the 'CA Generation Step' button and the same +array can be re-fed into the algorithm to see the step by step iteration, and then can be reset to a new noise field again to start +over. diff --git a/image-19.png b/image-19.png new file mode 100644 index 0000000..671db62 Binary files /dev/null and b/image-19.png differ diff --git a/src/CA.ts b/src/CA.ts index b28b4ac..81aa84e 100644 --- a/src/CA.ts +++ b/src/CA.ts @@ -62,7 +62,7 @@ function countAdjacentWalls(map: number[], width: number, height: number, index: if (coinflip > 0.5) count++; break; case "mirror": - if (i == 0 || j == 0) count++; + if (map[index] == 1) count++; break; default: count++; // Perceive out of bounds as wall diff --git a/src/main.ts b/src/main.ts index 5ffcf1c..3f698ee 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,6 @@ import "./style.css"; import { UI } from "@peasy-lib/peasy-ui"; import { Engine, DisplayMode, TileMap, Vector } from "excalibur"; import { bluey, model, template, whitey } from "./ui"; -//@ts-expect-error import { PerlinGenerator } from "@excaliburjs/plugin-perlin"; export let generator: PerlinGenerator;