Anonymous user
Conway's Game of Life: Difference between revisions
→{{header|Elena}}
Line 3,330:
=={{header|Elena}}==
ELENA 3.
<lang elena>
import system'text.
const int maxX = 48.
const int maxY = 28.
limited
{
action eval
}
Line 3,352 ⟶ 3,353:
bool started.
constructor newRandomset
[
theSpace := IntMatrixSpace new
theRuleSet := transformSet.
Line 3,363 ⟶ 3,364:
]
constructor newLoaded
[
theSpace := IntMatrixSpace new
theRuleSet := transformSet.
Line 3,375 ⟶ 3,376:
[
if ($nil != theListener)
[ theListener eval
]
Line 3,386 ⟶ 3,387:
[
if (started)
[ theSpace update
[ started := true. ].
Line 3,395 ⟶ 3,396:
const int DELAY = 50.
symbol testSet = ((0,1,0),
class gameOfLifeRuleSet = BaseRuleSet▼
(0,1,0),
(0,1,0)).
▲class gameOfLifeRuleSet = BaseRuleSet::
{
validate
[
int cell := s getAt
int number := s getLiveCell
if ((cell == 0) && (number == 3))
Line 3,411 ⟶ 3,416:
]
}.
extension space presenterOp
{
print
[
console setCursorPosition int:0 int:0.
int columns := self columns.
int rows := self rows.
int i := 0.
int j := 0.
while (i < rows)
[
j := 0.
while (j < columns)
[
int cell := self getAt int:i int:j.
console write((cell == 0)iif(" ","o")).
j := j + 1.
i := i + 1.
console writeLine.
].
]
}
program =
Line 3,416 ⟶ 3,451:
console clear.
var model := Model newRandomset
model onUpdate
▲ (&space:sp) [ sp print ].
until (console
[
model run.
|