Page 1 of 5

Morpion

Unread postPosted: 24 Dec 2006, 15:40
by univscien
Salut! :D:
Je suis entrein de faire un morpion, mais j'ai quelques petit problémes:
Code: Select all
ClrHome
ClrDraw
0-Z
0-Y
0-X
0-W
0-V
0-U
0-T
0-S
0-R
Line(32,0,32,62)
Line(62,0,62,62)
Line(0,21,94,21)
Line(0,42,94,42)
Lbl 1
randInt(1,9-C
If (C=1)(Z1)
Then
Circle(15,52,5
1-Z
Else
Goto 1
End
If (C=2)(Y1)
Then
Circle(45,52,5
1-Y
Else
Goto 1
End
If (C=3)(X1)
Then
Circle(79,52,5
1-X
Else
Goto 1
End
If (C=4)(W1)
Then
Circle(15,32,5
1-W
Else
Goto 1
End
If (C=5)(V1)
Then
Circle(45,32,5
1-V
Else
Goto 1
End
If (C=6)(U1)
Then
Circle(79,32,5
1-U
Else
Goto 1
End
If (C=7)(T1)
Then
Circle(15,10,5
1-T
Else
Goto 1
End
If (C=8)(S1)
Then
Circle(45,10,5
1-S
Else
Goto 1
End
If (C=9)(R1)
Then
Circle(79,10,5
1-R
Else
Goto 1
End
Repeat K
getKey-K
If K=72 and Z1
Then
Line(9,49,16,56
Line(16,49,9,56
2-Z
End
If K=73 and Y1
Then
Line(42,49,49,56
Line(49,49,42,56
2-Y
End
If K=74 and X1
Then
Line(74,49,81,56
Line(81,49,74,56
2-X
End
If K=82 and W1
Then
Line(9,28,16,35
Line(16,28,9,35
2-W
End
If K=83 and V1
Then
Line(42,28,49,35
Line(49,28,42,35
2-V
End
If K=84 and U1
Then
Line(74,28,81,35
Line(81,28,74,35
2-U
End
If K=92 and T1
Then
Line(9,5,16,12
Line(16,5,9,12
2-T
End
If K=93 and S1
Then
Line(42,5,49,12
Line(49,5,42,12
2-S
End
If K=94 and R1
Then
Line(81,5,74,12
Line(74,5,81,12
2-R
End
End
Goto 1


Le prob, c'est que en appuiyant sur une des touches, aucunne croix n'apparait.
Y'a seulement un cercle dans la premiére case en haut à gauche et puis c'est tout.
Vous pouvez m'aider plz? :):

Re: Morpion

Unread postPosted: 24 Dec 2006, 18:28
by tama
t'es courageux de faire ça ! y a beaucoup plus simple : utiliser une matrice puis utiliser les coordonnées
pour ton problème c'est parce que t'as oublié un end après le getkey-k

Re: Morpion

Unread postPosted: 24 Dec 2006, 19:58
by tama
Code: Select all
ClrDraw
Line(32,0,32,62
Line(62,0,62,62
Line(0,21,94,21
Line(0,42,94,42
{3,3-dim([A]
Fill(2,[A]
0-T
0-K
0-V
3-I
1-J
9-L
While V=0 and L0
not(T-T
0-O
Repeat O
While K72 and K94
getkey-K
If K-10int(.1K)=1 or K-10int(.1K)=5
0-K
End
If int(.1K)=8
2-I
If int(.1K)=9
1-I
If K-10int(.1K)=3
2-J
If K-10int(.1K)=4
3-J
If [A](I,J)=0
Then
If T=0
Then
Line(21J-15,21I-15,21J-5,21I-5
Line(21J-15,21I-5,21J-5,21I-15
End
If T=1
Circle(21J-10,21I-10,5
T-[A](I,J
1-O
L-1-L
End
For W,1,3
If [A](W,1)=/2 and [A](W,1)=[A](W,2) and [A](W,2)=[A](W,3
T+1-V
If [A](1,W)=/2 and [A](2,W)=[A](1,W) and [A](2,W)=[A](3,W
T+1-V
End
If [A](1,1)=/2 and [A](2,2)=[A](1,1) and [A](3,3)=[A](2,2
T+1-V
If [A](3,1)=/2 and [A](3,1)=[A](2,2) and [A](2,2)=[A](1,3
T+1-V
End
End
ClrHome
If V=1
Disp "Joueur 1 gagne"
If V=2
Disp "Joueur 2 gagne"
If V=0 and L=0
Disp "Match nul..."


=/ c'est le signe "différent de"

Re: Morpion

Unread postPosted: 24 Dec 2006, 20:58
by Ver2guerre
On a pas encore fait les matrices, c'est quoi ?

Re: Morpion

Unread postPosted: 24 Dec 2006, 21:10
by tama
on ?
les matrices c'est des sortes de tableaux à usage multiple pour stocker des données

Re: Morpion

Unread postPosted: 25 Dec 2006, 00:19
by Ver2guerre
Ah, je croyais qu'on le faisais en maths. J'avais vu des bouquins de maths où ils en parlaient

Re: Morpion

Unread postPosted: 25 Dec 2006, 13:04
by tama
ah ok surement avec des trucs comme matrice inverse et tout ça
oui
mais bon c'est simple d'utilisation

Re: Morpion

Unread postPosted: 25 Dec 2006, 13:52
by Ver2guerre
Je fregarderai si je trouve qqch la dessus.

Re: Morpion

Unread postPosted: 25 Dec 2006, 15:01
by tama
c'est vachement simple à utiliser
c'est juste des listes à 2 dimensions

Re: Morpion

Unread postPosted: 25 Dec 2006, 17:28
by Romain
Salut !!
J'ai moi meme fini la semaine derniere un prog sur le morpion! J'y ai mis deux semaines, j'avais commencé comme toi et même en utilisant les listes pour les coordonnées et puis j'ai pensé aux matrices ! Pour le joueur 1 place un 1 dans la case correspondante de la matrice et pour le joueur 2 un 2 ! Ensuite un petit test s'il y a eu au minimum 7 coups (4 pour le joueur 1 et 3 pour le 2) et voili voilou ça se finit tout seul !!
Continue comme ça t'es bien parti! C'est sympa de voir qu'ils y en a qui ont la foi !!
Bonne chance !!