' *** Sepinski's Triangle *** ' programed by Joshua Milligan ' started and completed on 1/17/97 ' This program was originally written by Joshua Milligan and his father, ' Stuart Milligan, in GW-Basic format many years ago. On Januarty 17, 1997, ' I, Joshua, went back and rewrote the program for Qbasic (also compatible ' with QuickBasic 4.5). ' A Sepinski Triangle is a fractal that is represented by ' plotting points at random applying only a small set of guidelines. ' The three vertecies of the triangle are plotted first. This can be done ' at random but was not done in this program in order to create a better ' visual effect. Then, a point is chosen, and plotted completely at random. ' One of the three vertices is then chosen, again at random. The midpoint ' between the point and the vertex is plotted. Another vertex is selected ' at random and the midpoint between the previous midpoint and the new vertex ' is plotted. This cycle is repeated to infinitey or until the user quits ' the program. CLS RANDOMIZE TIMER SCREEN 9 X1 = 70 'Assigns the x,y coordinants of the Y1 = 300 'three vertices of the triangle. X2 = 530 'Even this could be determined randomly Y2 = 300 'if so desired. X3 = 280 Y3 = 30 COLOR 14 'Plots the three vertices of the triangle in yellow. PSET (X1, Y1) PSET (X2, Y2) PSET (X3, Y3) x = INT(500 * RND) 'plot the first point at random x,y. y = INT(500 * RND) PSET (x, y), 7 'Select, at random, one of the three vertices of the triangle. 'Determine the midpoint between it and the last point plotted and 'plot this point. Keep track of the numbers of points plotted. 'Terminate when user presses a key. LET numPoints = 1 COLOR 9 DO SELECT CASE INT(RND * 3) CASE 0: x = (X1 + x) / 2: y = (Y1 + y) / 2 CASE 1: x = (X2 + x) / 2: y = (Y2 + y) / 2 CASE 2: x = (X3 + x) / 2: y = (Y3 + y) / 2 END SELECT PSET (x, y) 'pset the point LET numPoints = numPoints + 1 LOCATE 1, 1 PRINT USING "Number of points: ###,###,###"; numPoints LOOP UNTIL INKEY$ <> ""