Elementary cellular automaton: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
|||
Line 1,512: | Line 1,512: | ||
</pre> |
</pre> |
||
=={{header|Peri}}== |
|||
<syntaxhighlight lang="peri"> |
|||
###sysinclude standard.uh |
|||
###sysinclude system.uh |
|||
###sysinclude args.uh |
|||
###sysinclude str.uh |
|||
#g argc 4 < { ."Usage: " 0 argv sprint SPACE 1 argv sprint SPACE ."rule size\n" |
|||
."The \"rule\" and \"size\" are numbers.\n" |
|||
."0<=rule<=255\n" end } |
|||
terminallines 3 - sto gen |
|||
3 argv #s (#g) sto maxcell |
|||
2 argv (#g) sto rule |
|||
#g argc 5 >= { 4 argv #s (#g) sto gen } |
|||
@maxcell mem !maximize sto livingspace |
|||
@maxcell mem sto originallivingspace |
|||
@maxcell {{ @livingspace {{}} 0 inv [] }} @livingspace @maxcell #g 2 / 1 inv [] |
|||
{.. |
|||
originallivingspace @livingspace #s = |
|||
livingspace {~ #k {~?~} { '* }{ '. } print ~} NL |
|||
#g |
|||
livingspace~ lsp: {{ |
|||
zero aa |
|||
@originallivingspace {{}} ? @maxcell -- [] { 4 sto aa } |
|||
@originallivingspace {{}} [] { @aa 2 | sto aa } |
|||
@originallivingspace {{+}} @maxcell == { 0 }{ {{+}} } [] { @aa 1 | sto aa } |
|||
8 {{ @rule 1 {{}} << & { |
|||
{{}} @aa == { @livingspace {{}}§lsp 1 inv [] {{<}}§lsp } |
|||
} |
|||
}} |
|||
z: @livingspace {{}} 0 inv [] {{<}} |
|||
}} |
|||
#s @originallivingspace @livingspace == { {.>.} } |
|||
@gen { {..} @gen #g == { {.>.} } } |
|||
{..} sto l |
|||
..} |
|||
."Generations: " l #g printnl |
|||
@livingspace inv mem |
|||
@originallivingspace inv mem |
|||
end |
|||
{ „maxcell” } |
|||
{ „rule” } |
|||
{ „state” } |
|||
{ „livingspace” } |
|||
{ „originallivingspace” } |
|||
{ „aa” } |
|||
{ „gen” } |
|||
// =============================================================================== |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
peri eca.upu 90 100 33 |
|||
..................................................*................................................. |
|||
.................................................*.*................................................ |
|||
................................................*...*............................................... |
|||
...............................................*.*.*.*.............................................. |
|||
..............................................*.......*............................................. |
|||
.............................................*.*.....*.*............................................ |
|||
............................................*...*...*...*........................................... |
|||
...........................................*.*.*.*.*.*.*.*.......................................... |
|||
..........................................*...............*......................................... |
|||
.........................................*.*.............*.*........................................ |
|||
........................................*...*...........*...*....................................... |
|||
.......................................*.*.*.*.........*.*.*.*...................................... |
|||
......................................*.......*.......*.......*..................................... |
|||
.....................................*.*.....*.*.....*.*.....*.*.................................... |
|||
....................................*...*...*...*...*...*...*...*................................... |
|||
...................................*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.................................. |
|||
..................................*...............................*................................. |
|||
.................................*.*.............................*.*................................ |
|||
................................*...*...........................*...*............................... |
|||
...............................*.*.*.*.........................*.*.*.*.............................. |
|||
..............................*.......*.......................*.......*............................. |
|||
.............................*.*.....*.*.....................*.*.....*.*............................ |
|||
............................*...*...*...*...................*...*...*...*........................... |
|||
...........................*.*.*.*.*.*.*.*.................*.*.*.*.*.*.*.*.......................... |
|||
..........................*...............*...............*...............*......................... |
|||
.........................*.*.............*.*.............*.*.............*.*........................ |
|||
........................*...*...........*...*...........*...*...........*...*....................... |
|||
.......................*.*.*.*.........*.*.*.*.........*.*.*.*.........*.*.*.*...................... |
|||
......................*.......*.......*.......*.......*.......*.......*.......*..................... |
|||
.....................*.*.....*.*.....*.*.....*.*.....*.*.....*.*.....*.*.....*.*.................... |
|||
....................*...*...*...*...*...*...*...*...*...*...*...*...*...*...*...*................... |
|||
...................*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.................. |
|||
..................*...............................................................*................. |
|||
.................*.*.............................................................*.*................ |
|||
Generations: 33 |
|||
</pre> |
|||
=={{header|GFA Basic}}== |
=={{header|GFA Basic}}== |