Langton's ant: Difference between revisions
Content deleted Content added
Updated to compile with Nim 1.4 |
|||
Line 1,744:
=={{header|Dyalect}}==
<lang dyalect>
func move(ant) {
ant::position::x += xInc[ant::direction]
ant::position::y += yInc[ant::direction]
}
func Array.step(ant) {
var ptCur = (x
var leftTurn = this[ptCur::x][ptCur::y]
ant.direction =
if leftTurn {
leftTurns[ant::direction]
} else {
rightTurns[ant::direction]
}
this[ptCur::x][ptCur::y] = !this[ptCur::x][ptCur::y]
move(ant)
ptCur = (x
ant::outOfBounds =
ptCur::x < 0 ||
ptCur::x >= ant::width ||
ptCur::y < 0 ||
ptCur::y >= ant::height
ant::position
}
func newAnt(width, height) {
(
position
origin
outOfBounds
isBlack
direction
width
height
)
}
func run() {
while !ant::outOfBounds {
blacks.step(ant)
}
|