18-97-14-85.crawl.commoncrawl.org | ToothyWiki | Kazuhiko | RecentChanges | Login
- [Click to play]
A CellularAutomata implemented in ToothyGDL. Not really a game since it currently has no objectives, but more of a sand-box.
Instructions: While the flow is stopped, click on any of the central red squares to toggle them between earth (non-conductive) and copper (conductive). Then start the flow to see the electrons move along your wires.
Most controls are disabled during actual animation due to the response time. Just click as fast as you can on the stop button to return to the stopped state so you can actually edit stuff. The actual automaton is based on the [WireWorld Computer] so, with a big enough grid, you could theoretically calculate primes by using their layout.
I wouldn't recommend it.
Very much dependent on the speed of your computer for actual performance. Works slightly faster in FireFox than IE. More annoyingly, IE insists on putting spaces between the blocks which makes it quite hard to see what is going on.
ToothyGDL: [Recompile] - [View compiler errors]
logic
{
// ~~~~~~~ Initial board layout
// 84|21 - {dead/cold/warm/hot}{void/copper/adamantine/earth}
// 0 = void
// 3 = earth
// 5 = copper - cold
// 9 = copper - warm
// 13 = copper - hot
// 6 = adamantine - cold
// 10 = adamantine - warm
// 14 = adamantine - hot
array board
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 14, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 6, 6, 0, 0, 0,
0, 6, 0, 10, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 6, 0, 0,
0, 6, 0, 6, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 6, 0, 6, 0,
0, 0, 6, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 6, 6, 6, 0,
0, 0, 6, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 6, 0, 0,
0, 0, 6, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 6, 0, 0,
0, 6, 6, 6, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 6, 0, 0,
0, 6, 0, 6, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 6, 0, 6, 0,
0, 0, 6, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 10, 0, 6, 0,
0, 0, 0, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 14, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}
int boardwidth { 20 }
int boardheight { 12 }
// Start / stop and zoom settings
int animate { 0 }
int zoom { 1 }
// Scratch variable for test calculations
int hot {0}
int else {0}
// Allow animation to be stopped/started
when {!animate}
allow {animate = 1;}
label {"start"}
when {animate}
allow {animate = 0;}
label {"stop"}
// Zoom in/out actions
when {!animate and !zoom}
allow {zoom = 1;}
label {"zoom in"}
when {!animate and zoom}
allow {zoom = 0;}
label {"zoom out"}
// Allow earth/copper toggle for all squares
for i (0 .. ((boardheight*boardwidth)-1))
{
when {!animate and ((board[i] == 5) or (board[i] == 9) or (board[i] == 13))}
allow {board[i] = 3;}
label {"toggle " i}
when {!animate and (board[i] == 3)}
allow {board[i] = 5;}
label {"toggle " i}
}
// The magic tick
when {animate}
allow
{
for i (0 .. ((boardheight*boardwidth)-1))
{
else = 1;
if ((board[i] & 12 == 8) or (board[i] & 12 == 12))
{
board[i] = (board[i]+12) % 16;
else = 0;
}
if (else and (board[i] & 12 == 4))
{
hot = 0;
if (board[i-1 ]&12 == 8) {hot++;}
if (board[i-(boardwidth+1)]&12 == 8) {hot++;}
if (board[i-boardwidth ]&12 == 8) {hot++;}
if (board[i-(boardwidth-1)]&12 == 8) {hot++;}
if (board[i+1 ]&12 == 12) {hot++;}
if (board[i+(boardwidth+1)]&12 == 12) {hot++;}
if (board[i+boardwidth ]&12 == 12) {hot++;}
if (board[i+(boardwidth-1)]&12 == 12) {hot++;}
if ((hot == 1) or (hot == 2)) {board[i] = (board[i]+8) % 16;}
}
}
}
label {"tick"}
// The not-so-magic tock
// Code must be kept identical to the tick above.
when {!animate}
allow
{
for i (0 .. ((boardheight*boardwidth)-1))
{
else = 1;
if ((board[i] & 12 == 8) or (board[i] & 12 == 12))
{
board[i] = (board[i]+12) % 16;
else = 0;
}
if (else and (board[i] & 12 == 4))
{
hot = 0;
if (board[i-1 ]&12 == 8) {hot++;}
if (board[i-(boardwidth+1)]&12 == 8) {hot++;}
if (board[i-boardwidth ]&12 == 8) {hot++;}
if (board[i-(boardwidth-1)]&12 == 8) {hot++;}
if (board[i+1 ]&12 == 12) {hot++;}
if (board[i+(boardwidth+1)]&12 == 12) {hot++;}
if (board[i+boardwidth ]&12 == 12) {hot++;}
if (board[i+(boardwidth-1)]&12 == 12) {hot++;}
if ((hot == 1) or (hot == 2)) {board[i] = (board[i]+8) % 16;}
}
}
}
label {"tock"}
}
display
{
// Traguna Macoides Tracorum Satesdi!
repeatedly { "tick" }
// Display
box {content {"Circuitry v0.7"}}
newline
// Draw the board, assigning all the possible actions as we go
for y ( 0 .. (boardheight-1) )
{
for x ( 0 .. (boardwidth-1) )
{
box
{
bind_action { "toggle " ((y*boardwidth)+x) }
//content {"~"}
if (!zoom)
{
width { 3px }
height { 3px }
}
if (zoom)
{
width { 15px }
height { 15px }
}
// Set background colour
background { #000 }
if (board[(y*boardwidth)+x] == 3) { background { #600 } }
if (board[(y*boardwidth)+x] == 5) { background { #f00 } }
if (board[(y*boardwidth)+x] == 9) { background { #f60 } }
if (board[(y*boardwidth)+x] == 13) { background { #fa0 } }
if (board[(y*boardwidth)+x] == 6) { background { #00f } }
if (board[(y*boardwidth)+x] == 10) { background { #06f } }
if (board[(y*boardwidth)+x] == 14) { background { #0af } }
}
}
newline
}
newline
box {content {" "}}
newline
box
{
content {" Start "}
bind_action {"start"}
background {#999}
while_active {background {#0f0}}
border { 1px solid #000 }
}
box {content {" "}}
box
{
content {" Stop "}
bind_action {"stop"}
background {#999}
while_active {background {#f00}}
border { 1px solid #000 }
}
box {content {" "}}
box
{
content {" Tick "}
bind_action {"tock"}
background {#999}
while_active {background {#ff0}}
border { 1px solid #000 }
}
newline
box {height{3px}}
newline
box {content {"The stop button is a bit sticky so you might have to pound on it for a while..."}}
newline
box {height{3px}}
newline
box
{
content {" Zoom In "}
bind_action {"zoom in"}
background {#999}
while_active {background {#00f}}
border { 1px solid #000 }
}
box {content {" "}}
box
{
content {" Zoom Out "}
bind_action {"zoom out"}
background {#999}
while_active {background {#00f}}
border { 1px solid #000 }
}
newline
box {content {" "}}
newline
}