DECLARE SUB clusterise (x%, y%, colour%) TYPE coord x AS INTEGER y AS INTEGER END TYPE DIM SHARED currentpoint%(3) DIM SHARED Recnum& DIM SHARED coords AS coord INPUT "Percolation Probability (0 to 1):", p SCREEN 12 DO CLS OPEN "points.dat" FOR RANDOM AS #1 LEN = 4 Recnum& = 0 RANDOMIZE TIMER FOR y% = 0 TO 479 FOR x% = 0 TO 639 IF RND < p THEN PSET (x%, y%) NEXT x% NEXT y% SLEEP 1 colour% = 1 FOR y% = 0 TO 479 FOR x% = 0 TO 639 GET (x%, y%)-(x%, y%), currentpoint% IF currentpoint%(2) = -32640 AND currentpoint%(3) = -32640 THEN PSET (x%, y%), colour% MOD 14 + 1 clusterise x%, y%, colour% MOD 14 + 1 WHILE Recnum& > 1 GET #1, Recnum&, coords xx% = coords.x yy% = coords.y Recnum& = Recnum& - 1 clusterise xx%, yy%, colour% MOD 14 + 1 WEND colour% = colour% + 1 END IF NEXT x% NEXT y% SLEEP 15 CLOSE #1 KILL "points.dat" LOOP SCREEN 0 SUB clusterise (x%, y%, colour%) IF x% > 0 THEN GET (x% - 1, y%)-(x% - 1, y%), currentpoint% IF currentpoint%(2) = -32640 AND currentpoint%(3) = -32640 THEN PSET (x% - 1, y%), colour% Recnum& = Recnum& + 1 coords.x = x% - 1 coords.y = y% PUT #1, Recnum&, coords END IF END IF IF x% < 639 THEN GET (x% + 1, y%)-(x% + 1, y%), currentpoint% IF currentpoint%(2) = -32640 AND currentpoint%(3) = -32640 THEN PSET (x% + 1, y%), colour% Recnum& = Recnum& + 1 coords.x = x% + 1 coords.y = y% PUT #1, Recnum&, coords END IF END IF IF y% > 0 THEN GET (x%, y% - 1)-(x%, y% - 1), currentpoint% IF currentpoint%(2) = -32640 AND currentpoint%(3) = -32640 THEN PSET (x%, y% - 1), colour% Recnum& = Recnum& + 1 coords.x = x% coords.y = y% - 1 PUT #1, Recnum&, coords END IF END IF IF y% < 479 THEN GET (x%, y% + 1)-(x%, y% + 1), currentpoint% IF currentpoint%(2) = -32640 AND currentpoint%(3) = -32640 THEN PSET (x%, y% + 1), colour% Recnum& = Recnum& + 1 coords.x = x% coords.y = y% + 1 PUT #1, Recnum&, coords END IF END IF END SUB