'Small Basic challenge of the month February 2019 (Partial Solution)
'Write a program that will join up some random points to draw an irregular convex polygon (no side lines cross each other).
'CONFIG
dotSize = 10 'The size of the dots
maxDots = 10 'The maximum number of dots that can be generated
'MAIN
dotCount = Math.GetRandomNumber(maxDots-3) + 3 'Determine the number of dots to be generated
GraphicsWindow.PenWidth = 0
GraphicsWindow.BrushColor = "Red"
For i = 1 To dotCount 'Randomise the dots and draw them to the graphics window
x[i] = Math.GetRandomNumber(gw - dotSize)
y[i] = Math.GetRandomNumber(gh - dotSize)
connected[i] = "False"
GraphicsWindow.FillEllipse(x[i] - dotSize/2, y[i] - dotSize/2, dotSize, dotSize)
EndFor
GraphicsWindow.PenWidth = 1
GraphicsWindow.PenColor = "Black"
For i = 1 To dotCount 'Draw lines between the dots
otherDot = Math.GetRandomNumber(dotCount) 'Select a dot to draw a line to
'BUG: the following loop runs infinitely in some situations
While connected[otherDot] = "True" Or otherDot = i Or originator[otherDot] = i 'Select a different dot if this dot already has a line to it.
otherDot = Math.GetRandomNumber(dotCount)
EndWhile
GraphicsWindow.DrawLine(x[i],y[i],x[otherDot],y[otherDot])
connected[otherDot] = "True"
originator[i] = otherDot
EndFor