Since this appears to be all up-to-date, I will gladly release it. Just have to find the time to put it all together....... Unless one of you guys want to do it, since I am (unfortunately) busy working on a HUGE ESSAY for my English teacher. Just put it all together, post it, and I will get it into SC3 and upload it from there.
» Forum
> Your Projects
|
I put it together within a few days, where it would he ready for release! Good luck on the essay, and I wish you a safe summer.
I've combined the two parts of the program, and the two most optimized versions come to a whopping 1600+ish bytes. This is the monochrome version (I'll sent it to PT_ for color translation). One this I want to a dress though...The AI always wins. This is obviously not fun for the user, and my AI design allows for easy dumbing down. I'm designing a menu where you select between Trivial, Easy, Medium, Hard, and Impossible, and would add a few hundred byes to data.
I've combined the two parts of the program, and the two most optimized versions come to a whopping 1600+ish bytes. This is the monochrome version (I'll sent it to PT_ for color translation). One this I want to a dress though...The AI always wins. This is obviously not fun for the user, and my AI design allows for easy dumbing down. I'm designing a menu where you select between Trivial, Easy, Medium, Hard, and Impossible, and would add a few hundred byes to data.
- NoahK
- Advanced Member (Posts: 244)
- 01 Jun 2015 03:52:49 pm
- Last edited by NoahK on 02 Jun 2015 06:16:20 am; edited 1 time in total
I and PT_ have talked a bit, and here are the difficulty levels in play, along with what they will execute:
1-Win-Block
2-Center
3-Block Double
4-Opposite Corner
5-Random Corner
6-Random Edge
7-Random Piece
Random: 7
Trivial: 1,7
Easy: 1,5,6,7
Medium: 1,2,5,6,7
Hard:1,2,4,5,6,7
Impossible: 1,2,3,4,5,6,7
[Edit]
Here is the *final* code. It works on both color and monochrome, TI-83 all the way up to TI-84+CSE/CE:
Code:
Please feel free to test the code!
1-Win-Block
2-Center
3-Block Double
4-Opposite Corner
5-Random Corner
6-Random Edge
7-Random Piece
Random: 7
Trivial: 1,7
Easy: 1,5,6,7
Medium: 1,2,5,6,7
Hard:1,2,4,5,6,7
Impossible: 1,2,3,4,5,6,7
[Edit]
Here is the *final* code. It works on both color and monochrome, TI-83 all the way up to TI-84+CSE/CE:
Code:
:DCS
"2424FF2424FF2424BBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBB3333333333333333BBBB3BBBBBB3BBBBBBBB3BBBB2B3BBBBBBBB3B22BBB3BBBBBBBB32B2B2B3BBBBBBBB3B22B2B3BBBBBBBB3BBBBBB3BBBB3333333333333333BBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBB"
94DeltaX+Xmin!=Xmax->G
If G
TextColor(Black
AxesOff
0->O
0->N
Lbl 0
0identity(3->[A]
Menu("Tic-Tac-Toe AI","Play",1,"Quit",2
Lbl 2
ClrHome
Stop
Lbl 1
1->F
Menu("AI Difficulty","Random", A,"Trivial",B,"Easy",C,"Meduim",D,"Hard",E,"Impossible",F
Lbl F
F+1->F
Lbl E
F+1->F
Lbl D
F+1->F
Lbl C
F+1->F
Lbl B
F+1->F
Lbl A
ClrDraw
~38->Xmin
If G
~33->Xmin
61->Ymax
~1->Ymin
61->Xmax
For(A,0,60,20
If G
Then
Line(A,0,A,60,Black
Line(0,A,60,A,Black
Else
Line(A,0,A,60
Line(0,A,60,A
End
End
Text(20,0,"GAMES WON
Text(32,0,"O: ",O
Text(44,0,"X: ",N
2->A
2->B
0->W
0->R
Repeat W or theta=45 or (R=9 and not(W
min(3,B->B
Text(0,0,"O'S TURN
If G
Then
Pt-On(20A-10,20B-10,Black
Else
Pt-On(20A-10,20B-10
End
Repeat Ans
getKey
End
Ans->theta
Pt-Off(20A-10,20B-10
min(3,max(1,A+(theta=26)-(theta=24->A
min(3,max(1,B+(theta=25)-(theta=34->B
If G
Then
Pt-On(20A-10,20B-10,Black
Else
Pt-On(20A-10,20B-10
End
If theta=105 and not([A](A,B
Then
R+1->R
Pt-Off(20A-10,20B-10
If G
Then
Circle(20A-10,20B-10,7,Blue
Else
Cirlce(20A-10,20B-10,7
End
1->[A](A,B
For(C,1,3
sum(seq([A](X,C),X,1,3->D
sum(seq([A](C,X),X,1,3->E
If sum(3={D,E
1->W
If sum(12={D,E
2->W
End
sum(seq([A](X,X),X,1,3->D
sum(seq([A](4-X,X),X,1,3->E
sum(2(12={D,E})+(3={D,E->W
If R<9 and not(W
Then
R+1->R
Text(0,0,"X'S TURN
ClrList L1
4->U
If F>1
Then
For(S,1,3
For(Q,1,3
1+(Q=3->P
3-(Q=1->V
S-(S=2->X
S+(S=2->G
2+(S=2->T
"5(U=Ans->|u
4-S->C:4-Q->Z
[A](S,V
If [A](S,P)=Ans and [A](S,P)not([A](S,Z
S+Z[i]+|u->L1(1+dim(L1
[A](V,S
If [A](P,S)=Ans and [A](P,S)not([A](Z,S
Z+S[i]+|u->L1(1+dim(L1
[A](T,T
If [A](X,X)=Ans and [A](X,X)not([A](C,C
C+C[i]+|u->L1(1+dim(L1
[A](2-(S=2),T
If [A](4-G,X)=Ans and [A](4-G,X)not([A](S,C
S+C[i]+|u->L1(1+dim(L1
End
End
End
If F>3 and not(dim(L1)) and not([A](2,2
2+2[i]->L1(1
If F>5 and not(dim(L1)) and (([A](1,1)=[A](3,3) and [A](1,1)=1) or ([A](3,1)=[A](1,3) and [A](3,1)=1
Goto 6
If F>4 and not(dim(L1
Then
For(S,1,3,2
For(Q,1,3,2
If [A](4-S,4-Q)=1 and not([A](S,Q
S+Q[i]->L1(1+dim(L1
End
End
End
If F>2 and not(dim(L1
Then
For(S,1,3,2
For(Q,1,3,2
If not([A](S,Q
S+Q[i]->L1(1+dim(L1
End
End
End
Lbl 6
If F>2 and not(dim(L1
Then
For(S,1,3,2
If not([A](2,S
2+S[i]->L1(1+dim(L1
If not([A](S,2
S+2[i]->L1(1+dim(L1
End
End
If not(dim(L1
Then
Repeat not([A](I,J
randInt(1,3->I
randInt(1,3->J
End
I+J[i]->L1(1
End
randInt(1,dim(L1->S
real(L1(S->I
imag(L1(S->J
For(D,1,dim(L1
If 5<real(L1(D
Then
real(L1(D))-5->I
imag(L1(D->J
End
End
4->[A](I,J
If G
Then
Line(20I-3,20J-3,20I-17,20J-17,Red
Line(20I-3,20J-17,20I-17,20J-3,Red
Else
Line(20I-3,20J-3,20I-17,20J-17
Line(20I-3,20J-17,20I-17,20J-3
End
Pt-Off(20I-10,20J-10
End
End
For(C,1,3
sum(seq([A](X,C),X,1,3->D
sum(seq([A](C,X),X,1,3->E
If sum(3={D,E
1->W
If sum(12={D,E
2->W
End
sum(seq([A](X,X),X,1,3->D
sum(seq([A](4-X,X),X,1,3->E
If sum(3={D,E
1->W
If sum(12={D,E
2->W
End
Text(0,0,"TIE!
If W
Then
O+(W=1->O
N+(W=2->N
Text(0,0,sub("OX",W,1)," WINS!
Text(32,14,O
Text(44,14,N
End
Pause
Goto 0
Please feel free to test the code!
I think six difficulty levels is too much for a tic-tac-toe game.
Interestingly, the "Impossible" really is impossible to win against.
Interestingly, the "Impossible" really is impossible to win against.
There are 6 because it is possible to have 6 with the code I wrote. It's not hurting to have so many levels
And thanks, I worked very hard to make it impossible.
[Edit]
After deep and academic conversation between I, Merth, Jonimus, and Runer112, it has come to conclusion that this "all-encompassing-cross-platform" program, designed to run on both color and monochrome calcs would work.
But:
Only if the program is exported my Merth's TokenIDE for the 83+, where the generated file could then be sent to *any* calculator from that computer. Sending the file from calculator to calculator will not work.
If that is a problem, then I can separate the color and monochrome programs, as so there are no issues.
And thanks, I worked very hard to make it impossible.
[Edit]
After deep and academic conversation between I, Merth, Jonimus, and Runer112, it has come to conclusion that this "all-encompassing-cross-platform" program, designed to run on both color and monochrome calcs would work.
But:
Only if the program is exported my Merth's TokenIDE for the 83+, where the generated file could then be sent to *any* calculator from that computer. Sending the file from calculator to calculator will not work.
If that is a problem, then I can separate the color and monochrome programs, as so there are no issues.
Well, it won't work properly on both the calcs. The code you give, have an icon for the color version, while I can't find the icon for the mono . But the code looks good and I will test it (and if possible optimize ).
The monochrome icon is the first 16 characters of the color icon: the top row of the color icon is pink and gray, but it makes perfect sense on a monochrome as an 8x8. I think we may have to separate the programs.....
Well, can't we just put both programs in one compressed folder and clearly show the difference between the two? I could do that when I upload it.
Well, here's my optimization, I don't know whether the 4 lines at top will work.
Code:
And NoahK, instead of colors, use can use numbers, which are ignored at the mono-calc but used with the color one.
Code:
:DCS
"BBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBB3333333333333333BBBB3BBBBBB3BBBBBBBB3BBBB2B3BBBBBBBB3B22BBB3BBBBBBBB32B2B2B3BBBBBBBB3B22B2B3BBBBBBBB3BBBBBB3BBBB3333333333333333BBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBB"
:DCS6
"0810081008100810FFFF081008500B100D500B500810FFFF0810081008100810
94DeltaX+Xmin!=Xmax->G
If G
TextColor(Black
AxesOff
0->O
0->N
Lbl 0
0identity(3->[A]
Menu("Tic-Tac-Toe AI","Play",1,"Quit",2
Lbl 2
ClrHome
Stop
Lbl 1
1
Menu("AI Difficulty","Random",A,"Trivial",B,"Easy",C,"Medium",D,"Hard",E,"Impossible",F
Lbl F
Ans+1
Lbl E
Ans+1
Lbl D
Ans+1
Lbl C
Ans+1
Lbl B
Ans+1
Lbl A
Ans+1->F
ClrDraw
~38+5G->Xmin
61->Ymax
~1->Ymin
61->Xmax
For(A,0,60,20
Line(A,0,A,60,12
Line(0,A,60,A,12
End
Text(20,0,"GAMES WON
Text(26+6G,0,"O: ",O
Text(32+12G,0,"X: ",N
2->A
2->B
0->W
0->R
Repeat W or theta=45 or (R=9 and not(W
min(3,B->B
Text(0,0,"O'S TURN
Pt-On(20A-10,20B-10,12
Repeat Ans
getKey
End
Ans->theta
Pt-Off(20A-10,20B-10
min(3,max(1,A+(theta=26)-(theta=24->A
min(3,max(1,B+(theta=25)-(theta=34->B
Pt-On(20A-10,20B-10,12
If theta=105 and not([A](A,B
Then
R+1->R
Pt-Off(20A-10,20B-10
Circle(20A-10,20B-10,7,10
1->[A](A,B
For(C,1,3
sum(seq([A](X,C),X,1,3->D
sum(seq([A](C,X),X,1,3->E
If sum(3={D,E
1->W
If sum(12={D,E
2->W
End
sum(seq([A](X,X),X,1,3->D
sum(seq([A](4-X,X),X,1,3->E
sum(2(12={D,E})+(3={D,E->W
If R<9 and not(W
Then
R+1->R
Text(0,0,"X'S TURN
ClrList L1
4->U
If F>1
Then
For(S,1,3
For(Q,1,3
1+(Q=3->P
3-(Q=1->V
S-(S=2->X
S+(S=2->K
2+(S=2->T
"5(U=Ans->|u
4-S->C:4-Q->Z
[A](S,V
If [A](S,P)=Ans and [A](S,P)not([A](S,Z
S+Z[i]+|u->L1(1+dim(L1
[A](V,S
If [A](P,S)=Ans and [A](P,S)not([A](Z,S
Z+S[i]+|u->L1(1+dim(L1
[A](T,T
If [A](X,X)=Ans and [A](X,X)not([A](C,C
C+C[i]+|u->L1(1+dim(L1
[A](2-(S=2),T
If [A](4-K,X)=Ans and [A](4-K,X)not([A](S,C
S+C[i]+|u->L1(1+dim(L1
End
End
End
If F>3 and not(dim(L1)) and not([A](2,2
2+2[i]->L1(1
If F>5 and not(dim(L1)) and (([A](1,1)=[A](3,3) and [A](1,1)=1) or ([A](3,1)=[A](1,3) and [A](3,1)=1
Goto 6
If F>4 and not(dim(L1
Then
For(S,1,3,2
For(Q,1,3,2
If [A](4-S,4-Q)=1 and not([A](S,Q
S+Q[i]->L1(1+dim(L1
End
End
End
If F>2 and not(dim(L1
Then
For(S,1,3,2
For(Q,1,3,2
If not([A](S,Q
S+Q[i]->L1(1+dim(L1
End
End
End
Lbl 6
If F>2 and not(dim(L1
Then
For(S,1,3,2
If not([A](2,S
2+S[i]->L1(1+dim(L1
If not([A](S,2
S+2[i]->L1(1+dim(L1
End
End
If not(dim(L1
Then
Repeat not([A](I,J
randInt(1,3->I
randInt(1,3->J
End
I+J[i]->L1(1
End
randInt(1,dim(L1->S
real(L1(S->I
imag(L1(S->J
For(D,1,dim(L1
If 5<real(L1(D
Then
real(L1(D))-5->I
imag(L1(D->J
End
End
4->[A](I,J
Line(20I-3,20J-3,20I-17,20J-17,11
Line(20I-3,20J-17,20I-17,20J-3,11
Pt-Off(20I-10,20J-10
End
End
For(C,1,3
sum(seq([A](X,C),X,1,3->D
sum(seq([A](C,X),X,1,3->E
If sum(3={D,E
1->W
If sum(12={D,E
2->W
End
sum(seq([A](X,X),X,1,3->D
sum(seq([A](4-X,X),X,1,3->E
If sum(3={D,E
1->W
If sum(12={D,E
2->W
End
Text(0,0,"TIE!
If W
Then
O+(W=1->O
N+(W=2->N
Text(0,0,sub("OX",W,1)," WINS!
Text(26+6G,7+7G,O
Text(32+12G,7+7G,N
End
Pause
Goto 0
And NoahK, instead of colors, use can use numbers, which are ignored at the mono-calc but used with the color one.
Can we get rid of the TextColor command? And just let the text be whatever color it wants? That would work great!
Alright, here it is:
Code:
PT_ and caleb, be sure to test in on your colors!
[Edit] I dont have a color, but I think this is it, the final edit.
Code:
:DCS
"2424FF2424FF2424BBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBB3333333333333333BBBB3BBBBBB3BBBBBBBB3BBBB2B3BBBBBBBB3B22BBB3BBBBBBBB32B2B2B3BBBBBBBB3B22B2B3BBBBBBBB3BBBBBB3BBBB3333333333333333BBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBB"
94DeltaX+Xmin!=Xmax->G
AxesOff
0->O
0->N
Lbl 0
0identity(3->[A]
Menu("Tic-Tac-Toe AI","Play",1,"Quit",2
Lbl 2
ClrHome
Stop
Lbl 1
1
Menu("AI Difficulty","Random",A,"Trivial",B,"Easy",C,"Medium",D,"Hard",E,"Impossible",F
Lbl F
Ans+1
Lbl E
Ans+1
Lbl D
Ans+1
Lbl C
Ans+1
Lbl B
Ans+1
Lbl A
Ans->F
ClrDraw
~33-5G->Xmin
61->Ymax
~1->Ymin
61->Xmax
For(A,0,60,20
Line(A,0,A,60,12
Line(0,A,60,A,12
End
Text(20,0,"GAMES WON
Text(26+6G,0,"O: ",O
Text(32+12G,0,"X: ",N
2->A
2->B
0->W
0->R
Repeat W or theta=45 or (R=9 and not(W
min(3,B->B
Text(0,0,"O'S TURN
Pt-On(20A-10,20B-10,12
Repeat Ans
getKey
End
Ans->theta
Pt-Off(20A-10,20B-10
min(3,max(1,A+(theta=26)-(theta=24->A
min(3,max(1,B+(theta=25)-(theta=34->B
Pt-On(20A-10,20B-10,12
If theta=105 and not([A](A,B
Then
R+1->R
Pt-Off(20A-10,20B-10
If G
Then
Circle(20A-10,20B-10,7,10
Else
Circle(20A-10,20B-10,7
End
1->[A](A,B
For(C,1,3
sum(seq([A](X,C),X,1,3->D
sum(seq([A](C,X),X,1,3->E
If sum(3={D,E
1->W
If sum(12={D,E
2->W
End
sum(seq([A](X,X),X,1,3->D
sum(seq([A](4-X,X),X,1,3->E
sum(2(12={D,E})+(3={D,E->W
If R<9 and not(W
Then
R+1->R
Text(0,0,"X'S TURN
ClrList L1
4->U
If F>1
Then
For(S,1,3
For(Q,1,3
1+(Q=3->P
3-(Q=1->V
S-(S=2->X
S+(S=2->K
2+(S=2->T
"5(U=Ans->|u
4-S->C:4-Q->Z
[A](S,V
If [A](S,P)=Ans and [A](S,P)not([A](S,Z
S+Z[i]+|u->L1(1+dim(L1
[A](V,S
If [A](P,S)=Ans and [A](P,S)not([A](Z,S
Z+S[i]+|u->L1(1+dim(L1
[A](T,T
If [A](X,X)=Ans and [A](X,X)not([A](C,C
C+C[i]+|u->L1(1+dim(L1
[A](2-(S=2),T
If [A](4-K,X)=Ans and [A](4-K,X)not([A](S,C
S+C[i]+|u->L1(1+dim(L1
End
End
End
If F>3 and not(dim(L1)) and not([A](2,2
2+2[i]->L1(1
If F>5 and not(dim(L1)) and (([A](1,1)=[A](3,3) and [A](1,1)=1) or ([A](3,1)=[A](1,3) and [A](3,1)=1
Goto 6
If F>4 and not(dim(L1
Then
For(S,1,3,2
For(Q,1,3,2
If [A](4-S,4-Q)=1 and not([A](S,Q
S+Q[i]->L1(1+dim(L1
End
End
End
If F>2 and not(dim(L1
Then
For(S,1,3,2
For(Q,1,3,2
If not([A](S,Q
S+Q[i]->L1(1+dim(L1
End
End
End
Lbl 6
If F>2 and not(dim(L1
Then
For(S,1,3,2
If not([A](2,S
2+S[i]->L1(1+dim(L1
If not([A](S,2
S+2[i]->L1(1+dim(L1
End
End
If not(dim(L1
Then
Repeat not([A](I,J
randInt(1,3->I
randInt(1,3->J
End
I+J[i]->L1(1
End
randInt(1,dim(L1->S
imag([i]L1(S->I
imag(L1(S->J
For(D,1,dim(L1
If 5<imag([i]L1(D
Then
imag([i]L1(D))-5->I
imag(L1(D->J
End
End
4->[A](I,J
Line(20I-3,20J-3,20I-17,20J-17,11
Line(20I-3,20J-17,20I-17,20J-3,11
Pt-Off(20I-10,20J-10
End
End
For(C,1,3
sum(seq([A](X,C),X,1,3->D
sum(seq([A](C,X),X,1,3->E
If sum(3={D,E
1->W
If sum(12={D,E
2->W
End
sum(seq([A](X,X),X,1,3->D
sum(seq([A](4-X,X),X,1,3->E
If sum(3={D,E
1->W
If sum(12={D,E
2->W
End
Text(0,0,"TIE! "
If W
Then
O+(W=1->O
N+(W=2->N
Text(0,0,sub("OX",W,1)," WINS! "
Text(26+6G,7+7G,O
Text(32+12G,7+7G,N
End
Pause
Goto 0
PT_ and caleb, be sure to test in on your colors!
[Edit] I dont have a color, but I think this is it, the final edit.
Here's my code that I would like to add to it:
Code:
Code:
DelVar Str1:{3,3}->dim([A]):0->Z:0->P:Fill(0,[A]
Menu("TIC-TAC-TOE","PLAY",1,"QUIT",2
Lbl 1
ClrDraw:0->Xmin:60->Xmax:0->Ymin:60->Ymax:AxesOff:0->W:Zsquare
For(A,0,60,20
Line(A,0,A,60
Line(0,A,60,A
End
2->A:2->B
Repeat theta=45 or Z=9
getKey->theta
Text(0,0,sub("OX",P+1,1
Pt-Off(20A-10,20B-10
A+(theta=26 and A<3)-(theta=24 and A>1)->A
B+(theta=25 and B<3)-(theta=34 and B>1)->B
Pt-On(20A-10,20B-10
If theta=105 and P=0:Then
If not([A](A,B
Then
1->[A](A,B):not(P)->P:Z+1->Z:0->theta
Circle(20A-10,20B-10,10
End
Matr>list([A],L1,L2,L3
If sum(L1)=3 or sum(L2)=3 or sum(L3)=3 or L1(1)+L2(2)+L3(3)=3 or L1(3)+L2(2)+L3(1)=3 or L1(1)+L2(1)+L3(1)=3 or L1(2)+L2(2)+L3(2)=3 or L1(3)+L2(3)+L3(3)=3
Then
9->Z:1->W
End
End
If theta=105 and P=1:Then
If not([A](A,B
Then
~1->[A](A,B):not(P)->P:Z+1->Z:0->theta
Line(20A-20,20B,20A,20B-20
Line(20A,20B,20A-20,20B-20
End
Matr>list([A],L1,L2,L3
If sum(L1)=~3 or sum(L2)=~3 or sum(L3)=~3 or L1(1)+L2(2)+L3(3)=~3 or L1(3)+L2(2)+L3(1)=~3 or L1(1)+L2(1)+L3(1)=~3 or L1(2)+L2(2)+L3(2)=~3 or L1(3)+L2(3)+L3(3)=~3
Then
9->Z:2->W
End
End
End
If W!=0:Then
"PLAYER "+sub("12",W,1)+" WINS"->Str1
ClrHome:Pause Str1
DelVar Str1
ClrHome
Menu("PLAY AGAIN?","YES",1,"NO",2
Lbl 2
ClrHome:Stop
End
I aded your PvP mode: We use all the real variables, and we use L1 and [A]. 2315 Bytes. That's 27 variables.....
Code:
Code:
:DCS
"2424FF2424FF2424BBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBB3333333333333333BBBB3BBBBBB3BBBBBBBB3BBBB2B3BBBBBBBB3B22BBB3BBBBBBBB32B2B2B3BBBBBBBB3B22B2B3BBBBBBBB3BBBBBB3BBBB3333333333333333BBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBBBBBB3BBBBBB3BBBB"
Goto AA
Lbl A0
For(C,1,3
sum(seq([A](X,C),X,1,3->D
sum(seq([A](C,X),X,1,3->E
If sum(3={D,E
1->W
If sum(12={D,E
2->W
End
sum(seq([A](X,X),X,1,3->D
sum(seq([A](4-X,X),X,1,3->E
If sum(3={D,E
1->W
If sum(12={D,E
2->W
If H=1
Goto A1
If H=2
Goto A2
Lbl AA
94DeltaX+Xmin!=Xmax->G
AxesOff
0->O
0->N
Lbl 0
0identity(3->[A]
0->L
Menu("Tic-Tac-Toe AI","Player-Player",3,"Player-Comp",1,"Quit",2
Lbl 2
ClrHome
Stop
Lbl 1
1
Menu("AI Difficulty","Random",A,"Trivial",B,"Easy",C,"Medium",D,"Hard",E,"Impossible",F
Lbl F
Ans+1
Lbl E
Ans+1
Lbl D
Ans+1
Lbl C
Ans+1
Lbl B
Ans+1
Lbl A
Ans->F
L-1->L
Lbl 3
L+1->L
ClrDraw
~33-6G->Xmin
61->Ymax
~1->Ymin
61->Xmax
For(A,0,60,20
Line(A,0,A,60,12
Line(0,A,60,A,12
End
Text(20,0,"GAMES WON
Text(26+6G,0,"O: ",O
Text(32+12G,0,"X: ",N
2->A
2->B
2->I
2->J
0->W
0->R
Repeat W or theta=45 or (R=9 and not(W
min(3,B->B
Text(0,0,"O'S TURN
Pt-On(20A-10,20B-10,12
Repeat theta=105
Repeat Ans
getKey
End
Ans->theta
Pt-Off(20A-10,20B-10
min(3,max(1,A+(theta=26)-(theta=24->A
min(3,max(1,B+(theta=25)-(theta=34->B
Pt-On(20A-10,20B-10,12
End
If theta=105 and not([A](A,B
Then
R+1->R
Pt-Off(20A-10,20B-10
If G
Then
Circle(20A-10,20B-10,7,10
Else
Circle(20A-10,20B-10,7
End
1->[A](A,B
1->H
Goto A0
Lbl A1
If R<9 and not(W
Then
R+1->R
Text(0,0,"X'S TURN
If L
Then
Pt-On(20I-10,20J-10,12
Repeat theta=105 and not([A](I,J
Repeat Ans
getKey
End
Ans->theta
Pt-Off(20I-10,20J-10
min(3,max(1,I+(theta=26)-(theta=24->I
min(3,max(1,J+(theta=25)-(theta=34->J
Pt-On(20I-10,20J-10,12
End
Pt-Off(20I-10,20J-10
Else
ClrList L1
4->U
If F>1
Then
For(S,1,3
For(Q,1,3
1+(Q=3->P
3-(Q=1->V
S-(S=2->X
S+(S=2->K
2+(S=2->T
"5(U=Ans->|u
4-S->C:4-Q->Z
[A](S,V
If [A](S,P)=Ans and [A](S,P)not([A](S,Z
S+Z[i]+|u->L1(1+dim(L1
[A](V,S
If [A](P,S)=Ans and [A](P,S)not([A](Z,S
Z+S[i]+|u->L1(1+dim(L1
[A](T,T
If [A](X,X)=Ans and [A](X,X)not([A](C,C
C+C[i]+|u->L1(1+dim(L1
[A](2-(S=2),T
If [A](4-K,X)=Ans and [A](4-K,X)not([A](S,C
S+C[i]+|u->L1(1+dim(L1
End
End
End
If F>3 and not(dim(L1)) and not([A](2,2
2+2[i]->L1(1
If F>5 and not(dim(L1)) and (([A](1,1)=[A](3,3) and [A](1,1)=1) or ([A](3,1)=[A](1,3) and [A](3,1)=1
Goto 6
If F>4 and not(dim(L1
Then
For(S,1,3,2
For(Q,1,3,2
If [A](4-S,4-Q)=1 and not([A](S,Q
S+Q[i]->L1(1+dim(L1
End
End
End
If F>2 and not(dim(L1
Then
For(S,1,3,2
For(Q,1,3,2
If not([A](S,Q
S+Q[i]->L1(1+dim(L1
End
End
End
Lbl 6
If F>2 and not(dim(L1
Then
For(S,1,3,2
If not([A](2,S
2+S[i]->L1(1+dim(L1
If not([A](S,2
S+2[i]->L1(1+dim(L1
End
End
If not(dim(L1
Then
Repeat not([A](I,J
randInt(1,3->I
randInt(1,3->J
End
I+J[i]->L1(1
End
randInt(1,dim(L1->S
imag([i]L1(S->I
imag(L1(S->J
For(D,1,dim(L1
If 5<imag([i]L1(D
Then
imag([i]L1(D))-5->I
imag(L1(D->J
End
End
End
4->[A](I,J
Line(20I-3,20J-3,20I-17,20J-17,11
Line(20I-3,20J-17,20I-17,20J-3,11
Pt-Off(20I-10,20J-10
End
End
2->H
Goto A0
Lbl A2
End
Text(0,0,"TIE! "
If W
Then
O+(W=1->O
N+(W=2->N
Text(0,0,sub("OX",W,1)," WINS! "
Text(26+6G,7+7G,O
Text(32+12G,7+7G,N
End
Pause
Goto 0
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
» Go to Registration page
» Goto page Previous 1, 2, 3, 4
» View previous topic :: View next topic
» View previous topic :: View next topic
Page 4 of 4
» 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
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