RETROGICIEL
JOUONS AU CHIFOUMI
RETROGICIEL
JOUONS AU CHIFOUMI
⇩. Présentation
Le chifoumi, ou pierre-feuille-ciseaux, ou encore roche-papier-ciseaux, oppose deux participants, qui doivent former avec une main soit :
- une pierre, la main est fermée ;
- la feuille, la main est ouverte ;
- les ciseaux, l'index et le majeur forment un V et les autres doigts sont repliés.
Les participants décident, avant le premier coup, du nombre de points qui faudra pour gagner la partie, en général 3, 5 ou 10 points. Au signal, les joueurs comptent jusqu'à 3 et présentent leur choix simultanément. Si les deux joueurs ont fait le même symbole, le coup est nul et ne compte pas, sinon le gagnant du match est défini selon les règles suivantes :
- la pierre casse les ciseaux et marque le point ;
- les ciseaux coupent la feuille et marque le point ;
- la feuille couvre la pierre et marque le point.
Créons un petit programme qui nous permettra d'affronter la machine.
⇩. Consignes
Le programme doit :
attendre que le joueur fasse son choix ;
faire un choix aléatoire pourla machine ;
désigner le gagnant du match et lui ajouter 1 point et si :
aucun participant n'a 5 points faire la ronde suivante ;
un des participant a 5 points :
désigner le gagnant de la partie ;
proposer de faire une autre partie ou de ;
- quitter le jeu.
D'abord, faite-le fonctionner. Ensuite, faite-le beau. Enfin, faite-le performant.
Amusez-vous bien !
Télécharger RETROGICIEL - Jouons au chiffoumi.
Cette présentation nécessite que Python 3 soit installé sur votre machine.
Après avoir téléchargé le fichier Le chifoumi.7z, décompressez le-dans le répertoire de votre choix.
Ouvrez le répertoire qui vient d'être créé.
Lancez le fichier Retrogiciel.py.
Cliquez sur l'onglet RUN et testez le programme.
Créez votre propre script dans un des langages proposés ou un autre de votre choix.
Le répertoire contient aussi :
- Python.py, l'exemple en PYTHON sans tkinter ;
- Tkinter.py, l'exemple en PYTHON avec tkinter ;
- Qb84.bas, l'exemple en QBASIC avec qb64 ;
- Bbc.bas, l'exemple en BBC BASIC avec bbc sdl.
# --- Origine Nerd ---
# --- RETROGICIEL - PYTHON ---
# --- Chifoumi ---
# -*- coding: utf-8 -*-
# --- IMPORTATION DES MODULES ---
import random
# --- INITIALISATION GÉNÉRALE ---
DCT_Choix = { "humain" : "" , "machine" : "" }
DCT_Scores = { "humain" : 0 , "machine" : 0 , "ronde" : 0 , "gagnant" : "aucun" }
# --- DÉFINITION DES FONCTIONS POUR PROGRAMME ADAPTE ---
# --- Analyse et recheche du gagnant ---
def FNC_Analyse ( ) :
# --- Recherche le gain de la ronde ---
match DCT_Choix [ "humain" ] :
case "P" : kgain = "humain" if DCT_Choix [ "machine" ] == "C" else "machine"
case "F" : kgain = "humain" if DCT_Choix [ "machine" ] == "P" else "machine"
case "C" : kgain = "humain" if DCT_Choix [ "machine" ] == "F" else "machine"
# --- Attribution du point au gagnant de la ronde ---
if kgain == "humain" :
print ( "Vous gagnez cette ronde. Félicitation." )
DCT_Scores [ "humain" ] += 1
if DCT_Scores [ "humain" ] > 4 : DCT_Scores [ "gagnant" ] = "humain"
else :
print ( "La machine remporte cette ronde." )
DCT_Scores [ "machine" ] += 1
if DCT_Scores [ "machine" ] > 4 : DCT_Scores [ "gagnant" ] = "machine"
# --- Nom complet d'un choix ---
def FNC_Choix ( Q ) :
if Q == "P" : return "PIERRE"
if Q == "F" : return "FEUILLE"
if Q == "C" : return "CISEAUX"
# --- Les choix est identiques pour les 2 joueurs ---
def FNC_Egalite ( ) :
print ( "match nul." )
# --- Saisie du choix de l'humain ---
def FNC_Humain ( ) :
while True :
print ( )
print ( "Entrez P pour choisir la pierre." )
print ( "Entrez F pour choisir la feuille." )
print ( "Entrez C pour choisir les ciseaux." )
kchoix = input ( "Entrez votre choix (P, F ou C) ... " )
if kchoix.upper ( ) in ( "P" , "F" , "C" ) : break
print ( "CHOIX INCORECT ! " )
return kchoix.upper ( )
# --- Fin d'un match (un joueur à 5 points ) ---
def FNC_Termine ( ) :
print ( "\n\npartie terminée." )
print ( f"vous { DCT_Scores [ 'humain' ] } - { DCT_Scores [ 'machine' ] } machine" )
if DCT_Scores [ "gagnant" ] == "humain" :
print ( "Vous avez gagné. FÉLICITATION !" )
else :
print ( "Vous avez perdu. Dommage. retentez votre chance." )
# --- PRESENTATION ---
print ( "JOUONS AU CHIFOUMI ! \n" )
print ( "La PIERRE casse les ciseaux et gagne." )
print ( "La FEUILLE couvre la pierre et gagne." )
print ( "Les CISEAUX coupent la feuille et gagne." )
print ( "Le gagnant est le premier à obtenir 5 points." )
# --- BOUCLE PRINCIPALE ---
while True :
# --- affichage et analyse des scores ---
DCT_Scores [ "ronde" ] += 1
print ( f"\n\nRonde : { DCT_Scores [ 'ronde' ] }. vous { DCT_Scores [ 'humain' ] } - { DCT_Scores [ 'machine' ] } machine" )
# --- choix des joueurs ( humain et machine ) ---
DCT_Choix [ "humain" ] = FNC_Humain ( )
DCT_Choix [ "machine" ] = random.choice ( "PFC" )
print ( )
print ( f"Vous avez choisi ......: { FNC_Choix ( DCT_Choix [ 'humain' ] ) }." )
print ( f"La machine a choisi ...: { FNC_Choix ( DCT_Choix [ 'machine' ] ) }." )
FNC_Egalite ( ) if DCT_Choix [ "humain" ] == DCT_Choix [ "machine" ] else FNC_Analyse ( )
# --- recheche une fin de partie (5 points) ---
if DCT_Scores [ "gagnant" ] != "aucun" :
FNC_Termine ( )
kchoix = input ( "\nUne autre partie [O]ui ou [N]on ? " )
if kchoix.upper ( ) == "N" : break
DCT_Scores [ "humain" ] = 0
DCT_Scores [ "machine" ] = 0
DCT_Scores [ "ronde" ] = 0
DCT_Scores [ "gagnant" ] = "aucun"
print ( "\n\nSuper ! On commence une nouvelle partie ... " )
# --- FIN DU PROGRAMME ---
print ( "\n\nAu revoir" )
# --- Programme : JFB ---
# --- Juillet 2025 ---
# --- Fin ---
Pour mieux comprendre l'exemple en PYTHON sans tkinter.
# --- Origine Nerd ---
# --- RETROGICIEL - TKINTER ---
# --- Chifoumi ---
# -*- coding: utf-8 -*-
# --- IMPORTATION DES MODULES ---
# --- Modules de la bibliothèque standard ---
import tkinter
import random
# --- DÉFINITION DES FONCTIONS PERSONNALISEES ---
# --- Analyse et résultat du match ---
def FNC_Analyse ( Qhumain , Qmachine ) :
# --- Recherche le gain de la ronde ---
match Qhumain :
case "PIERRE" : kgain = "humain" if Qmachine == "CISEAUX" else "machine"
case "FEUILLE" : kgain = "humain" if Qmachine == "PIERRE" else "machine"
case "CISEAUX" : kgain = "humain" if Qmachine == "FEUILLE" else "machine"
# --- Attribution du point au gagnant de la ronde ---
if kgain == "humain" :
LAB_Message [ "text" ] = "Vous gagnez cette ronde.\n"
kscore = int ( LAB_ScoreH [ "text" ] ) + 1
LAB_ScoreH [ "text" ] = kscore
else :
LAB_Message [ "text" ] = "La machine gagne cette ronde.\n"
kscore = int ( LAB_ScoreM [ "text" ] ) + 1
LAB_ScoreM [ "text" ] = kscore
# --- Annonce du gagnant de la partie (5 points) ---
def FNC_Gagnant ( Q ) :
LAB_ChoixH [ "text" ] = ""
LAB_ChoixM [ "text" ] = ""
if Q == "humain" : LAB_Message [ "text" ] = "Vous avez 5 points.\nVous avez GAGNÉ cette partie."
else : LAB_Message [ "text" ] = "La machine a 5 points.\nVous avez PERDU cette partie."
# --- Nouvelle ronde ou fin de partie ---
def FNC_Nouveau ( ) :
# --- Il y a un gagnant (5points), fin de la partie ---
kgagnant = "aucun"
if int ( LAB_ScoreH [ "text" ] ) > 4 : kgagnant = "humain"
if int ( LAB_ScoreM [ "text" ] ) > 4 : kgagnant = "machine"
if kgagnant != "aucun" :
FNC_Gagnant ( kgagnant )
BUT_Partie [ "state" ] = "normal"
# --- Il n'y a pas de gagnant, ronde suivante ---
else :
kronde = int ( FRM_Message [ "text" ].rsplit ( ) [ -1 ] ) + 1
LAB_ChoixH [ "text" ] = f"La PIERRE bat les ciseaux."
LAB_ChoixM [ "text" ] = f"Les CISEAUX battent la feuille."
LAB_Message [ "text" ] = "La FEUILLE bat les ciseaux.\nFaites votre choix."
FRM_Message [ "text" ] = f"Ronde : { kronde } "
BUT_Pierre [ "state" ] = "normal"
BUT_Feuille [ "state" ] = "normal"
BUT_Ciseaux [ "state" ] = "normal"
# --- Nouvelle partie ---
def FNC_Partie ( ) :
BUT_Partie [ "state" ] = "disabled"
LAB_ScoreH [ "text" ] = 0
LAB_ScoreM [ "text" ] = 0
FRM_Message [ "text" ] = f"Ronde : 0 "
FNC_Nouveau ( )
# --- Choix de la machine et recheche du gain ---
def FNC_Ronde ( Q ) :
# --- Mise en veille des choix du joueur ---
BUT_Pierre [ "state" ] = "disabled"
BUT_Feuille [ "state" ] = "disabled"
BUT_Ciseaux [ "state" ] = "disabled"
# --- Choix aléatoire de la machine ---
kmachine = random.choice ( ( "PIERRE" , "FEUILLE" , "CISEAUX" ) )
LAB_ChoixH [ "text" ] = f"vous avez choisi { Q }."
LAB_ChoixM [ "text" ] = f"La machine choisi { kmachine }."
# --- Analyse des choix du match ---
if Q == kmachine : LAB_Message [ "text" ] = "Match nul.\n"
else : FNC_Analyse ( Q , kmachine )
# --- Ronde suivante / nouvelle parie ---
TKI_Principal.after ( 3000 , FNC_Nouveau )
# --- CREATION DE L'INTERFACE GRAPHIQUE ---
# --- Création de la fenêtre principale ---
TKI_Principal = tkinter.Tk ( )
TKI_Principal.title ( "RETROGICIEL - Chifoumi" )
# --- Création des controles nommées ---
BUT_Partie = tkinter.Button ( TKI_Principal , text = "nouvelle partie" , command = FNC_Partie )
FRM_Scores = tkinter.LabelFrame ( TKI_Principal , text = " Scores. " , height = 55 )
LAB_ScoreH = tkinter.Label ( FRM_Scores, text = "0" , fg = "blue" , bg = "cyan" , bd = 2 , relief = "solid" )
LAB_ScoreM = tkinter.Label ( FRM_Scores, text = "0" , fg = "green" , bg = "palegreen" , bd = 2 , relief = "solid" )
FRM_Choix = tkinter.LabelFrame ( TKI_Principal , text = " Faites votre choix. " )
BUT_Pierre = tkinter.Button ( FRM_Choix , text = "PIERRE" , command = lambda : FNC_Ronde ( "PIERRE" ) )
BUT_Feuille = tkinter.Button ( FRM_Choix , text = "FEUILLE" , command = lambda : FNC_Ronde ( "FEUILLE" ) )
BUT_Ciseaux = tkinter.Button ( FRM_Choix , text = "CISEAUX" , command = lambda : FNC_Ronde ( "CISEAUX" ) )
FRM_Message = tkinter.LabelFrame ( TKI_Principal , text = " Ronde : 0 " )
LAB_ChoixH = tkinter.Label ( FRM_Message, text = "---" , fg = "blue" )
LAB_ChoixM = tkinter.Label ( FRM_Message, text = "---" , fg = "green" )
LAB_Message = tkinter.Label ( FRM_Message, text = "...\n" )
# --- Mise en place des controles (anonymes et nommés) dans la fenêtre principale ---
tkinter.Label ( TKI_Principal, text = "JOUONS A CHIFOUMI !" ).grid ( row = 0 , column = 0 , columnspan = 2 , sticky = "nesw" )
FRM_Scores.grid ( row = 1 , column = 0 , columnspan = 2 , sticky = "nesw" )
FRM_Choix.grid ( row = 2 , column = 0 , columnspan = 2 , sticky = "nesw" )
FRM_Message.grid ( row = 3 , column = 0 , columnspan = 2 , sticky = "nesw" )
BUT_Partie.grid ( row = 4 , column = 0 , sticky = "nesw" )
tkinter.Button ( TKI_Principal , text = "Quitter" , command = TKI_Principal.destroy ).grid ( row = 4 , column = 1 , sticky = "nesw" )
# --- MeP des controles dans le cadre des scores ---
tkinter.Label ( FRM_Scores , text = "vous" ).place ( x = 25 )
LAB_ScoreH.place ( x = 60 , width = 40 )
tkinter.Label ( FRM_Scores , text = "-" ).place ( x = 105 )
LAB_ScoreM.place ( x = 120 , width = 40 )
tkinter.Label ( FRM_Scores , text = "machine" ).place ( x = 160 )
# --- MeP des controles dans le cadre des choix ---
BUT_Pierre.pack ( side = "left" )
BUT_Feuille.pack ( side = "left" )
BUT_Ciseaux.pack ( side = "left" )
# --- MeP des controles dans le cadre des messages ---
LAB_ChoixH.pack ( )
LAB_ChoixM.pack ( )
LAB_Message.pack ( )
# --- Mise à jour de controle ---
FNC_Partie ( )
# --- DEBUT DU PROGRAMME ---
TKI_Principal.mainloop ( )
# --- Programme : JFB ---
# --- Juillet 2025 ---
# --- Fin ---
Pour mieux comprendre l'exemple en PYTHON avec tkinter.
' --- Origine Nerd propose pour ---
' --- RETROGICIEL - QB64 ---
' --- Chifoumi ---
' --- INITIALISATION GENERALE ---
' --- Definition des types utilisateurs ---
TYPE PER_Choix
humain AS STRING
machine AS STRING
END TYPE
TYPE PER_Scores
humain AS INTEGER
machine AS INTEGER
ronde AS INTEGER
gagnant AS STRING
END TYPE
' --- Declarations des variables globales ---
DIM SHARED DCT_Choix AS PER_Choix
DIM SHARED DCT_Scores AS PER_Scores
' --- Initialisation globale ---
LOCATE , , 1
RANDOMIZE TIMER
' --- DEBUT DU PROGRAMME ---
PRINT TAB(30); "JOUONS A CHIFOUMI."
PRINT TAB(20); "La PIERRE casse les ciseaux et gagne."
PRINT TAB(20); "La FEUILLE couvre la pierre et gagne."
PRINT TAB(19); "Les CISEAUX coupent la feuille et gagne."
PRINT TAB(17); "Le gagnant est le premier a obtenir 5 points."
PRINT STRING$(80, 205)
' --- BOUCLE PRINCIPALE ---
DO
' --- Nouvelle partie ---
DCT_Scores.humain = 0
DCT_Scores.machine = 0
DCT_Scores.ronde = 0
DCT_Scores.gagnant = "aucun"
' --- Les rondes de la partie ---
DO
VIEW PRINT 9 TO 24
FNC_Ronde
PRINT "Appuyez sur une touche pour poursuivre ... "
SLEEP: kpause$ = INKEY$
LOOP UNTIL DCT_Scores.gagnant <> "aucun"
' --- Partie terminee ---
CLS: PRINT
IF DCT_Scores.gagnant = "humain" THEN
PRINT TAB(17); "Vous avez 5 points. Vous gagnez cette partie."
PRINT TAB(33); "FELICITATION !"
ELSE
PRINT TAB(20); "La machine a 5 points. Vous avez perdu !"
END IF
' --- Bouclage du programme ---
PRINT TAB(22); "Voulez-vous recommencer [ O ou N ]"
SLEEP: kchoix$ = INKEY$
LOOP UNTIL UCASE$(kchoix$) = "N"
' --- FIN DU PROGRAMME ---
PRINT "Au revoir."
END
' --- DEFINITION DES FONCTIONS PERSONNALISEES ---
' --- Analyse des choix ---
FUNCTION FNC_Analyse$
' --- Recherche le gagnant de la ronde ---
kgagnant$ = "humain"
IF DCT_Choix.humain = "PIERRE" AND DCT_Choix.machine = "FEUILLE" THEN kgagnant$ = "machine"
IF DCT_Choix.humain = "FEUILLE" AND DCT_Choix.machine = "CISEAUX" THEN kgagnant$ = "machine"
IF DCT_Choix.humain = "CISEAUX" AND DCT_Choix.machine = "PIERRE" THEN kgagnant$ = "machine"
' --- Gestion des scores et recheche un vainqueur de partie ---
IF kgagnant$ = "humain" THEN
DCT_Scores.humain = DCT_Scores.humain + 1
IF DCT_Scores.humain = 5 THEN DCT_Scores.gagnant = "humain"
ELSE
DCT_Scores.machine = DCT_Scores.machine + 1
IF DCT_Scores.machine = 5 THEN DCT_Scores.gagnant = "machine"
END IF
' --- Retourne le gagnant de la ronde ---
FNC_Analyse$ = kgagnant$
END FUNCTION
' --- Saisie et controle du choix de l'humain ---
FUNCTION FNC_Humain$
' --- Gestion de l'ecran ---
VIEW PRINT 11 TO 20
' --- Saisie et controle de la validite du choix ---
DO
PRINT "Entrez P pour choisir la pierre."
PRINT "Entrez F pour choisir la feuille."
PRINT "Entrez C pour choisir les ciseaux."
PRINT "Choisissez P, F ou C ... ";
SLEEP: klettre$ = INKEY$
CLS
klettre$ = UCASE$(klettre$)
SELECT CASE klettre$
CASE "P": kchoix$ = "PIERRE"
CASE "F": kchoix$ = "FEUILLE"
CASE "C": kchoix$ = "CISEAUX"
CASE ELSE: kchoix$ = "autre"
END SELECT
LOOP UNTIL kchoix$ <> "autre"
VIEW PRINT 9 TO 20
CLS
' --- Retourne le choix du joueur ---
FNC_Humain$ = kchoix$
END FUNCTION
' --- Choix aleatoire de la machine ---
FUNCTION FNC_Machine$
' --- Choix aleatoire de la machine ---
kchoix = RND * 3000
SELECT CASE kchoix
CASE IS < 1000: kchoix$ = "PIERRE"
CASE IS > 1999: kchoix$ = "CISEAUX"
CASE ELSE: kchoix$ = "FEUILLE"
END SELECT
' --- Retourne le choix de la machine ---
FNC_Machine$ = kchoix$
END FUNCTION
' --- Nouvelle ronde ---
SUB FNC_Ronde
' --- Preparation de la nouvelle ronde ---
CLS
DCT_Scores.ronde = DCT_Scores.ronde + 1
PRINT "Ronde :"; DCT_Scores.ronde; ". Vous"; DCT_Scores.humain; "-"; DCT_Scores.machine; "machine."
' --- Choix des participants ---
DCT_Choix.humain = FNC_Humain$
DCT_Choix.machine = FNC_Machine$
PRINT "Vous avez choisi ...: "; DCT_Choix.humain
PRINT "La machine a choisi : "; DCT_Choix.machine
' --- Recherche du gagnant de la ronde ---
IF DCT_Choix.humain = DCT_Choix.machine THEN
PRINT "C'est un math nul"
ELSE
PRINT UCASE$(FNC_Analyse$); " marque le point."
END IF
' --- Affichage du score apres la ronde ---
PRINT "Vous"; DCT_Scores.humain; "-"; DCT_Scores.machine; "machine."
END SUB
' --- Programme : JFB ---
' --- Juillet 2025 ---
' --- Fin ---
Pour mieux comprendre l'exemple en QB64.
REM --- Origine Nerd propose pour ---
REM --- RETROGICIEL - BBC BASIC ---
REM --- Chifoumi ---
REM --- INITIALISATION GENERALE ---
REM --- Déclarations des variables globales ---
DIM DCT_Choix{humain$, machine$}
DIM DCT_Scores{humain, machine, ronde, gagnant$}
REM --- DEBUT DU PROGRAMME ---
PRINT TAB( 30 ) "JOUAONS AU CHIFOUMI !"
PRINT TAB( 20 ) "La PIERRE casse les ciseaux et gagne."
PRINT TAB( 20 ) "La FEUILLE couvre la pierre et gagne."
PRINT TAB( 19 ) "Les CISEAUX coupent la feuille et gagne."
PRINT TAB( 17 ) "Le gagnant est le premier a obtenir 5 points."
PRINT STRING$( 80 , "=" )
VDU 28 , 2 , 20 , 78 , 8
REM --- BOUCLE PRINCIPALE ---
REPEAT
REM --- Nouvelle partie ---
PROC_Nouveau
REM --- Nouvelle ronde ---
REPEAT
REM --- Presentation de la ronde ---
CLS
DCT_Scores{}.ronde += 1
PRINT TAB( 25 ) ; "Ronde : " ; DCT_Scores{}.ronde ;
PRINT ". vous " ; DCT_Scores{}.humain ; " - " ; DCT_Scores{}.machine ; " machine."
REM --- Choix des participant (joueur et machine) ---
PROC_Humain
PROC_Machine
khumain$ = "Vous avez choisi : " + DCT_Choix{}.humain$ + "."
kmachine$ = "La machine a choisi : " + DCT_Choix{}.machine$ + "."
kcolonne = ( 80 - LEN( khumain$ ) ) / 2
PRINT TAB( kcolonne ) khumain$
kcolonne = ( 80 - LEN( kmachine$ ) ) / 2
PRINT TAB( kcolonne ) kmachine$
REM --- Recharche du vainqueur de la ronde ---
IF DCT_Choix{}.humain$ <> DCT_Choix{}.machine$ THEN
PROC_Analyse
ELSE
PRINT TAB( 30 ) "C'est un match nul."
ENDIF
PRINT TAB( 30 ) "vous " ; DCT_Scores{}.humain ; " - " ; DCT_Scores{}.machine ; " machine."
PRINT TAB( 21 ) "Appuyez sur une touche pour continuer."
kpause = GET
REM --- Recherche un vainqueur de la parte (5 points) ---p
IF DCT_Scores{}.humain > 4 THEN DCT_Scores{}.gagnant$ = "humain"
IF DCT_Scores{}.machine > 4 THEN DCT_Scores{}.gagnant$ = "machine"
IF DCT_Scores{}.gagnant$ <> "aucun" THEN EXIT REPEAT
UNTIL FALSE
REM --- Fin d'une partie ---
CLS
PRINT TAB( 30 ) "vous " ; DCT_Scores{}.humain ; " - " ; DCT_Scores{}.machine ; " machine."
IF DCT_Scores{}.gagnant$ = "humain" THEN
PRINT TAB( 24 ) "FELICITATION VOUS AVEZ 5 POINTS !"
PRINT TAB( 25 ) "Vous avez gagne cette partie."
ELSE
PRINT TAB( 25 ) "La machine a obtenu 5 points."
PRINT TAB( 25 ) "Vous avez perdu cette partie."
ENDIF
PRINT TAB( 17 ) "Voulez-vous faire une autre partie [ O ou N ] ?"
kchoix$ = GET$
UNTIL kchoix$ = "N" OR kchoix$ = "n"
REM --- FIN DU PROGRAMME ---
CLS
PRINT TAB( 35 , 8 ) "Au revoir."
END
REM --- DEFINITION DES FONCTIONS PERSONNALISEES ---
REM --- Recherche du vainqueur d'une rond ---
DEF PROC_Analyse
REM --- Recheche du gagnant ---
kgagnant$ = "humain"
IF DCT_Choix{}.humain$ = "PIERRE" AND DCT_Choix{}.machine$ = "FEUILLE" THEN kgagnant$ = "machine"
IF DCT_Choix{}.humain$ = "FEUILLE" AND DCT_Choix{}.machine$ = "CISEAUX" THEN kgagnant$ = "machine"
IF DCT_Choix{}.humain$ = "CISEAUX" AND DCT_Choix{}.machine$ = "PIERRE" THEN kgagnant$ = "machine"
REM --- Affichage du gagnant et ajout du point a son score ---
IF kgagnant$ = "humain" THEN
PRINT TAB( 24 ) "Vous gagnez cette ronde. Bravo."
DCT_Scores{}.humain += 1
ELSE
PRINT TAB( 25 ) "La machine gagne cette ronde."
DCT_Scores{}.machine += 1
ENDIF
ENDPROC
REM --- Saisie et controle du choix du joueur ---
DEF PROC_Humain
REM --- Presentation des choix ---
VDU 28 , 2 , 20 , 78 , 10
PRINT "Appuyez sur : "
PRINT "P pour choisir PIERRE."
PRINT "F pour choisir FEUILLE."
PRINT "C pour choisir CISEAUX."
REM --- Saisie et validite du choix du joueur ---
REPEAT
ktouche$ = GET$
CASE ktouche$ OF
WHEN "P" , "p" : kchoix$ = "PIERRE"
WHEN "F" , "f" : kchoix$ = "FEUILLE"
WHEN "C" , "c" : kchoix$ = "CISEAUX"
OTHERWISE kchoix$ = "rien"
ENDCASE
UNTIL kchoix$ <> "rien"
REM --- Memorisation du choix du joueur ---
DCT_Choix{}.humain$ = kchoix$
VDU 28 , 2 , 20 , 78 , 8
CLS
ENDPROC
REM --- Choix aleatoire de la machine ---
DEF PROC_Machine
ktirage = RND( 3000 )
DCT_Choix{}.machine$ = "FEUILLE"
IF ktirage < 1001 THEN DCT_Choix{}.machine$ = "PIERRE"
IF ktirage > 2000 THEN DCT_Choix{}.machine$ = "CISEAUX"
ENDPROC
REM --- Initialisation d'une nouvelle partie ---
DEF PROC_Nouveau
DCT_Scores{}.humain = 0
DCT_Scores{}.machine = 0
DCT_Scores{}.ronde = 0
DCT_Scores{}.gagnant$ = "aucun"
ENDPROC
REM --- Programme : JFB ---
REM --- Juillet 2025 ---
REM --- Fin ---
Pour mieux comprendre l'exemple en BBC BASIC.