π
<-

Tic Tac Toe for ti 84 (1 player against AI) no bugs

Pour le TI-Basic sur Nspire

Tic Tac Toe for ti 84 (1 player against AI) no bugs

Unread postby parzival1747 » Today, 00:28

This program is a beta version of the original version that I dug up a day ago. It is only for TI-BASIC. The program has a working AI.
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.

Code: Select all
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}→L1
{1,1,1,2,2,2,1,2,3,1,2,3,1,1,1,1,2,3,1,1,1,3,1,3}→L2
{1,2,3,1,2,3,2,2,2,3,3,3,1,2,3,3,3,3,1,3,2,2,2,2}→L3
{2,2,2,3,3,3,1,2,3,1,2,3,3,3,3,1,2,3,3,3,2,2,2,2}→L4
{1,2,3,1,2,3,3,3,3,1,1,1,1,2,3,2,2,2,2,2,3,3,1,1}→L5
{3,3,3,1,1,1,1,2,3,1,2,3,2,2,2,1,2,3,2,2,3,1,3,1}→L6
{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](L1(J),L2(J))=1 and [A]*L3(J).L4(J))=1 and [A]*L5(J).L6(J))=0
   Then
      2→[A]*L5(J).L6(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](L1(J),L2(J))=1 and [A]*L3(J).L4(J))=1 and [A]*L5(J).L6(J))=1
      Goto PW
End
If M=9
   Goto TI
Goto A9
User avatar
parzival1747
Niveau 0: MI (Membre Inactif)
Niveau 0: MI (Membre Inactif)
Level up: 0%
 
Posts: 1
Joined: Today, 00:21
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Tic Tac Toe for ti 84 (1 player against AI) no bugs

Unread postby Adriweb » Today, 11:34

There were some symbol issues in the code block, I fixed it :)

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
My calculator programs
Mes programmes pour calculatrices
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 80.1%
 
Posts: 14855
Images: 1134
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: adriweb
GitHub: adriweb


Return to Nspire-Basic

Who is online

Users browsing this forum: No registered users and 4 guests

-
Search
-
Social TI-Planet
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
"1 calculatrice pour tous", le programme solidaire de Texas Instruments. Reçois gratuitement et sans aucune obligation d'achat, 5 calculatrices couleur programmables en Python à donner aux élèves les plus nécessiteux de ton lycée. Tu peux recevoir au choix 5 TI-82 Advanced Edition Python ou bien 5 TI-83 Premium CE Edition Python.
Enseignant(e), reçois gratuitement 1 exemplaire de test de la TI-82 Advanced Edition Python. À demander d'ici le 31 décembre 2024.
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
1234
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
3240 utilisateurs:
>3227 invités
>7 membres
>6 robots
Record simultané (sur 6 mois):
29271 utilisateurs (le 11/07/2025)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)