11-16-2023, 06:32 PM
Code: (Select All)
Rem Program ESCAPE.BAS (c) 1994 by J. C. Sprott
Dim a(12) 'Array of coefficients
Randomize Timer 'Reseed random numbers
Screen 12 'Assume VGA graphics
n% = 0
While InKey$ = "" 'Loop until a key is pressed
If n% = 0 Then Call setparams(x, y)
Call advancexy(x, y, n%)
Call testsoln(x, y, n%)
If n% = 1000 Then Call display: n% = 0
Wend
End
Sub advancexy (x, y, n%) 'Advance (x, y) at step n%
Shared a()
xnew = a(1) + x * (a(2) + a(3) * x + a(4) * y) + y * (a(5) + a(6) * y)
y = a(7) + x * (a(8) + a(9) * x + a(10) * y) + y * (a(11) + a(12) * y)
x = xnew
n% = n% + 1
End Sub
Sub display () 'Plot escape-time contours
For i% = 0 To 639
For j% = 0 To 479
x = -5 + i% / 64
y = 5 - j% / 48
n% = 0
While n% < 128 And x * x + y * y < 1000000
Call advancexy(x, y, n%)
Wend
PSet (i%, j%), n% Mod 16
Next j%
Next i%
_Display
End Sub
Sub setparams (x, y) 'Set a() and initialize (x,y)
Shared a()
x = 0: y = 0
For i% = 1 To 12: a(i%) = (Int(25 * Rnd) - 12) / 10: Next i%
End Sub
Sub testsoln (x, y, n%) 'Test the solution
If n% = 1000 Then n% = 0 'Solution is bounded
If x * x + y * y > 1000000 Then 'Solution escaped
If n% > 100 Then n% = 1000 Else n% = 0
End If
End Sub