Anonymous user
Langton's ant: Difference between revisions
→{{header|Java}}: One line was out of order
(→{{header|Common Lisp}}: Break out display logic.) |
(→{{header|Java}}: One line was out of order) |
||
Line 1,517:
</pre>
=={{header|Java}}==
This implementation allows for sizes other than 100x100, marks the starting position with a green box (sometimes hard to see at smaller zoom levels and the box is smaller than the "pixels" so it doesn't cover up the color of the "pixel" it's in), and includes a "zoom factor" (<code>ZOOM</code>) in case the individual "pixels" are hard to see on your monitor.
<lang java>import java.awt.Color;
Line 1,561 ⟶ 1,560:
int xChange = 0, yChange = -1; //start moving up
while(antX < width && antY < height && antX >= 0 && antY >= 0){
plane[antY][antX] = !plane[antY][antX];▼
if(plane[antY][antX]){
//turn left
Line 1,581 ⟶ 1,579:
}
}
▲ plane[antY][antX] = !plane[antY][antX];
antX += xChange;
antY += yChange;
|