Found this neat little flash game/thing and made myself a port of it to TI-Basic.
TI-Basic version uses a reference List (L1) to see whether conditions should yield an on or off pixel, so it doesn't use much memory other than the draw screen. The way it references which element of L1 is by using a list (Ans) storing which pxl-Test is where in comparison to the current (D,O) coordinate, and multiplying each pxl-Test by an increasing factor of 2. Then using a sum, it can determine which situation the current (D,O) to reference from L1. Before actually checking, it turns on current (D,O) pixel, and if the situation requires an off pixel, it turns the current pixel back off, otherwise remain on. This was done so you can follow a blinking pixel to see where the current (D,O) coordinates are.
Each successive iteration moves the current Ans list elements over, so it doesn't need to call 3 pxl-Test('s per iteration, and instead only 1 at the cost of having to move two elements in a list.
After running through a complete row, it changes the current Ans list so it can use the two new pxl-Test('s that it would otherwise not have seen, and would have used the previous row's values. This is there partly for each new row, but also for initialization of the Ans list on the first pass.
Which situation each element of L1 represents can be expressed as a binary set of pixels, however since the program runs the O coordinate from left to right, the binary reflects that.
The situation I have laid out below will require each new row of pixels to turn on only when one pixel is on above it on either the left or right (100, or 001), however this can be changed to whatever you desire.
The other portion of code that's meant to be changed is which pixels you turn on to start the program. Since the program relies on using pixels for information, it will require at least one be on for much to really happen. You can however turn on multiple pixels for different results, and I do recommend doing so.
And the code:
Code:
This situation exactly as is will draw the Sierpinski Triangle, however there are many ways to run into this pattern, as it often shows up in this program.
Have fun playing with it.
TI-Basic version uses a reference List (L1) to see whether conditions should yield an on or off pixel, so it doesn't use much memory other than the draw screen. The way it references which element of L1 is by using a list (Ans) storing which pxl-Test is where in comparison to the current (D,O) coordinate, and multiplying each pxl-Test by an increasing factor of 2. Then using a sum, it can determine which situation the current (D,O) to reference from L1. Before actually checking, it turns on current (D,O) pixel, and if the situation requires an off pixel, it turns the current pixel back off, otherwise remain on. This was done so you can follow a blinking pixel to see where the current (D,O) coordinates are.
Each successive iteration moves the current Ans list elements over, so it doesn't need to call 3 pxl-Test('s per iteration, and instead only 1 at the cost of having to move two elements in a list.
After running through a complete row, it changes the current Ans list so it can use the two new pxl-Test('s that it would otherwise not have seen, and would have used the previous row's values. This is there partly for each new row, but also for initialization of the Ans list on the first pass.
Which situation each element of L1 represents can be expressed as a binary set of pixels, however since the program runs the O coordinate from left to right, the binary reflects that.
The situation I have laid out below will require each new row of pixels to turn on only when one pixel is on above it on either the left or right (100, or 001), however this can be changed to whatever you desire.
The other portion of code that's meant to be changed is which pixels you turn on to start the program. Since the program relies on using pixels for information, it will require at least one be on for much to really happen. You can however turn on multiple pixels for different results, and I do recommend doing so.
And the code:
Code:
:{0,1,0,0,1,0,0,0->L1
:ClrDraw
:Pxl-On(0,47
:For(D,1,62
:{0,2pxl-Test(D-1,1),4pxl-Test(D-1,2
:For(O,1,93
:{Ans(2)/2,Ans(3)/2,4pxl-Test(D-1,O+1
:Pxl-On(D,O
:If not(L1(1+sum(Ans
:Pxl-Off(D,O
:End
:End
This situation exactly as is will draw the Sierpinski Triangle, however there are many ways to run into this pattern, as it often shows up in this program.
Have fun playing with it.