Partage
  • Partager sur Facebook
  • Partager sur Twitter

[batch] Puissance 4

    22 juillet 2021 à 11:38:56

    Bonjour à tous 

    Je crée ce sujet pour avoir un peu d'aide sur l'organisation du code  de mon puissance 4 j'aimerai savoir selon vous comment faire en sorte que l' "IA"  bloque l'adversaire mais surtout qu'elle gagne !!!

    Voici mon code  (si vous voulez vous amusez):

    @echo off 
    :var
    set /a round=0
    
    set l1c1=111
    set l2c1=111
    set l3c1=111
    set l4c1=111
    set l5c1=111
    set l6c1=111
    
    set l1c2=111
    set l2c2=111
    set l3c2=111
    set l4c2=111
    set l5c2=111
    set l6c2=111
    
    set l1c3=111
    set l2c3=111
    set l3c3=111
    set l4c3=111
    set l5c3=111
    set l6c3=111
    
    set l1c4=111
    set l2c4=111
    set l3c4=111
    set l4c4=111
    set l5c4=111
    set l6c4=111
    
    set l1c5=111
    set l2c5=111
    set l3c5=111
    set l4c5=111
    set l5c5=111
    set l6c5=111
    
    set l1c6=111
    set l2c6=111
    set l3c6=111
    set l4c6=111
    set l5c6=111
    set l6c6=111
    
    ::tour
    ::set /a j=%random%%%2
    :: if %j%==0 goto j1
    ::if %j%==1 goto ordi
    
    
    :deb
    REM FR. Affiche la grille - EN. show grid
    REM :: FR. L=Ligne - EN. L=Row
    REM :: FR. C=Colonne - EN. C=Column
    REM :: _ FR. Exemple L1C1 Ligne 1 Colonne 1 - EN. Exemple L1C1 Row 1 Column 1
    
    cls
    
    echo %l6c1% I %l6c2% I %l6c3% I %l6c4% I %l6c5% I %l6c6% I %l6c7%
    echo %l5c1% I %l5c2% I %l5c3% I %l5c4% I %l5c5% I %l5c6% I %l5c7%
    echo %l4c1% I %l4c2% I %l4c3% I %l4c4% I %l4c5% I %l4c6% I %l4c7%
    echo %l3c1% I %l3c2% I %l3c3% I %l3c4% I %l3c5% I %l3c6% I %l3c7%
    echo %l2c1% I %l2c2% I %l2c3% I %l2c4% I %l2c5% I %l2c6% I %l2c7%
    echo %l1c1% I %l1c2% I %l1c3% I %l1c4% I %l1c5% I %l1c6% I %l1c7% 
    echo.
    echo    1    
    REM if %tour%==ordi goto ordi
    REM if %tour%==j1 goto j1
    
    :j1
    
    set /p choix=FR. Nombre Colonne - EN. Column number:
    if %choix%==1 goto c1
    if %choix%==2 goto c2 
    if %choix%==3 goto c3
    if %choix%==4 goto c4 
    if %choix%==5 goto c5
    if %choix%==6 goto c6 
    if %choix%==7 goto c7
    
    
    :c1
    REM FR. Verifie la colonne 1  
    REM :: Fr. Pour placé le pion au bonne endroit
    
    
    if %l1c1%==111 (
    set l1c1=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l2c1%==111 (
    set l2c1=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l3c1%==111 (
    set l3c1=OOO
    :: set tour=Ordi
    goto deb
    )
    
    
    if %l4c1%==111 (
    set l4c1=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l5c1%==111 (
    set l5c1=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l6c1%==111 (
    set l6c1=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l6c1%==OOO (
    REM set tour=j1
    Echo choix impossible
    pause
    goto deb
    )
    
    
    if %l6c1%==XXX (
    REM set tour=j1
    Echo choix impossible
    pause
    goto deb
    )
    
    
    
    
    :c2
    
    
    if %l1c2%==111 (
    set l1c2=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l2c2%==111 (
    set l2c2=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l3c2%==111 (
    set l3c2=OOO
    :: set tour=Ordi
    goto deb
    )
    
    
    if %l4c2%==111 (
    set l4c2=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l5c2%==111 (
    set l5c2=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l6c2%==111 (
    set l6c2=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l6c2%==OOO (
    REM set tour=j1
    Echo choix impossible
    pause
    goto deb
    )
    
    
    if %l6c2%==XXX (
    REM set tour=j1
    Echo choix impossible
    pause
    goto deb
    )
    
    
    
    :c3
    
    
    if %l1c3%==111 (
    set l1c3=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l2c3%==111 (
    set l2c3=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l3c3%==111 (
    set l3c3=OOO
    :: set tour=Ordi
    goto deb
    )
    
    
    if %l4c3%==111 (
    set l4c3=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l5c3%==111 (
    set l5c3=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l6c3%==111 (
    set l6c3=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l6c3%==OOO (
    REM set tour=j1
    Echo choix impossible
    pause
    goto deb
    )
    
    
    if %l6c3%==XXX (
    REM set tour=j1
    Echo choix impossible
    pause
    goto deb
    )
    
    
    :c4
    
    
    if %l1c4%==111 (
    set l1c4=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l2c4%==111 (
    set l2c4=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l3c4%==111 (
    set l3c4=OOO
    :: set tour=Ordi
    goto deb
    )
    
    
    if %l4c4%==111 (
    set l4c4=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l5c4%==111 (
    set l5c4=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l6c4%==111 (
    set l6c4=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l6c4%==OOO (
    REM set tour=j1
    Echo choix impossible
    pause
    goto deb
    )
    
    
    if %l6c4%==XXX (
    REM set tour=j1
    Echo choix impossible
    pause
    goto deb
    )
    
    
    :c5
    
    
    if %l1c5%==111 (
    set l1c5=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l2c5%==111 (
    set l2c5=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l3c5%==111 (
    set l3c5=OOO
    :: set tour=Ordi
    goto deb
    )
    
    
    if %l4c5%==111 (
    set l4c5=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l5c5%==111 (
    set l5c5=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l6c5%==111 (
    set l6c5=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l6c5%==OOO (
    REM set tour=j1
    Echo choix impossible
    pause
    goto deb
    )
    
    
    if %l6c5%==XXX (
    REM set tour=j1
    Echo choix impossible
    pause
    goto deb
    )
    
    
    :c6
    
    
    if %l1c6%==111 (
    set l1c6=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l2c6%==111 (
    set l2c6=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l3c6%==111 (
    set l3c6=OOO
    :: set tour=Ordi
    goto deb
    )
    
    
    if %l4c6%==111 (
    set l4c6=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l5c6%==111 (
    set l5c6=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l6c6%==111 (
    set l6c6=OOO
    :: set tour=Ordi
    goto deb
    )
    
    if %l6c6%==OOO (
    REM set tour=j1
    Echo choix impossible
    pause
    goto deb
    )
    
    
    if %l6c6%==XXX (
    REM set tour=j1
    Echo choix impossible
    pause
    goto deb
    )
    
    
    
    
    
    
    
    

    Ici vous avez la 1er partie du code reste plus qu'à créer L'IA :D

    -
    Edité par Bidouillman 22 juillet 2021 à 15:12:56

    • Partager sur Facebook
    • Partager sur Twitter

    [batch] Puissance 4

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    • Editeur
    • Markdown