XUtils

CA Art

A small project aimed at learning Scala on intermediate level by experimenting with Cellular Automata


CA Art

Hi there. This repository consists of a few examples of Cellular Automata, the common part of the code (“the engine”) and the graphical user interface made in JavaFX and FXGL.

After compilation, you can run an example from the sbt shield. There are five of them:

  1. Game of Life (“life”)
  2. Langton’s Ant (“ant”)
  3. Langton’s Ants in color (“antc”)
  4. Chase (“chase”)
  5. Snake (“snake”)

You can run each one by writing run <example name> in the sbt console or if you want more fine control over the example’s configuration you can use:

>run example=[...] dim=[...] scale=[...] delay=[...] enforcegc=[...]

where the arguments are:

  • example - the name of the example (no default, choose something)
  • dim - the length of one side of the board (default = 100)
  • scale - the length of one side of a cell (default = 8)
  • delay - the forced delay between turns in milliseconds (default = 0) There is also enforcegc. The cellular automaton generates a new board every turn and discards the old one. This creates a lot of garbage to collect and if your JDK use a slow, unoptimized GC then after a few hundreds turns you will start to experience more and more hiccups. enforcegc, if set to true, enforces GC every turn. It results in slower simulations but it fixes the problem. Type run example 1 enforcegc true and see for yourself.

If you run the Game of Life example (with run life) you will see an empty, white window. This is the initial board. You can populate it with the left mouse clicks. When you’re done, start the animation by hitting the space bar. You can always stop the simulation again (with the space bar) and edit the board.


Articles

  • coming soon...