Langton's ant: Difference between revisions

m (→‎{{header|Perl}}: fixed: use a uninitialized variable in substraction)
Line 2,984:
 
=={{header|Processing}}==
{{incorrect|Processing|The chirality of the output is reversed, meaning the ant is turning left when the spec says it should turn right, and vice-versa.}}
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.
[[File:ant-processing.png|thumb|right|Sample output]]
<lang processing>/*
* we use the following conventions:
* directions 0: up, 1: rightleft, 2: down: 3: leftright
*
* 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;
}
Anonymous user