TI-83/TI-83+/TI-83+ SE/TI-84+/TI-84+ SE, etc. programs (in BASIC) NOW TAKING REQ
Posted by: Guy
Date: 2008-02-22 19:28:12
NOW TAKING REQUESTS!
prgmBLACKJA2 - This is called "Blackjack2" as it being made after the original BLACKJAC, which just wasn't good at all. The code for this is pretty long, but anyway:
0->(arrow, store to)J
0->K
0->L
0->O
0->P
0->Q
randInt(2,11)->H
randInt(2,11)->I
randInt(2,11)->M
If H+I=21 and H=11
1->H
If H+I=21 and I=11
1->I
H+I->R
Pause {H,I,J,K,L,R}
If H+I=21
Disp "BLACKJACK!"
If H+I=21
Goto Y
Disp "HIT?"
Prompt S
If S≠0 and S≠1
Goto X
If S=1
randInt(2,11)->J
If S=0
Goto Y
If H+I+J>21 and J=11
1->J
H+I+J->R
Pause {H,I,J,K,L,R}
If R>21
Disp "BUST"
If R>21
Goto Y
Disp "HIT?"
Prompt S
If S≠1 and S≠0
Goto X
If S=1
randInt(2,11)->K
If S=0
Goto Y
If H+I+J+K>21 and K=11
1->K
H+I+J+K->R
Pause {H,I,J,K,L,R}
If R>21
Disp "BUST"
If R>21
Goto Y
Disp "HIT?"
Prompt S
If S≠1 and S≠0
Goto X
If S=1
randInt(2,11)->L
If S=0
Goto Y
If H+I+J+K+L>21 and L=11
1->L
H+I+J+K+L->R
If R>21
Disp "BUST"
If R>21
Goto Y
Lbl Y
randInt(2,11)->M
randInt(2,11)->N
If M+N>21 and M=11
1->M
M+N->T
If M+N≤16
randInt(2,11)->o
If M+N+O->21 and O=11
1->O
M+N+O->T
If M+N+O≤16
randInt(2,11)->P
If M+N+O+P>21 and P=11
1->P
M+N+O+P->T
If M+N+O+P≤16
randInt(2,11)->Q
If M+N+O+P+Q>21 and Q=11
1->Q
M+N+O+P+Q->T
Lbl Y
Pause {H,I,J,K,L,R}
Pause {M,N,O,P,Q,T}
If R>21 and T>21
Disp "TIE"
If R=T
Disp "TIE"
If R>T and R<22 and T<22
Disp "YOU WN"
If T>R and R<22 and T<22
Disp "YOU LOSE"
If R<22 and T>21
Disp "YOU WIN"
If T<22 and R>21
Disp "YOU LOSE"
Lbl X
If S≠0 and S≠1
Disp "ERROR"
There are a few messy things in the coding in this I realized, such as two "Lbl Y"s, but they haven't seemed to ever affect the programming. Also I programmed it to say "BUST" on the first turn if the total was over 21, but that's not possible in Blackjack, so it never comes into effect. This was also before my knowledge of "Output(", but it looks cleaner without overlapping things on the screen. When it prompts you to hit (S), choose 1 to hit and 0 not to. This was before I thought of "1 or anything else" so I wasted my time on an error thing. The way the AI works is it keeps hitting until it is over 16. Anyway, hope you enjoy! (if you have a compatible calculator!)
EDIT: Nothing! :???: Seriously I didn't change anything!