Source of: Random Walker, by Gemini 2.5 Flash
32 lines, no comments ยท 223 tokens, written in 2 seconds for $0.0006
1 let x, y;
2
3 function setup() {
4 createCanvas(400, 400);
5 background(220);
6 x = width / 2;
7 y = height / 2;
8 }
9
10 function draw() {
11 stroke(0);
12 point(x, y);
13
14 let choice = floor(random(4));
15 switch (choice) {
16 case 0:
17 x++;
18 break;
19 case 1:
20 x--;
21 break;
22 case 2:
23 y++;
24 break;
25 case 3:
26 y--;
27 break;
28 }
29
30 x = constrain(x, 0, width - 1);
31 y = constrain(y, 0, height - 1);
32 }