Conway's Game of Life
mark mitchell
cowhead at mac.com
Wed Apr 9 02:51:01 EDT 2003
>
I've done an extremely basic cellular automata in Rev. It ain't much,
and only took about 15 minutes to code, but you're welcome to it. Just
make a scrolling field, set the text format to Courier size 10, then
stick this script in a button or somewhere. The cells are then
different colored apples based on a basic neighbor's rule and a random
first line:
on mouseUp
put "" into field 1
repeat for 91 times
put "" after field 1
put random(2) into zaCol
if zaCol = 1 then
set the textColor of character -1 of field 1 to 255,0,0
else
set the textColor of character -1 of field 1 to 0,0,255
end if
end repeat
put return after field 1
put 0 into zaCOunt
repeat for 50 times
add 1 to zaCount
repeat with i = 1 to 91
if (i - 1) < 0 then
put "" after field 1
put the textColor of character 1 of field 1 into mycol
set the textColor of character -1 of field 1 to myCol
next repeat
end if
if (i + 1) > 91 then
put "" after field 1
put the textColor of character 91 of field 1 into mycol
set the textColor of character -1 of field 1 to myCol
next repeat
end if
put the textColor of character (i - 1) of line zaCount of field 1 into
forCol
put the textColor of character (i + 1) of line zaCount of field 1 into
aftCol
put the textColor of character i of line zaCount of field 1 into
thisCol
put "" after field 1
if forCol = aftCol then
if thisCol = 255,0,0 then
set the textColor of character -1 of field 1 to 0,0,255
else
set the textColor of character -1 of field 1 to 255,0,0
end if
else
set the textColor of character -1 of field 1 to thisCol
end if
end repeat
put return after field 1
end repeat
end mouseUp
--mark mitchell
Japan
More information about the use-livecode
mailing list