Je n'ai pas compris tous les enjeux de certains éléments.
La méthode me trottait dans la tête depuis longtemps.
Je ne connais pas plus rapide comme test de victoire mais ce serait bien de l'accélérer encore plus.
Les touches bas, 2nde et entrer permettent toutes de valider un coup. (ça n'a pas changé mais personne ne l'a dit)
Code
ClrDraw
1->Xmin
1->Ymin
95->Xmax
63->Ymax
For(F,1,9
Line(1,65-F8,49,65-F8
Line(F6-5,57,F6-5,1
End
Text(0,2,"V
8->dim(L1
Fill(7,L1
1->D
0->G
randInt(1,2)->J
Lbl J
getKey
Text(25,52,"PLAYER : ",J
Text(0,D6-4,"V
Repeat sum(K={105,34,21,45,24,26
getKey->K
End
Text(0,D6-4," "
D-(K=24)+(K=26->D
If not(D
8->D
If D=9
1->D
If K=45:Stop
If K-105 and K-21 and K-34
Goto J
If not(L1(D
Goto J
L1(D)-1->L1(D
8L1(D->R
If J=1
Then
Line(D6-2,50-R,D6-4,52-R
Line(D6-2,50-R,D6,52-R
Line(D6-2,56-R,D6-4,54-R
Line(D6-2,56-R,D6,54-R
Else
Text(R+7,D6-4,"O
Line(D6-2,50-R,D6-2,56-R
Line(D6-4,52-R,D6-4,54-R
Line(D6,52-R,D6,54-R
End
G+1->G
If G=56
Goto F
//// début de la partie test victoire (facultative)
DelVar B
1->Z
For(W,-3,3
D6-3+6W->X
R+7+8W->Y
If X>0 and Y>0 and X<50 and Y<60
Then
pxl-Test(Y,X)+pxl-Test(Y+1,X->C
If C-J and W>0
DelVar Z
Z+B->B
If C-J and W<1
DelVar B
End
End
If B>3
Goto Z
DelVar B
1->Z
For(W,-3,3
D6-3-6W->X
R+7+8W->Y
If X>0 and Y>0 and X<50 and Y<60
Then
pxl-Test(Y,X)+pxl-Test(Y+1,X->C
If C-J and W>0
DelVar Z
Z+B->B
If C-J and W<1
DelVar B
End
End
If B>3
Goto Z
D6-3->X
DelVar B
1->Z
For(W,0,3
R+7+8W->Y
If Y>0 and Y<60
Then
pxl-Test(Y,X)+pxl-Test(Y+1,X->C
If C-J
DelVar Z
Z+B->B
End
End
If B>3
Goto Z
R+7->Y
DelVar B
1->Z
For(W,-3,3
D6-3+6W->X
If X>0 and X<50
Then
pxl-Test(Y,X)+pxl-Test(Y+1,X->C
If C-J and W>0
DelVar Z
Z+B->B
If C-J and W<1
DelVar B
End
End
If B>3
Goto Z
//// fin de la partie test victoire
3-J->J
Goto J
Lbl F
Text(0,0,"---- FULL ----
DelVar J
Lbl Z
If J
Text(31,52,"WIN
L'idée de base est de tester les cases à proximité des pions joués plutôt que de tester toute la grille à chaque fois.
EDIT: avec du recul quelques mois après je me demande si un code si long en vaut la chandelle. Probablement plus long qu'un test basique mais plus rapide.