Another Sierpinski Triangle Program for the Color Computer

As part of my continuing series of fractal programs for the TRS-80 Color Computer emulator, I am offering the following program that was converted from an AppleSoft example at RosettaCode. The program creates the classic “Chaos Game” Sierpinski  triangle. We showed a version of this program that creates the Sierpinski Triangle in a slightly different fashion earlier. You can find a complete run down on origins of the Sierpinski Triangle in that article.

I made the decision to make a few optimizations to this latest version of the  program, namely to allow the program to be a little easier to configure in line 40 with the max and min X and Y ranges for the graphics capabilities of the platform. The thing I liked about this version of the program is it’s brevity and simplicity and it was a quick thing to convert and enjoy.

A key difference from the first program is the orientation with the base of the triangle at the top of the screen and pointing downwards. Additionally the PMODE for this program is set to color the screen background white and the PSET command later on sets the pixels to orange for a little artistic license. Change as you like and feel free to experiment.

10 REM BASED OFF EXAMPLE AT https://rosettacode.org/wiki/Chaos_game#Applesoft_BASIC
20 REM MODIFIED 1/1/22 BY JON ALMADA
30 REM SET X,Y COORDINATE MAX RANGE FOR YOUR PLATFORM
40 XC = 255 : YC = 191 : HXC = INT(XC/2) : HYC = INT(Y/2)
50 REM BEGIN THE PROGRAM
60 PMODE 3,1 : PCLS : SCREEN 1,1
70 REM GRAPHICS SIZE RANGE FOR X AND Y
80 X = RND(1) * XC
90 Y = RND(1) * YC
100 FOR I=1 TO 20000
110 V = RND(3)
120 ON V GOTO 130,160,190
130 X = X/2
140 Y = Y/2
150 GOTO 210
160 X = HXC + (HXC-X)/2
170 Y = YC – (YC-Y)/2
180 GOTO 210
190 X = XC – (XC-X)/2
200 Y = Y / 2
210 PSET(X,Y,0)
220 NEXT I
230 GOTO 230

Running the Program

As most people do not own a working vintage Color Computer, the VCC Color Computer Emulator will suffice and is, more importantly, FREE.

This software emulates all types of Color Computer systems and comes with built-in BASIC to allow one to run original Radio Shack software or create their own from scratch. The software emulates all manner of varieties and peripherals that the COCO supported during it’s heyday.

Scrape and then paste the code into the VCC emulator and then type “RUN” to execute the code. I recommend you get a cup of coffee and return to slowly watch the art emerge as the formula iterates and feeds into itself over time.

Enjoy the code and I hope this inspires you to use simple retro systems like the Color Computer to explore math and science concepts. — Jon