Batch Index du Forum
S’enregistrerRechercherFAQMembresGroupesConnexion
Répondre au sujet Page 1 sur 1
Tic Tac Toe (Deux joueurs)
Auteur Message
Répondre en citant
Message Tic Tac Toe (Deux joueurs) 
Bonjour,
J'ai voulu essayer pour la première fois de faire un Tic Tac Toe.
Le voici, pour deux joueurs uniquement:
(Le code est largement réductible, j'en suis conscient)

Code:
@ECHO OFF
:START
COLOR 0F
CLS
PING 127.0.0.1 -N 2 > NUL
:: //            TIC TAC TOE
:: //           GADACHA DYLAN
TITLE TIC TAC TOE - BY GADACHA DYLAN
SETLOCAL ENABLEDELAYEDEXPANSION
:NICKNAME
CLS
SET /P "PLAYER1=PLAYER1 [X]: "
SET /P "PLAYER2=PLAYER2 [O]: "
SET TRY=0
SET "C1L1=[1]" &SET "C2L1=[2]" &SET "C3L1=[3]"
SET "C1L2=[4]" &SET "C2L2=[5]" &SET "C3L2=[6]"
SET "C1L3=[7]" &SET "C2L3=[8]" &SET "C3L3=[9]"
:PLAYER1
SET "L1=!C1L1! !C2L1! !C3L1!"
SET "L2=!C1L2! !C2L2! !C3L2!"
SET "L3=!C1L3! !C2L3! !C3L3!"
SET PLAYER=X
CLS
ECHO PLAYER: %PLAYER1%
ECHO.
ECHO %L1%
ECHO.
ECHO %L2%
ECHO.
ECHO %L3%
ECHO.
SET /P "PARTICULARS=PARTICULARS: "
IF "%PARTICULARS%" EQU "1" GOTO C1L1
IF "%PARTICULARS%" EQU "4" GOTO C1L2
IF "%PARTICULARS%" EQU "7" GOTO C1L3
IF "%PARTICULARS%" EQU "2" GOTO C2L1
IF "%PARTICULARS%" EQU "5" GOTO C2L2
IF "%PARTICULARS%" EQU "8" GOTO C2L3
IF "%PARTICULARS%" EQU "3" GOTO C3L1
IF "%PARTICULARS%" EQU "6" GOTO C3L2
IF "%PARTICULARS%" EQU "9" GOTO C3L3
:C1L1
IF "%C1L1%" EQU "[1]" SET "C1L1=[!PLAYER!]" &GOTO CHECK1
IF "%C1L1%" NEQ "[1]" GOTO UNAVAILABLE1
:C2L1
IF "%C2L1%" EQU "[2]" SET "C2L1=[!PLAYER!]" &GOTO CHECK1
IF "%C2L1%" NEQ "[2]" GOTO UNAVAILABLE1
:C3L1
IF "%C3L1%" EQU "[3]" SET "C3L1=[!PLAYER!]" &GOTO CHECK1
IF "%C3L1%" NEQ "[3]" GOTO UNAVAILABLE1
:C1L2
IF "%C1L2%" EQU "[4]" SET "C1L2=[!PLAYER!]" &GOTO CHECK1
IF "%C1L2%" NEQ "[4]" GOTO UNAVAILABLE1
:C2L2
IF "%C2L2%" EQU "[5]" SET "C2L2=[!PLAYER!]" &GOTO CHECK1
IF "%C2L2%" NEQ "[5]" GOTO UNAVAILABLE1
:C3L2
IF "%C3L2%" EQU "[6]" SET "C3L2=[!PLAYER!]" &GOTO CHECK1
IF "%C3L2%" NEQ "[6]" GOTO UNAVAILABLE1
:C1L3
IF "%C1L3%" EQU "[7]" SET "C1L3=[!PLAYER!]" &GOTO CHECK1
IF "%C1L3%" NEQ "[7]" GOTO UNAVAILABLE1
:C2L3
IF "%C2L3%" EQU "[8]" SET "C2L3=[!PLAYER!]" &GOTO CHECK1
IF "%C2L3%" NEQ "[8]" GOTO UNAVAILABLE1
:C3L3
IF "%C3L3%" EQU "[9]" SET "C3L3=[!PLAYER!]" &GOTO CHECK1
IF "%C3L3%" NEQ "[9]" GOTO UNAVAILABLE1
:CHECK1
SET /A "TRY+=1"
IF "%TRY%" EQU "9" GOTO EQUALITY
IF "%C1L1%" EQU "[X]" IF "%C2L1%" EQU "[X]" IF "%C3L1%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C1L2%" EQU "[X]" IF "%C2L2%" EQU "[X]" IF "%C3L2%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C1L3%" EQU "[X]" IF "%C2L3%" EQU "[X]" IF "%C3L3%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C1L1%" EQU "[X]" IF "%C1L2%" EQU "[X]" IF "%C1L3%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C2L1%" EQU "[X]" IF "%C2L2%" EQU "[X]" IF "%C2L3%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C3L1%" EQU "[X]" IF "%C3L2%" EQU "[X]" IF "%C3L3%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C1L1%" EQU "[X]" IF "%C2L2%" EQU "[X]" IF "%C3L3%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C3L1%" EQU "[X]" IF "%C2L2%" EQU "[X]" IF "%C1L3%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C1L1%" EQU "[O]" IF "%C2L1%" EQU "[O]" IF "%C3L1%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
IF "%C1L2%" EQU "[O]" IF "%C2L2%" EQU "[O]" IF "%C3L2%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
IF "%C1L3%" EQU "[O]" IF "%C2L3%" EQU "[O]" IF "%C3L3%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
IF "%C1L1%" EQU "[O]" IF "%C1L2%" EQU "[O]" IF "%C1L3%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
IF "%C2L1%" EQU "[O]" IF "%C2L2%" EQU "[O]" IF "%C2L3%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
IF "%C3L1%" EQU "[O]" IF "%C3L2%" EQU "[O]" IF "%C3L3%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
IF "%C1L1%" EQU "[O]" IF "%C2L2%" EQU "[O]" IF "%C3L3%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
IF "%C3L1%" EQU "[O]" IF "%C2L2%" EQU "[O]" IF "%C1L3%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
GOTO PLAYER2
:UNAVAILABLE1
ECHO UNAVAILABLE CHOICE !
PING 127.0.0.1 -N 2 > NUL
GOTO PLAYER1
:PLAYER2
SET "L1=!C1L1! !C2L1! !C3L1!"
SET "L2=!C1L2! !C2L2! !C3L2!"
SET "L3=!C1L3! !C2L3! !C3L3!"
SET PLAYER=O
CLS
ECHO PLAYER: %PLAYER2%
ECHO.
ECHO %L1%
ECHO.
ECHO %L2%
ECHO.
ECHO %L3%
ECHO.
SET /P "PARTICULARS=PARTICULARS: "
IF "%PARTICULARS%" EQU "1" GOTO C1L1
IF "%PARTICULARS%" EQU "4" GOTO C1L2
IF "%PARTICULARS%" EQU "7" GOTO C1L3
IF "%PARTICULARS%" EQU "2" GOTO C2L1
IF "%PARTICULARS%" EQU "5" GOTO C2L2
IF "%PARTICULARS%" EQU "8" GOTO C2L3
IF "%PARTICULARS%" EQU "3" GOTO C3L1
IF "%PARTICULARS%" EQU "6" GOTO C3L2
IF "%PARTICULARS%" EQU "9" GOTO C3L3
:C1L1
IF "%C1L1%" EQU "[1]" SET "C1L1=[!PLAYER!]" &GOTO CHECK2
IF "%C1L1%" NEQ "[1]" GOTO UNAVAILABLE2
:C2L1
IF "%C2L1%" EQU "[2]" SET "C2L1=[!PLAYER!]" &GOTO CHECK2
IF "%C2L1%" NEQ "[2]" GOTO UNAVAILABLE2
:C3L1
IF "%C3L1%" EQU "[3]" SET "C3L1=[!PLAYER!]" &GOTO CHECK2
IF "%C3L1%" NEQ "[3]" GOTO UNAVAILABLE2
:C1L2
IF "%C1L2%" EQU "[4]" SET "C1L2=[!PLAYER!]" &GOTO CHECK2
IF "%C1L2%" NEQ "[4]" GOTO UNAVAILABLE2
:C2L2
IF "%C2L2%" EQU "[5]" SET "C2L2=[!PLAYER!]" &GOTO CHECK2
IF "%C2L2%" NEQ "[5]" GOTO UNAVAILABLE2
:C3L2
IF "%C3L2%" EQU "[6]" SET "C3L2=[!PLAYER!]" &GOTO CHECK2
IF "%C3L2%" NEQ "[6]" GOTO UNAVAILABLE2
:C1L3
IF "%C1L3%" EQU "[7]" SET "C1L3=[!PLAYER!]" &GOTO CHECK2
IF "%C1L3%" NEQ "[7]" GOTO UNAVAILABLE2
:C2L3
IF "%C2L3%" EQU "[8]" SET "C2L3=[!PLAYER!]" &GOTO CHECK2
IF "%C2L3%" NEQ "[8]" GOTO UNAVAILABLE2
:C3L3
IF "%C3L3%" EQU "[9]" SET "C3L3=[!PLAYER!]" &GOTO CHECK2
IF "%C3L3%" NEQ "[9]" GOTO UNAVAILABLE2
:CHECK2
SET /A "TRY+=1"
IF "%TRY%" EQU "9" GOTO EQUALITY
IF "%C1L1%" EQU "[X]" IF "%C2L1%" EQU "[X]" IF "%C3L1%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C1L2%" EQU "[X]" IF "%C2L2%" EQU "[X]" IF "%C3L2%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C1L3%" EQU "[X]" IF "%C2L3%" EQU "[X]" IF "%C3L3%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C1L1%" EQU "[X]" IF "%C1L2%" EQU "[X]" IF "%C1L3%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C2L1%" EQU "[X]" IF "%C2L2%" EQU "[X]" IF "%C2L3%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C3L1%" EQU "[X]" IF "%C3L2%" EQU "[X]" IF "%C3L3%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C1L1%" EQU "[X]" IF "%C2L2%" EQU "[X]" IF "%C3L3%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C3L1%" EQU "[X]" IF "%C2L2%" EQU "[X]" IF "%C1L3%" EQU "[X]" PING 127.0.0.1 -N 2 &GOTO WINP1
IF "%C1L1%" EQU "[O]" IF "%C2L1%" EQU "[O]" IF "%C3L1%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
IF "%C1L2%" EQU "[O]" IF "%C2L2%" EQU "[O]" IF "%C3L2%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
IF "%C1L3%" EQU "[O]" IF "%C2L3%" EQU "[O]" IF "%C3L3%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
IF "%C1L1%" EQU "[O]" IF "%C1L2%" EQU "[O]" IF "%C1L3%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
IF "%C2L1%" EQU "[O]" IF "%C2L2%" EQU "[O]" IF "%C2L3%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
IF "%C3L1%" EQU "[O]" IF "%C3L2%" EQU "[O]" IF "%C3L3%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
IF "%C1L1%" EQU "[O]" IF "%C2L2%" EQU "[O]" IF "%C3L3%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
IF "%C3L1%" EQU "[O]" IF "%C2L2%" EQU "[O]" IF "%C1L3%" EQU "[O]" PING 127.0.0.1 -N 2 &GOTO WINP2
GOTO PLAYER1
:UNAVAILABLE2
ECHO UNAVAILABLE CHOICE !
PING 127.0.0.1 -N 2 > NUL
GOTO PLAYER2
:EQUALITY
PING 127.0.0.1 -N 2 >NUL
CLS
ECHO EQUALITY !
ECHO.
SET /P REPLAY=REPLAY [Y/N] ?:
IF /I "%REPLAY%" EQU "Y" GOTO START
IF /I "%REPLAY%" EQU "N" PING 127.0.0.1 -N 2 > NUL &EXIT
:WINP1
PING 127.0.0.1 -N 2 > NUL
CLS
ECHO %PLAYER1% WON !
ECHO.
SET /P REPLAY=REPLAY [Y/N] ?:
IF /I "%REPLAY%" EQU "Y" GOTO START
IF /I "%REPLAY%" EQU "N" PING 127.0.0.1 -N 2 > NUL &EXIT
:WINP2
PING 127.0.0.1 -N 2 > NUL
CLS
ECHO %PLAYER2% WON !
ECHO.
SET /P REPLAY=REPLAY [Y/N] ?:
IF /I "%REPLAY%" EQU "Y" GOTO START
IF /I "%REPLAY%" EQU "N" PING 127.0.0.1 -N 2 > NUL &EXIT
:END
PING 127.0.0.1 -N 2 > NUL
CLS
SET /P CHOICE=EXIT [Y/N] ?:
IF /I "%CHOICE%" EQU "Y" GOTO START
IF /I "%CHOICE%" EQU "N" PING 127.0.0.1 -N 2 > NUL &EXIT


Voila, j'essayerai de faire une IA si j'ai le temps Smile




______________________________________________________
Viens découvrir INTERPOL, un nouveau langage interprété !

Yahoo Messenger
Message Publicité 
PublicitéSupprimer les publicités ?


Montrer les messages depuis:
Répondre au sujet Page 1 sur 1
  



Index | créer un forum | Forum gratuit d’entraide | Annuaire des forums gratuits | Signaler une violation | Conditions générales d'utilisation
Copyright 2008 - 2016 // Batch