DMelt:AI/Cellular Automaton

From HandWiki
Member

Cellular automaton

Read Cellular_automaton first. To start a cellular automaton framework based on Cambria Java library, run the script:

from jhplot  import *
c=HCellular()
c.visible()
print c.getRules()
c.setRule("Aggregation")
c.visible()
print c.getRule()
print c.getInitString()

You will see a window as this:

DMelt example: Cellular automaton using aggregation rule

To start the simulation, press [Start] below the main canvas.

There are a few important methods to extract and set cellular automaton rules:

First, you can see the default rule and initial parameters as with the method getRule():

>>> print c.getRule()
>>> print c.getInitString()

You can list all available rules as:

>>> print c.getRules()

Finally, one can set a given rule as:

>>> c.setRule("Aggregation")


Here is a complete example:

from jhplot  import *
c=HCellular()
c.setRule("Aggregation")
c.visible()
print c.getRule()
print c.getInitString()

Read Cambria Java for more information.