Ce programme est une version bêta de la version originale que j'ai dénichée il y a un jour. Il est uniquement destiné à TI-BASIC. Le programme dispose d'une IA fonctionnelle.
0->M
ClrDraw
AxesOff
0->Xmin
0->Ymax
-62->Ymin
94->Xmax
Menu("WHO MOVES FIRST?","ME",ME,"AI",AI
Lbl AI
2->F
Goto D9
Lbl ME
1->F
Goto D9
Lbl D9
ClrHome
ClrAllLists
4->B
6->A
{1,2,3,1,2,3,1,1,1,2,2,2,1,2,3,1,1,1,3,1,1,1,3,3}->1
{1,1,1,2,2,2,1,2,3,1,2,3,1,1,1,1,2,3,1,1,1,3,1,3}->2
{1,2,3,1,2,3,2,2,2,3,3,3,1,2,3,3,3,3,1,3,2,2,2,2}->3
{2,2,2,3,3,3,1,2,3,1,2,3,3,3,3,1,2,3,3,3,2,2,2,2}->4
{1,2,3,1,2,3,3,3,3,1,1,1,1,2,3,2,2,2,2,2,3,3,1,1}->5
{3,3,3,1,1,1,1,2,3,1,2,3,2,2,2,1,2,3,2,2,3,1,3,1}->6
{2,4,6,2,4,6,6,6,6,2,2,2,2,4,6,4,4,4,4,4,6,6,2,2}->B
{6,6,6,2,2,2,2,4,6,2,4,6,4,4,4,2,4,6,4,4,6,2,6,2}->A
ClrDraw
{3,3}->dim([A]0
Fill(0,[A])
Text(-1,16,54,"Moves"
Text(-1,24,54,"left:"
Line(4,-35,36,-35
Line(4,-19,36,-19
Line(14,-6,14,-47
Line(26,-6,26,-47
Text(-1,0,0,"TIC TAC TOE"
If F=2
Goto R8
If F=1
Goto P8
Lbl AW
ClrHome
Disp "AI Wins..."
Pause
ClrHome
Stop
Lbl PW
ClrHome
Disp "Player Wins..."
Pause
ClrHome
Stop
Lbl A9
M+1->M
Text(-1,24,84,10-M
Text(-1,56,0,"AI'S TURN"
0->L
For(J,1,24) /Blocks Player's Win
If ([A](1(J),2(J))=1 and [A]*3(J).4(J))=1 and [A]*5(J).6(J))=0
Then
2->[A]*5(J).6(J))
Text(-1,*B(J)*8)-8,*A(J)*6)-6,"O"
If M=9
Goto TI
Goto P8
End
End
M-1->M
Goto R8
Lbl R8
Text(-1,56,0,"AI'S TURN
M+1->M
Text(-1,24,84,10-M
{2,4,6}->BD /Generates random spot if there's no win to block
Repeat [A](A,B)=0
randInt(1,3)->A
randInt(1,3)->B
End
Text(-1,(*BD(A)*8)-8,((BD(B)*6)-6),"O"
2->[A](A,B)
If M=9
Goto TI
Goto P8
Lbl TI
ClrHome
Disp "TIE!
Pause
ClrHome
Stop
Lbl P8 /Player Makes a move
M+1->M
Text(-1,24,84,10-M
Text(-1,56,0,"YOUR TURN"
Repeat K>0
getKey->K
If (K=72 and [A](1,1)=0)
Then
Text(-1,8,6,"X
1->[A](1,1
End
If (K=73 and [A](1,2)=0)
Then
Text(-1,8,18,"X
1->[A](1,2
End
If (K=74 and [A](1,3)=0)
Then
Text(-1,8,30,"X
1->[A](1,3
End
If (K=82 and [A](2,1)=0)
Then
Text(-1,24,6
1->[A](2,1
End
If (K=83 and [A](2,2)=0)
Then
Text(-1,24,18,"X
1->[A](2,2
End
If (K=84 and [A](2,3)=0)
Then
Text(-1,24,30,"X
1->[A](2,3
End
If (K=92 and [A](3,1)=0)
Then
Text(-1,40,6,"X
1->[A](3,1
End
If (K=93 and [A](3,2)=0)
Then
Text(-1,40,18,"X
1->[A](3,2
End
If (K=94 and [A](3,3)=0)
Then
Text(-1,40,30,"X
1->[A](3,3
End
End
For(J,1,24
If [A](1(J),2(J))=1 and [A]*3(J).4(J))=1 and [A]*5(J).6(J))=1
Goto PW
End
If M=9
Goto TI
GotoA9