Anonymous user
Langton's ant: Difference between revisions
→flip x directions since in Processing +y axis is downward, add comment for less confusion, remove alert box, remove example image
m (→{{header|Perl}}: fixed: use a uninitialized variable in substraction) |
|||
Line 2,984:
=={{header|Processing}}==
Processing implementation, this uses two notable features of Processing, first of all, the animation is calculated with the draw() loop, second the drawing on the screen is also used to represent the actual state.
<lang processing>/*
* we use the following conventions:
* directions 0: up, 1:
*
* pixel white: true, black: false
Line 3,025 ⟶ 3,023:
for(int i=0;i<STEP;i++) {
count++;
boolean pix=get(x,y)!=-1; //white =-1
setBool(x,y,pix);
Line 3,048 ⟶ 3,046:
break;
case 1:
x
break;
case 2:
Line 3,054 ⟶ 3,052:
break;
case 3:
x
break;
}
|