Poster un nouveau sujet Poster une réponse
Morpion avec IA
Auteur Message
-Coco-



Autorisation : Membre
Nb de messages : 149
Inscrit le : Sam 28 Nov 2009, 16:09
Posté le : Lun 11 Avr 2011, 18:52   Citer 

Bon, suite à la demande de made2kill je vous poste mon Morpion animé d'une IA.

Je tiens à prévenir : l'IA sera longue à recopier. Cependant elle est (quasi) imbattable en mode "Puissant".

C'est parti !

(Bien entendu, le "¤" correspond au signe théta, soit [alpha]+[3], et ( -) correspond au petit -, soit celui à coté de [entrer], puis -> n'est pas un signe - et un signe supérieur, mais [sto>], en dessus de [ON])

Code

:0->Xmin
:94->Xmax
:0->Ymax
:(-)62->Ymin
:AxesOff
:Lbl MP
:0->I
:Menu("MORPION","JOUEUR/JOUEUR",JJ,"JOUEUR/IA",JI,"       QUITTER",QU
:Lbl JI
:Menu("NIVEAU IA","DEBILE",ID,"MOYEN",IM,"PUISSANT",IP
:Lbl IP
:I+1->I
:Lbl IM
:I+1->I
:Lbl ID
:I+1->I
:Goto JJ
:Lbl QU
:DelVar [A]
:ClrHome
:Stop
:Lbl JJ
:ClrDraw
:DelVar [A]
:{3,3}->dim([A]
:For(A,0,48,16
:Line(0,(-)A,48,(-)A
:Line(A,0,A,(-)48
:End
:2->Z
:2->¤
:1->J
:0->M
:Lbl P
:Text(10,50,"JOUEUR:",J
:Pxl-On(Z*16-1,¤*16-1
:Pxl-On(Z*16-15,¤*16-15
:Pxl-On(Z*16-15,¤*16-1
:Pxl-On(Z*16-1,¤*16-15
:0->T
:Repeat T
:getKey->T
:End
:If T=45
:Goto MP
:Pxl-Off(Z*16-1,¤*16-1
:Pxl-Off(Z*16-1,¤*16-15
:Pxl-Off(Z*16-15,¤*16-1
:Pxl-Off(Z*16-15,¤*16-15
:Z+(T=34)-(T=25->Z
:¤+(T=26)-(T=24->¤
:Z-3(Z=4)+3(Z=0->Z
:¤-3(¤=4)+3(¤=0)->¤
:If T=105
:Goto PP
:Goto P
:Lbl PP
:If [A](Z,¤
:Goto P
:M+1->M
:J->[A](Z,¤
:If J=2
:Goto CE
:Line(¤*16-3,(-)Z*16+3,¤*16-13,(-)Z*16+13
:Line(¤*16-13,(-)Z*16+3,¤*16-3,(-)Z*16+13
:Goto TS
:Lbl CE
:Circle(¤*16-8,(-)Z*16+8,5
:
:Lbl TS
:Text(50,50,"       
:For(A,1,3
:1->Q
:If [A](A,1)=J and [A](A,2)=J and [A](A,3)=J
:Goto W
:2->Q
:If [A](1,A)=J and [A](2,A)=J and [A](3,A)=J
:Goto W
:End
:3->Q
:If [A](1,1)=J and [A](2,2)=J and [A](3,3)=J
:Goto W
:4->Q
:If [A](3,1)=J and [A](2,2)=J and [A](1,3)=J
:Goto W
:If M=9
:Goto MN
:J-(J=2)+(J=1->J
:If J=2 and I>0
:Goto IA
:Goto P
:Lbl W
:If Q=1
:Line(4,(-)(A*16-8),44,(-)(A*16-8
:If Q=2
:Line(A*16-8,(-)4,A*16-8,(-)44
:If Q=3
:Line(4,(-)4,44,(-)44
:If Q=4
:Line(4,(-)44,44,(-)4
:Text(50,0,"LE JOUEUR ",J," A GAGNE!"
:Pause
:Goto MP
:Lbl MN
:Text(50,10,"MATCH NUL!
:Pause
:Goto MP
:Lbl IA
:Text(50,50,"IA
:If I=1
:Then
:Lbl T
:randInt(1,3->Z
:randInt(1,3->¤
:If [A](Z,¤
:Goto T
:Goto PP
:End
:
:If I=3 or I=2
:Goto PG
:
:Lbl PG
:If M=1
:Then
:If 0=[A](2,2
:Then
:2->Z:2->¤
:Goto PP
:End
:Lbl P2
:randInt(0,1)*2+1->Z
:randInt(0,1)*2+1->¤
:If [A](Z,¤)
:Goto P2
:Goto PP
:End
:For(V,2-(I=2),1+(I=2),(-)1+2(I=2
:For(Z,1,3
:For(¤,1,3
:If [A](Z,¤)[pas égal]0      //le signe [pas égal] se trouve [2nde]+[math]+[2]
:Goto P5
:If Z=1
:Then
:If [A](Z+1,¤)=V and V=[A](Z+2,¤
:Goto PP
:End
:If Z=2
:Then
:If [A](Z-1,¤)=V and V=[A](Z+1,¤
:Goto PP
:End
:If Z=3
:Then
:If [A](Z-1,¤)=V and V=[A](Z-2,¤
:Goto PP
:End
:If ¤=1
:Then
:If [A](Z,¤+1)=V and V=[A](Z,¤+2
:Goto PP
:End
:If ¤=2
:Then
:If [A](Z,¤-1)=V and V=[A](Z,¤+1
:Goto PP
:End
:If ¤=3
:Then
:If [A](Z,¤-1)=V and V=[A](Z,¤-2
:Goto PP
:End
:If Z=1 and ¤=1
:Then
:If [A](Z+1,¤+1)=V and V=[A](Z+2,¤+2)
:Goto PP
:End
:If Z=2 and ¤=2
:Then
:If [A](Z-1,¤-1)=V and V=[A](Z+1,¤+1
:Goto PP
:If [A](Z-1,¤+1)=V and V=[A](Z+1,¤-1
:Goto PP
:End
:If Z=3 and ¤=1
:Then
:If [A](Z-1,¤+1)=V and V=[A](Z-2,¤+2
:Goto PP
:End
:If Z=3 and ¤=3
:Then
:If [A](Z-1,¤-1)=V and V=[A](Z-2,¤-2
:Goto PP
:End
:If Z=1 and ¤=3
:Then
:If [A](2,2)=V and V=[A](3,1
:Goto PP
:End
:
:Lbl P5
:
:End
:End
:End
:If [A](1,1)=1 and [A](3,3)=1
:Then
:2->Z:1->¤:Goto PP
:End
:If [A](3,1)=1 and [A](1,3)=1
:Then
:3->Z:2->¤:Goto PP
:End
:For(A,1,2
:If [A](1,2)=A and [A](2,1)=A
:Then
:If [A](1,1
:Goto 20
:1->Z:1->¤:Goto PP
:End
:Lbl 20
:If [A](2,1)=A and [A](3,2)=A
:Then
:If [A](3,1
:Goto 21
:3->Z:1->¤:Goto PP
:End
:Lbl 21
:If [A](3,2)=A and [A](2,3)=A
:Then
:If [A](3,3
:Goto 22
:3->Z:3->¤:Goto PP
:End
:Lbl 22
:If [A](1,2)=A and [A](2,3)=A
:Then
:If [A](1,3
:Goto 23
:1->Z:3->¤:Goto PP
:End
:Lbl 23
:End
:
:If [A](1,1) and [A](1,3) and [A](3,3) and [A](3,1
:Goto P9
:Lbl P8
:randInt(0,1)*2+1->Z
:randInt(0,1)*2+1->¤
:If [A](Z,¤
:Goto P8
:Goto PP
:Lbl P9
:randInt(1,3->Z
:randInt(1,3->¤
:If [A](Z,¤
:Goto P9
:Goto PP



 Adresse email Haut de page Bas de page 
 
Gwénaël



Autorisation : Membre
Nb de messages : 3
Inscrit le : Ven 08 Avr 2011, 15:54
Posté le : Lun 11 Avr 2011, 19:57   Citer 

Qu'est-ce que


Citer
If [A](Z,¤)≠0



 Adresse email Haut de page Bas de page 
 
-Coco-



Autorisation : Membre
Nb de messages : 149
Inscrit le : Sam 28 Nov 2009, 16:09
Posté le : Lun 11 Avr 2011, 21:35   Citer 

Mince, celui là m'a échappé ^^
C'est le signe pas égal, =/= (remplacé dans le code)

 Adresse email Haut de page Bas de page 
 
made2kill



Autorisation : Membre
Nb de messages : 80
Inscrit le : Jeu 24 Fév 2011, 19:12
Posté le : Mar 12 Avr 2011, 9:30   Citer 


Citer : -Coco-
Bon, suite à la demande de made2kill je vous poste mon Morpion animé d'une IA.



Merci mec happy.gif

Maintenant faut recopier tout ça... karate.gif

----------------------
Aussi connu sous le nom de f/x=x².
 Adresse email Haut de page Bas de page 
 
Gwénaël



Autorisation : Membre
Nb de messages : 3
Inscrit le : Ven 08 Avr 2011, 15:54
Posté le : Mar 12 Avr 2011, 15:33   Citer 

C'est méga long... On ne peut pas raccourcir ? Évite les entrées vides car ça prend de la mémoire pour rien

 Adresse email Haut de page Bas de page 
 
made2kill



Autorisation : Membre
Nb de messages : 80
Inscrit le : Jeu 24 Fév 2011, 19:12
Posté le : Mar 12 Avr 2011, 17:47   Citer 

c'est bon, je l'ai tapé (c'était long...), mais deux remarques:

1) Comment ca se fait que j'ai gagné facilement contre l'AI en mode puissant ?

2)C'est normal que ma calto réfléchisse... longtemps avant de tracer un cercle ?

----------------------
Aussi connu sous le nom de f/x=x².
 Adresse email Haut de page Bas de page 
 
Persalteas



Autorisation : Membre
Nb de messages : 2164
Inscrit le : Sam 23 Jan 2010, 20:09
Posté le : Mar 12 Avr 2011, 20:07   Citer 

Si tu es puissant aussi, tu peux battre l'IA...

et ça ne me semble pas si long pour un prog avec une IA.

 Adresse email Haut de page Bas de page 
 
-Coco-



Autorisation : Membre
Nb de messages : 149
Inscrit le : Sam 28 Nov 2009, 16:09
Posté le : Mer 13 Avr 2011, 20:01   Citer 

Tu ne peux pas battre l'IA puissant facilement, tu as donc fait une erreur dans le code.
Sinon il n'y a pas moyen d'optimiser plus que cela, car en effet l'IA puissant gère quasiment au cas par cas.
Ensuite, il s'agit d'une calculatrice et non d'un ordinateur : le temps de réflexion est bien plus long.

 Adresse email Haut de page Bas de page 
 
Poster un nouveau sujet Poster une réponse





  Powered by Fire-Soft-Board v1.0.10 © 2004 - 2024 Groupe FSB
Page générée en 9 requêtes
BlackOne par Grimmlink