Add solutions for part 1
This commit is contained in:
32
projects/09/CellAutomaton1D/Main.jack
Normal file
32
projects/09/CellAutomaton1D/Main.jack
Normal file
@@ -0,0 +1,32 @@
|
||||
/** Implements a cellular automaton.
|
||||
*
|
||||
* In the first state the user can define the initial configuration (the cells
|
||||
* that are alive in the beginning. If the user is not sure about which cells
|
||||
* to enable choosing the one in the middle (255/256) is ususually a good
|
||||
* start.
|
||||
*
|
||||
* Next, the user selects the rule they want to simulate. A list of all rules
|
||||
* is available on Wikipedia. If the user is not sure which rule they want Rule
|
||||
* 90 is a good start to get the idea.
|
||||
*
|
||||
* https://en.wikipedia.org/wiki/Elementary_cellular_automaton
|
||||
*
|
||||
* In the second stage the user can select the initial configuration of the
|
||||
* automaton. The keys 'h' and 'l' move the cursor one pixel to the left or
|
||||
* right respectively. By pressing the space bar the user can toggle the
|
||||
* current pixel. By pressing the 'r' key the simulation is started. Pressing
|
||||
* 'q' ends the simulator.
|
||||
*/
|
||||
|
||||
/** Initializes a new Cellular Automaton Game and runs it. */
|
||||
class Main {
|
||||
function void main() {
|
||||
var CellularAutomatonController controller;
|
||||
|
||||
let controller = CellularAutomatonController.new();
|
||||
do controller.initialConfiguration();
|
||||
do controller.run();
|
||||
do controller.dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user