pierre_feuille_ciseaux.py

Created by johnnyboulayq

Created on November 01, 2024

3.2 KB

Pierre Feuille Ciseaux


import random
from ion import *
from kandinsky import *
from time import *

DIF = 0
PLAYER = 0
BOT = random.randint(1, 9)
TYPE = 0

fill_rect(0, 0, 355, 255, color(0, 0, 100))
draw_string("Choisi ton mode", 70, 0, color(50, 50, 50))
draw_string(" [1] - Facile  ", 70, 70)
draw_string("   Bientot...  ", 70, 100, color(50, 50, 50))
draw_string("   Bientot...  ", 70, 130, color(50, 50, 50))

while DIF == 0:
    if keydown(KEY_ONE):
        DIF = 1

fill_rect(0, 0, 355, 255, color(0, 0, 100))

if DIF == 1:
    draw_string("Mode Facile", 70, 100)

sleep(1)

while True:
    if TYPE == 0:
        fill_rect(0, 0, 355, 255, color(0, 0, 100))
        draw_string("Choisi bien ce que tu vas \nprendre", 0, 100)
        sleep(2)

        while PLAYER == 0:
            fill_rect(0, 0, 355, 255, color(0, 0, 100))
            draw_string("Choisi bien ce que tu vas \nprendre", 0, 0)
            draw_string("[1] - Pierre  ", 100, 70)
            draw_string("[2] - Feuille ", 100, 100)
            draw_string("[3] - Ciseaux ", 100, 130)

            if keydown(KEY_ONE):
                PLAYER = 1  # Pierre choisi
            if keydown(KEY_TWO):
                PLAYER = 2  # Feuille choisie
            if keydown(KEY_THREE):
                PLAYER = 3  # Ciseaux choisis
            sleep(0.01)
        TYPE = 1
    else:
        # Le jeu commence
        fill_rect(0, 0, 355, 255, color(0, 0, 100))
        draw_string("3", 150, 100, color(0, 255, 0))
        sleep(1)
        fill_rect(0, 0, 355, 255, color(0, 0, 100))
        draw_string("2", 150, 100, color(255, 127, 0))
        sleep(1)
        fill_rect(0, 0, 355, 255, color(0, 0, 100))
        draw_string("1", 150, 100, color(255, 0, 0))
        sleep(1)
        fill_rect(0, 0, 355, 255, color(0, 0, 100))
        draw_string("GO!", 150, 100)
        sleep(1)

        # Générer le choix de l'IA après que le joueur ait choisi
        BOT = random.randint(1, 9)  # L'IA choisit
        fill_rect(0, 0, 355, 255, color(0, 0, 100))

        while not keydown(KEY_OK):
            if PLAYER == 1:
                draw_string("Toi - Pierre", 0, 100)
            elif PLAYER == 2:
                draw_string("Toi - Feuille", 0, 100)
            elif PLAYER == 3:
                draw_string("Toi - Ciseaux", 0, 100)

            if BOT == 1 or BOT == 4 or BOT == 7:
                draw_string("IA - Pierre", 0, 130)
            elif BOT == 2 or BOT == 5 or BOT == 8:
                draw_string("IA - Feuille", 0, 130)
            elif BOT == 3 or BOT == 6 or BOT == 9:
                draw_string("IA - Ciseaux", 0, 130)
            
            sleep(0.01)

            # Vérifier les résultats
            if PLAYER == BOT:
                draw_string("Egalité!", 0, 0, color(255, 255, 0))  # Jaune pour égalité
            
            elif (PLAYER == 1 and BOT == 2) or (PLAYER == 2 and BOT == 3) or (PLAYER == 3 and BOT == 1):
                draw_string("L'IA a gagné", 0, 0, color(255, 0, 0))  # Rouge pour IA gagnante
            
            else:
                draw_string("Tu as gagné", 0, 0, color(0, 255, 0))  # Vert pour joueur gagnant


        fill_rect(0, 0, 355, 255, color(0, 0, 100))
        TYPE = 0
        PLAYER = 0
        BOT = random.randint(1, 9)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.