I have a bad habit of not backing up my programs, but it doesn't make me too mad because the types of programs I write on a calculator nowadays aren't usually worthy of making public anyway. It's been a surprisingly long time since I've accidentally datawiped my 83 PCEEP, so I decided I might as well post the more completed programs here for fun, before they're all lost to time. So here you go: here's every TI-BASIC program currently on my calculator that I've written.

prgmULAMSPRL
This little program, in conjunction with a primality test I made, fills your graphscreen with an Ulam spiral until it dimension errors. It's one of the cooler little graphscreen entertainment programs I've made.

Code:
ClrDraw
AxesOff
GridOff
BackgroundOff
"265*165
"132 82
132→V
82→W
1→N
1→J
Repeat 0
For(S,1,­1,­2
For(I,1,J
V+S→V
N+1→N
prgmISPRIME
If Ans
Pxl-On(W,V,BLACK
End
For(I,1,J
W-S→W
N+1→N
prgmISPRIME
If Ans
Pxl-On(W,V,BLACK
End
J+1→J
End
End

prgmISPRIME
This program is a simple primality test that takes an integer in Ans and returns either a 0 or 1 in Ans depending on primality. I used a custom list in this program instead of using any letter variables because I quickly remembered that TI-BASIC does not support locals! Unless another program happens to use ʟIP, this program won't mess with any of your other data.

Code:
Ans→⌊IP(1)
If ⌊IP(1)≤3
Then:1:Return:End
If not(remainder(⌊IP(1),2) and remainder(⌊IP(1),3
Then:0:Return:End
5→⌊IP(2)
While ⌊IP(2)²≤⌊IP(1)
If not(remainder(⌊IP(1),⌊IP(2)) and remainder(⌊IP(1),⌊IP(2)+2
Then:0:Return:End
⌊IP(2)+6→⌊IP(2)
End
1

prgmTRI
Yet another neat graphscreen entertainment program, this program uses a chaos game to produce a Sierpinski triangle. I forgot what exactly this method is called, but it's a cool demonstration of how chaotic systems can still be limited. Basically, every iteration, a 3 sided die is rolled, each number corresponding to a vertex of a triangle. A new dot is drawn in the midpoint between the last dot drawn and the chosen vertex, and then the program iterates again. Keep in mind that this program assumes that your graphscreen background is not white, as it draws white pixels.

Code:
ZStandard
ZSquare
AxesOff
GridOff
10→Y
0→X
While 1
X→V
Y→W
randInt(0,2
If not(Ans
Then
X/2→X
(10+Y)/2→Y
End
If Ans=1
Then
(­11.547+X)/2→X
(­10+Y)/2→Y
End
If Ans=2
Then
(11.54700538+X)/2→X
(­10+Y)/2→Y
End
Pt-On(X,Y,4,WHITE
"Line(X,Y,V,W,1,WHITE,1
End

prgmTRIARBTR
After I made the above program, I immediately wondered whether the fractal pattern that it produced using three vertices would extend to different regular polygons, so I made a second program that runs the same chaos game, except with an arbitrary number of vertices. I haven't checked to see if this is true, but it seems like a fractal structure is produced when running this game on any shape with an odd number of vertices, and never on a shape with an even number of vertices, though it becomes exponentially more difficult to tell on the small CE graphscreen, as the center area becomes very small very quickly. Make sure to select "0" when it asks if you want to use custom vertices, as I never coded that part of the program in.

Code:
ZStandard
ZSquare
AxesOff
GridOff
Degree
Input "Custom Vertices? ",A
If A
Then


Else
Input "Polygon Num: ",N
N→dim(L₁
N→dim(L₂
If fPart(N/2)=0
Then
360/(2N)→C
Else
0→C
End
0→B
For(A,0+C,360-360/N+C,360/N
B+1→B
10sin(A→L₁(B
10cos(A→L₂(B
End
End
For(A,1,N
If A=N
Then
Line(L₁(N),L₂(N),L₁(1),L₂(1),1,DARKGRAY,1
Else
Line(L₁(A),L₂(A),L₁(A+1),L₂(A+1),1,DARKGRAY,1
End
End
L₁(1→X
L₂(1→Y
While 1
X→V
Y→W
randInt(1,N→A
(L₁(A)+X)/2→X
(L₂(A)+Y)/2→Y
Pt-On(X,Y,4,WHITE
"Line(X,Y,V,W,1,WHITE,1
End

prgmSUPERGAA
It seems like the theme of these programs is neat graphscreen demos. This program raytraces an infinite checkerboard floor pattern that extends to the horizon. By using LTGRAY, MEDGRAY, and GRAY in addition to WHITE and DARKGRAY, this program anti-aliases the whole scene by super-sampling by a factor of 2. Even on a rev M CE, this program takes quite a long time to produce a full scene, so I'd run it, set it down, and go make dinner or something. I made a non-AA version of this program, but it's not nearly as cool and has already been done plenty of times.

Code:
"Focus pos
0→X
0→Y
20→Z
"Center of lens
0→U
10→V
20→W
"X res
264→S
"Y res
164→T
"X width
20→P
"Y width
15→Q
{WHITE,LTGRAY,MEDGRAY,GRAY,DARKGRAY→L₁
For(B,T,82,­1
For(A,0,S-1
U-.5P+A(P/S→M
V→N
W+.5Q-B(Q/T→O
0→C
For(D,­.25(P/S),.25(P/S),.5(P/S
For(E,­.25(Q/T),.25(Q/T),.5(Q/T
If O-Z+E<0
Then
If M-X+D≠0
J/((N-Y)/(M-X+D→K
If N-Y≠0
­Z/((O-Z+E)/(N-Y→J
0→θ
If abs(fPart(J/10))≥.5
not(θ→θ
If abs(fPart(K/10))≥.5
not(θ→θ
If θ
C+1→C
Else
10→C
End
End
End
If C≤4
Then
L₁(C+1→C
Else
BLACK→C
End
Pxl-On(B,A,C
End
End

prgmRNGTEST
This is an interesting little program that I wrote some time ago, and it took me a while today to decipher exactly what it was meant to do. Essentially, this program tests randIntNoRep(0,9 over and over with a different initial seed for rand, keeping track of which seeds produce random lists closest to {0,1,2,3,4,5,6,7,8,9}. It outputs the random list and the seed that generated it each time it produces a list more accurate than the current most accurately produced list. I don't believe this program ever created a perfect list, and I ran it for probably an hour. I believe I wrote this for golfing purposes, where having a perfect 0-9 list would be very advantageous. You can easily search for different lists by altering the list in the sum( command.

Code:
0→A
10→M
{0}→L₂
While 1
A→rand
randIntNoRep(0,9→L₁
sum(not(not(L₁-{0,1,2,3,4,5,6,7,8,9})))→N
If N<M
Then
augment(L₂,{A→L₂
Disp L₁,A
N→M
End
A+1→A
End

prgmRIEMANN
This program is a fairly sophisticated definite integral approximation program, in that it returns the left, right, trapezoidal, and midpoint Riemann sums of an integral with an arbitrary number of divisions, as well as a Simpson's rule approximation and a column that shows each approximations' deviation from the exact answer, all rounded to a specified number of digits. This program was written to streamline an extremely long and boring calculus assignment.

Code:
1→D
While 1
Float
ClrHome
If D
Prompt Y₁,A,B
Input "Round to ? decimals:",U
0→D
Input "Num of divisions:",N
ClrHome
Output(1,1,"MTHD  VAL      ERR
(B-A)/N→H
0→S
For(I,1,N-1
A+IH→X
S+Y₁(X→S
End
(Y₁(A)+S)H→L
(Y₁(B)+S)H→R
(L+R)/2→T
fnInt(Y₁,X,A,B→C
Output(4,1,"L
Output(4,7,round(L,U
Output(4,16,round(C-L,U
Output(5,1,"R
Output(5,7,round(R,U
Output(5,16,round(C-R,U
Output(6,1,"T
Output(6,7,round(T,U
Output(6,16,round(C-T,U
0→M
A+H/2→X
For(I,1,N
M+Y₁(X→M
X+H→X
End
MH→M
Output(7,1,"M
Output(7,7,round(M,U
Output(7,16,round(C-M,U
Output(8,1,"S(2N)
Output(8,7,round((T+2M)/3,U
Output(8,16,round(C-(T+2M)/3,U
Output(10,1,"INT
Output(10,7,C
Pause
End

prgmREVPOL
Finally, something fun! This program simulates a calculator operating using reverse Polish notation. It lacks a fully realized feature set, but it works perfectly fine for addition, subtraction, multiplication, division, exponents, negatives, and floats.

Code:
ClrHome
16→dim(L₁
Fill(0,L₁
{102,92,93,94,82,83,84,72,73,74,103,104,95,85,75,65,55,105,45→L₂
{0,1,2,3,4,5,6,7,8,9,31,32,11,12,13,14,15,21,22→L₃
While 1
ClrHome
For(I,1,9
If L₁(I)≠0
Output(10-I,1,L₁(I
End
"0→Str1
Repeat max(K={21,11,12,13,14,15}) or (K=22 and Str1="0
If K=22
"0→Str1
If Str1="0
Output(10,1,"                         
Output(10,1,Str1
0→K
Repeat K
getKey→K
End
max(L₃*(L₂=K))-(0=max(L₂=K→K
If K≤9 and K≠­1
Then
If Str1="0
Then
toString(K→Str1
Else
Str1+toString(K→Str1
End
End
If K=31 and not(inString(Str1,".
Str1+".→Str1
If K=32 and Str1≠"0
Then
If sub(Str1,1,1)="­
Then
Output(10,length(Str1),"
sub(Str1,2,length(Str1)-1→Str1
Else
"­"+Str1→Str1
End
End
End
If K=21
Then
For(I,15,1,­1
L₁(I→L₁(I+1
End
expr(Str1→L₁(1
End
If max(K={22,11,12,13,14,15
Then
If K=11
L₁(2)+L₁(1→L₁(2
If K=12
L₁(2)-L₁(1→L₁(2
If K=13
L₁(2)*L₁(1→L₁(2
If K=14
L₁(2)/L₁(1→L₁(2
If K=15
L₁(2)^L₁(1→L₁(2
For(I,1,15
L₁(I+1→L₁(I
End
0→L₁(dim(L₁
End
End

prgmGUESSNUM
Honestly, what's a graphing calculator without good ol' guessnum? This program is ENHANCED guessnum and supports highscores! (I wouldn't be surprised if I have written this program a hundred times.)

Code:
randInt(1,100→N
If randInt(1,10)=1
N+.1→N
0→T
Repeat G=N
T+1→T
Input "Guess:",G
If G>N
Disp "Too high!
If G<N
Disp "Too low!
End
Disp "You won in "+toString(T)+" tries!
If T<H
Then
T→H
Disp "New highscore: "+toString(H)+" tries
Else
Disp "Highscore: "+toString(H)+" tries"
End

prgmFIND
This program is a little game that fills your screen with a grid of one character, all except one slightly different character. The goal is to pass all 6 levels as quickly as possible. There is no cursor, you're just supposed to press enter when you've found the odd one out. Honor system, folks.

Code:
ClrHome
"θOŚNEFoceLT→Str1
startTmr→T
For(A,1,length(Str1)/2
randInt(1,10→X
randInt(1,26→Y
For(B,1,10
For(C,1,26
Output(B,C,sub(Str1,2A-1+(X=B and Y=C),1
End
End
Pause
End
Disp checkTmr(T

prgmBOUNCE
This program was influenced by one of the cool demo programs in the SUPERHOT pseudo-filesystem. The screen is covered in a collection of angled mirrors denoted by slash and backslash, with dots coming onscreen from the left. Each time a dot hits a mirror, it is reflected by the mirror while also turning the mirror 90 degrees, so the next dot that hits that mirror goes in the opposite direction. The program runs for some time but eventually has a Dim error that I haven't had the time to weed out.

Code:
ClrHome
{10,20→dim([A]
Fill(0,[A]
[A]→[B]
For(A,2,9
For(B,2,19
If not([A](A-1,B)) and not([A](A+1,B)) and not([A](A,B-1)) and not([A](A,B+1)) and not(randInt(0,4
Then
randInt(1,2→C
C→[A](A,B
Output(A,B,sub(" /\",C+1,1
End
End
End
0→T
Repeat T=1000
[A]→[B]
If not(fPart(T/1
5→[A](randInt(1,10),1
For(A,1,10
For(B,1,20
[A](A,B→C
If C>2
Then
0→[B](A,B
If C=3 and A≠1
Then
[A](A-1,B→D
If A≠1
Then
If not(D
Then
3→[B](A-1,B
Else
If D>2
Then
3→[B](A-1,B
Else
If D=1
Then
5→[B](A-1,B+1
2→[B](A-1,B
End
If D=2
Then
4→[B](A-1,B-1
1→[B](A-1,B
End
End
End
End
End
If C=4 and B≠1
Then
[A](A,B-1→D
If B≠1
Then
If not(D
Then
4→[B](A,B-1
Else
If D>2
Then
4→[B](A,B-1
Else
If D=1
Then
6→[B](A+1,B-1
2→[B](A,B-1
End
If D=2
Then
3→[B](A-1,B-1
1→[B](A,B-1
End
End
End
End
End
If C=5 and B≠20
Then
[A](A,B+1→D
If B≠20
Then
If not(D
Then
5→[B](A,B+1
Else
If D>2
Then
5→[B](A,B+1
Else
If D=1
Then
3→[B](A-1,B+1
2→[B](A,B+1
End
If D=2
Then
6→[B](A+1,B+1
1→[B](A,B+1
End
End
End
End
End
If C=6 and A≠10
Then
[A](A+1,B→D
If A≠10
Then
If not(D
Then
6→[B](A+1,B
Else
If D>2
Then
6→[B](A-1,B
Else
If D=1
Then
4→[B](A+1,B-1
2→[B](A+1,B
End
If D=2
Then
5→[B](A+1,B+1
1→[B](A+1,B
End
End
End
End
End

prgmNEURAL, prgmNEURALNW, prgmNEURALPL, prgmTICTAC
Finally, I've still managed to avoid deleting these enigmas of programs. I wrote all four on a long coast-to-coast flight a year or so back in an attempt to create a functional artificial intelligence via neural network functioning on my CE. This was created using my very primitive knowledge of neural networks and machine learning, so I'm not sure it ever produced any results. In theory, I think it was supposed to, but perhaps I just didn't run it for long enough. It's supposed to train a neural net how to play Tic Tac Toe.

From what I understand by looking at the code, it seems like prgmNEURALNW intializes the neural net to have 20 neurons in 4 rows, with [A] [B] and [C] used for weights between the rows. It also creates ʟSCR to save (I believe) the scores for each of 8 variations in a generation, and ʟSTAT to save highscores.

Code:
9→dim(⌊IN
{54,7→dim([A]
6→dim(⌊N1
{18,7→dim([B]
3→dim(⌊N2
{6,7→dim([C]
2→dim(⌊S1
2→dim(⌊S2
Fill(1,[A]
Fill(1,[B]
Fill(1,[C]
8→dim(⌊SCR
Fill(0,⌊SCR
3→dim(⌊STAT
{­1000000,0,0→⌊STAT


prgmNEURAL is certainly the outermost program of the set, as it contains code to randomly alter the weights between neurons.

Code:
ClrHome
Output(5,1,"Max Fitness
Output(5,13,⌊STAT(1
Output(6,1,"Generation
While 1
⌊STAT(2)+1→⌊STAT(2
Output(6,13,⌊STAT(2
­10000000→⌊SCR(8
For(I,1,7
round(⌊SCR(I),3→⌊SCR(I
End
If max(⌊SCR)>⌊STAT(1
Then
max(⌊SCR→⌊STAT(1
Output(5,13,⌊STAT(1
End
Output(7,1,⌊SCR
0→I
Repeat ⌊SCR(I)=max(⌊SCR
I+1→I
End
For(J,1,54
For(K,1,7
[A](J,I→[A](J,K
If J≤18
[B](J,I→[B](J,K
If J≤6
[C](J,I→[C](J,K
End
End
For(I,1,54
For(J,2,7
[A](I,J)+.05rand-.5→[A](I,J
If I≤18
[B](I,J)+rand-.5→[B](I,J
If I≤6
[C](I,J)+rand-.5→[C](I,J
End
End
For(M,1,7
M→⌊SCR(8
prgmTICTAC
End
End


prgmNEURALPL is called during prgmTICTAC and I believe that the program means "Neural Play" meaning it plays a move as the neural net in the ongoing game of tic tac toe. It passes in ʟJ, which contains each of the 9 squares in the game, and returns ʟS2, containing X and Y coordinates of where the net has chosen to play.

Code:
⌊J→⌊IN
Fill(50,⌊N1
For(I,1,9
For(J,1,6
⌊N1(J)+⌊IN(I)[A](6(I-1)+J,⌊SCR(dim(⌊SCR→⌊N1(J
End
End
Fill(50,⌊N2
For(I,1,6
For(J,1,3
⌊N2(J)+⌊N1(I)[B](3(I-1)+J,⌊SCR(dim(⌊SCR→⌊N2(J
End
End
Fill(50,⌊S1
For(I,1,3
For(J,1,2
⌊S1(J)+⌊N2(I)[C](2(I-1)+J,⌊SCR(dim(⌊SCR→⌊S1(J
End
End
round(⌊S1(1)/100,0→⌊S2(1
round(⌊S1(2)/100,0→⌊S2(2


prgmTICTAC officiates each individual game of tic tac toe, and seems to log some calculation of the net's fitness that round into ʟSCR.

Code:
0→R
For(Q,1,5
9→dim(⌊J
Fill(0,⌊J
For(I,1,3
For(J,1,3
Output(I,J,"·
End
End
0→D
0→E
0→T
"D: {FAIL,DRAW,WIN,LOSS}
Repeat D
T+1→T
If E=0
Then
Repeat ⌊J(K)=0
randInt(1,9→K
End
­1→⌊J(K
Output(int((K-1)/3)+1,remainder((K-1),3)+1,"O"
Else
prgmNEURALPL
3⌊S2(1)+⌊S2(2)+3→K
If K>0 and K<10
Then
If ⌊J(K)=0
Then
1→⌊J(K
Output(int((K-1)/3)+1,remainder((K-1),3)+1,"X"
Else
1→D
End
Else
1→D
End
End
not(E→E
If D=0
Then
If min(abs(⌊J))≠0
2→D
If ⌊J(5)≠0
Then
For(I,1,4
If 0=variance({⌊J(I),⌊J(5),⌊J(10-I
3.5-.5(⌊J(5→D
End
Else
If ⌊J(1)≠0 and (0=variance({⌊J(1),⌊J(4),⌊J(7)}) or 0=variance({⌊J(1),⌊J(2),⌊J(3
3.5-.5(⌊J(1→D
If ⌊J(9)≠0 and (0=variance({⌊J(3),⌊J(6),⌊J(9)}) or 0=variance({⌊J(7),⌊J(8),⌊J(9
3.5-.5(⌊J(9→D
End
End
End
If D<3
50T-(max(abs(⌊S1(1)),abs(⌊S1(2)))≥100)(.5abs(√(⌊S1(1)²+⌊S1(2)²))-50(T≤2→K
If D=3
550-10T→K
If D=4
50T→K
K+R→R
End
R/5→⌊SCR(⌊SCR(dim(⌊SCR


I'm very impressed that you actually scrolled through all of that.
Sam wrote:
I believe I wrote this for golfing purposes, where having a perfect 0-9 list would be very advantageous.


The smallest seed that results in randIntNoRep(0,9) spitting out {0,1,2,3,4,5,6,7,8,9} is:
256540


Code:
:256540→rand
:Disp randIntNoRep(0,9)

{0 1 2 3 4 5 6 7 8 9}


I hope this helps your golfing.

EDIT: Another seed that produces the same result: 1180736
Sam wrote:
this program tests randIntNoRep(0,9 over and over with a different initial seed for rand, keeping track of which seeds produce random lists closest to {0,1,2,3,4,5,6,7,8,9}.

Code:
seq(A,A,0,9

Code:
cumSum(not(binompdf(9,0

hides

some neat stuff in here though, good job Good Idea
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement