Accueil > > > JEU DE PIERRE, FEUILLE, CISEAUX (JANKENPON)
JEU DE PIERRE, FEUILLE, CISEAUX (JANKENPON)
Information sur la source
Description
Qui n'as jamais joué au Pierre, Feuille, Ciseau? Inutile donc de rappeler en quoi ça consiste. Amusez-vous !
Source
- // Crée avec SharpDevelop (http://www.icsharpcode.net/OpenSource/SD/Default.aspx)
- // Mail du programmeur: yanngeffrotin@gmail.com
- // [je l'utilise donc je le soutiens avec www.paypal.fr]
-
-
- /* Algorithme du Jaken (version épurée)
-
- Algo Jaken
-
- Constantes
-
- Variables
- scor, scor2, choix : entiers
- texte, choix2 : caractères
-
- DEBUT
-
- Afficher "Jeu de Jaken"
- Afficher "Licence publique générale GNU"
-
- scor <- 0
- scor2 <- 0
- choix <- 0
- choix2 <- "pierre"
-
- Répéter
- Afficher " "
- Répéter
- Afficher "pierre, papier ou ciseau?"
- Saisir texte
- Jusqu'à texte="pierre" ou texte="papier" ou texte="ciseau"
-
- si texte = "pierre" alors
- choix <- 0
- finsi
- si texte = "papier" alors
- choix <- 1
- finsi
- si texte = "ciseau" alors
- choix <- 2
- finsi
-
- Afficher " "
- Afficher "joueur1: ", texte
-
- nb <- aléatoire(2)
-
- si nb = 0 alors
- choix2 <- "pierre"
- finsi
- si nb = 1 alors
- choix2 <- "papier"
- finsi
- si nb = 2 alors
- choix2 <- "ciseau"
- finsi
-
- Afficher "joueur2: ", choix2
- Afficher " "
-
- si choix=0 et nb=0 alors
- Afficher "Partie Nulle."
- sinon
- si choix=0 et nb=1 alors
- Afficher "Le papier recouvre la pierre."
- scor2 <- scor2 + 1
- sinon
- si choix=0 et nb=2 alors
- Afficher "La pierre casse les ciseaux."
- scor <- scor + 1
- finsi
- finsi
- finsi
-
- si choix=1 et nb=0 alors
- Afficher "Le papier enveloppe la pierre."
- scor <- scor + 1
- sinon
- si choix=1 et nb=1 alors
- Afficher "Partie Nulle."
- sinon
- si choix=1 et nb=2 alors
- Afficher "Le ciseau coupe le papier."
- scor2 <- scor2 + 1
- finsi
- finsi
- finsi
-
- si choix=2 et nb=0 alors
- Afficher "La pierre casse le ciseau."
- scor2 <- scor2 + 1
- sinon
- si choix=2 et nb=1 alors
- Afficher "Le ciseau coupe le papier."
- scor <- scor + 1
- sinon
- si choix=2 et nb=2 alors
- Afficher "Partie Nulle."
- finsi
- finsi
- finsi
-
- Afficher " "
- Afficher "Les scores sont :"
- Afficher "Joueur1 : ", scor
- Afficher "Joueur2 : ", scor2
- Afficher " "
-
- Répéter
- Afficher "Encore une partie?(O/N)"
- Saisir texte
- texte <- agrandir(texte)
- Jusqu'à texte="N" ou texte="O"
-
- jusqu'à texte="N"
-
- FIN
-
- */
-
- using System;
-
- namespace Jaken
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- Console.WriteLine(" "); //Annonce du début
- Console.WriteLine("Jeu de Jaken"); // rock scissor paper
- Console.WriteLine("Licence publique générale GNU"); // http://www.gnu.org/licenses/gpl.html
-
- //Constantes et Variables //variable locale non assignée
-
- string texte1;
- string texte2="rien";
-
- bool exit = false;
-
- int choix1 = 0; // choix du joueur 1 ( 0, 1, 2 )
- int choix2 = 0; // choix du joueur 2 ( 0, 1, 2 )
-
-
- int nbtour = 1; // Le premier tour commence
- int Maxtab = 531; // Taille maximal du tableau
-
- int[] Tchoix = new int[Maxtab];
- int[] Tetat = new int[Maxtab]; //perdu(0), nul(1), gagne(2)
-
-
- //DEBUT
- do
- {
- int scor1 = 0; // Le score du joueur 1
- int scor2 = 0; // Le score du joueur 2
- Console.WriteLine(" ");
- Console.WriteLine("----------");
- Console.WriteLine("(F) - Mode facile");
- Console.WriteLine("(M) - Mode moyen");
- Console.WriteLine("(D) - Mode difficile");
- Console.WriteLine("(S) - Sortir");
- Console.WriteLine("----------");
- texte1 = Console.ReadLine();
- texte1 = texte1.ToUpper();
- Console.WriteLine("----------");
- Console.WriteLine(" ");
- switch (texte1)
- {
- case "S": // Sortie
- break;
-
- case "F": // Humain contre Machine Random
- exit = false;
- nbtour=1;
- do //Début de la boucle
- { Console.WriteLine(" ");
- Console.WriteLine("--- mode facile, tour n°" + nbtour + " ---");
- choix_humain(ref texte2, ref exit);
- if (texte1 != "quitter")
- { convert_to_nb(texte2, ref choix1);
- choix_random(ref choix2);
- convert_to_string(choix2);
- gagnants_et_résultats(choix1, choix2, ref scor1, ref scor2, ref Tetat, nbtour);
- nbtour = nbtour + 1;
- }
- } while (exit != true); //Fin de la boucle
- break;
-
- case "M": // Humain contre Méthode Minasi
- exit = false;
- nbtour=1;
- do //Début de la boucle
- { Console.WriteLine(" ");
- Console.WriteLine("--- mode moyen, tour n°" + nbtour + " ----");
- choix_humain(ref texte2, ref exit);
- if (texte2 != "quitter")
- { convert_to_nb(texte2, ref choix1);
- algorithme_de_Minasi(ref choix2, nbtour, choix1, Tchoix);
- gagnants_et_résultats(choix1, choix2, ref scor1, ref scor2, ref Tetat, nbtour);
- nbtour = nbtour + 1;
- }
- } while (exit != true); //Fin de la boucle
- break;
-
- case "D": // Humain contre Algo de Shannon
- int[] Tstat = new int[29]; //27 + 1 vide + 1 nul
- exit = false;
- nbtour=1;
- do //Début de la boucle
- { Console.WriteLine(" ");
- Console.WriteLine("--- mode difficile, tour n°" + nbtour + " ---");
- choix_humain(ref texte2, ref exit);
- if (texte2 != "quitter")
- { convert_to_nb(texte2, ref choix1);
- algorithme_de_Shannon(ref choix2, nbtour, choix1, Tstat, Tchoix, Tetat);
-
- gagnants_et_résultats(choix1, choix2, ref scor1, ref scor2, ref Tetat, nbtour);
- nbtour = nbtour + 1;
- }
- } while (exit != true); //Fin de la boucle
- break;
- }
- } while (texte1 != "S"); //texte1 != "0" && texte1 != "à"
- //FIN
- }
-
- static void choix_humain(ref string texte2, ref bool exit)
- { Console.WriteLine(" ");
- do
- {
- Console.WriteLine("pierre, papier, ciseau ou quitter?");
- texte2 = Console.ReadLine();
- texte2 = texte2.ToLower();
- } while (texte2 != "pierre" && texte2 != "papier" && texte2 != "ciseau" && texte2 != "quitter");
-
- if (texte2 == "quitter" )
- { exit = true; }
- }
-
- static void convert_to_nb(string texte, ref int choix1)
- { if (texte == "pierre" )
- { choix1 = 0; }
-
- if (texte == "papier")
- { choix1 = 1; }
-
- if (texte == "ciseau")
- { choix1 = 2; }
-
- Console.WriteLine(" ");
- Console.WriteLine("joueur1: " + texte);
- }
-
- static void choix_random(ref int choix2)
- { Random r = new Random(); //Aléatoire : jeu de hasard pur
- choix2 = r.Next(2);
- }
-
- static void convert_to_string(int choix2)
- { string texte2 = "pierre"; // use of unassigned local variable
- if (choix2 == 0)
- { texte2 = "pierre"; }
- if (choix2 == 1)
- { texte2 = "papier"; }
- if (choix2 == 2)
- { texte2 = "ciseau"; }
- Console.WriteLine("joueur2: " + texte2);
- }
-
-
- static void algorithme_de_Minasi(ref int choix2, int nbtour, int choix1, int[] Tchoix)
- { //Algorithme de Minasi : Stocke les coups joués dans un tableau, recherche le meilleur coups
-
- int cpt;
- int Maxproba = 0;
- int[] Tstat = new int[3];
- Tstat[0] = Tstat[1] = Tstat[2] = 0;
- int nboccurence = 0;
-
- Tchoix[nbtour] = choix1;
-
- if (nbtour > 2)
- {
- for (cpt = 1; cpt <= nbtour - 1; cpt++)
- {
- if (Tchoix[cpt] == Tchoix[nbtour - 1])
- {
- nboccurence = nboccurence + 1;
-
- if (Tchoix[cpt + 1] == 0) // pierre
- { Tstat[0] = Tstat[0] + 1;
- }
-
- if (Tchoix[cpt + 1] == 1) //papier
- { Tstat[1] = Tstat[1] + 1;
- }
-
- if (Tchoix[cpt + 1] == 2) //ciseau
- { Tstat[2] = Tstat[2] + 1;
- }
- }
- }
- }
- else
- { choix_random(ref choix2);
- }
-
- if (Tstat[0] > Tstat[1]) // Recherche du maximum
- {
- if (Tstat[0] > Tstat[2])
- { Maxproba = 0; }
- }
- else
- {
- if (Tstat[1] > Tstat[2])
- { Maxproba = 1; }
- else
- { Maxproba = 2; }
- }
-
- Maxproba = Maxproba + 1; // choix Minasi = choix adversaire + 1
- if (nbtour > 2)
- {choix2 = Maxproba ;}
-
- // Choix du joueur 2
- if (choix2 == 3)
- {choix2 = 0;} // Le 3 redevient 0
-
- //Affichage du choix du joueur 2
- convert_to_string(choix2);
- }
-
- static void algorithme_de_Shannon(ref int choix2, int nbtour, int choix, int[] Tstat, int[] Tchoix, int[] Tetat)
- { //Algorithme de Shannon : Affecte dans un arbre des probabilités, l'apparition des coups et l'état des parties, séléction du plus probable
-
- int i = 0;
- int Maxstat = 0;
- int Maxstatcontenu = 0;
- int j, k, l ;
- Tchoix[nbtour] = choix;
-
- if (nbtour > 2)
- { // 3*3*3=27 possibilités par tour
- for (j=0;j<=2;j++)
- {
- for (k=0;k<=2;k++)
- {
- for (l=0;l<=2;l++)
- {
- i = i + 1 ;
- if (Tetat[nbtour - 2] == j && Tchoix[nbtour - 1] == k && Tetat[nbtour - 1] == l)
- {
- Tstat[i] = Tstat[i] + 1;
- }
- Console.WriteLine("Stat n°"+i+" : "+ Tstat[i]+ " (tour "+(nbtour-2)+"="+j+", choix tour-1="+k+", etat précédent="+l+")"); //affiche l'arbre
- }
- }
- }
-
- for (i = 1; i <= 27; i++) // Recherche du maximum
- { //Console.WriteLine("Maxstat["+ (i-1) +"] : " + Tstat[i]);
- //Console.WriteLine("Maxstatcontenu : " + Maxstatcontenu);
- if (Tstat[i] > Maxstatcontenu)
- { Maxstat = i;
- Maxstatcontenu = Tstat[i];
-
- }
- }
-
- // choix Shannon = choix adversaire le plus probable + 1
- if (Maxstat == 1 || Maxstat == 2 || Maxstat == 3 || Maxstat == 10 || Maxstat == 11 || Maxstat == 12 || Maxstat == 19 || Maxstat == 20 || Maxstat == 21)
- {choix2 = 1;}
- if (Maxstat == 4 || Maxstat == 5 || Maxstat == 6 || Maxstat == 13 || Maxstat == 14 || Maxstat == 15 || Maxstat == 22 || Maxstat == 23 || Maxstat == 24)
- {choix2 = 2;}
- if (Maxstat == 7 || Maxstat == 8 || Maxstat == 9 || Maxstat == 16 || Maxstat == 17 || Maxstat == 18 || Maxstat == 25 || Maxstat == 26 || Maxstat == 27)
- {choix2 = 0;}
-
- convert_to_string(choix2);
- }
- else
- {
- choix_random(ref choix2);
- convert_to_string(choix2);
- }
- }
-
- static void gagnants_et_résultats(int choix1, int choix2, ref int scor1, ref int scor2, ref int[] Tetat, int nbtour)
- { // Détermination des gagnants et affichage des résultats
-
- Console.WriteLine(" ");
- if (choix1 == 0 && choix2 == 0)
- {
- Console.WriteLine("Partie Nulle.");
- Tetat[nbtour] = 1; //"nul"
- }
- else
- {
- if (choix1 == 0 && choix2 == 1)
- {
- Console.WriteLine("Le papier recouvre la pierre.");
- scor2 = scor2 + 1;
- Tetat[nbtour] = 0; //"perdu"
- }
- else
- {
- if (choix1 == 0 && choix2 == 2)
- {
- Console.WriteLine("La pierre casse les ciseaux.");
- scor1 = scor1 + 1;
- Tetat[nbtour] = 2; //"gagne"
- }
- }
- }
- if (choix1 == 1 && choix2 == 0)
- {
- Console.WriteLine("Le papier enveloppe la pierre.");
- scor1 = scor1 + 1;
- Tetat[nbtour] = 2;
- }
- else
- {
- if (choix1 == 1 && choix2 == 1)
- {
- Console.WriteLine("Partie Nulle.");
- Tetat[nbtour] = 1;
- }
- else
- {
- if (choix1 == 1 && choix2 == 2)
- {
- Console.WriteLine("Le ciseau coupe le papier.");
- scor2 = scor2 + 1;
- Tetat[nbtour] = 0;
- }
- }
- }
-
- if (choix1 == 2 && choix2 == 0)
- {
- Console.WriteLine("La pierre casse le ciseau.");
- scor2 = scor2 + 1;
- Tetat[nbtour] = 0;
- }
- else
- {
- if (choix1 == 2 && choix2 == 1)
- {
- Console.WriteLine("Le ciseau coupe le papier.");
- scor1 = scor1 + 1;
- Tetat[nbtour] = 2;
- }
- else
- {
- if (choix1 == 2 && choix2 == 2)
- {
- Console.WriteLine("Partie Nulle.");
- Tetat[nbtour] = 1;
- }
- }
- }
- //Affichage des résultats
- Console.WriteLine(" ");
- Console.WriteLine("Les scores sont :");
- Console.WriteLine("Joueur1 : " + scor1);
- Console.WriteLine("Joueur2 : " + scor2);
- }
- }
- }
// Crée avec SharpDevelop (http://www.icsharpcode.net/OpenSource/SD/Default.aspx)
// Mail du programmeur: yanngeffrotin@gmail.com
// [je l'utilise donc je le soutiens avec www.paypal.fr]
/* Algorithme du Jaken (version épurée)
Algo Jaken
Constantes
Variables
scor, scor2, choix : entiers
texte, choix2 : caractères
DEBUT
Afficher "Jeu de Jaken"
Afficher "Licence publique générale GNU"
scor <- 0
scor2 <- 0
choix <- 0
choix2 <- "pierre"
Répéter
Afficher " "
Répéter
Afficher "pierre, papier ou ciseau?"
Saisir texte
Jusqu'à texte="pierre" ou texte="papier" ou texte="ciseau"
si texte = "pierre" alors
choix <- 0
finsi
si texte = "papier" alors
choix <- 1
finsi
si texte = "ciseau" alors
choix <- 2
finsi
Afficher " "
Afficher "joueur1: ", texte
nb <- aléatoire(2)
si nb = 0 alors
choix2 <- "pierre"
finsi
si nb = 1 alors
choix2 <- "papier"
finsi
si nb = 2 alors
choix2 <- "ciseau"
finsi
Afficher "joueur2: ", choix2
Afficher " "
si choix=0 et nb=0 alors
Afficher "Partie Nulle."
sinon
si choix=0 et nb=1 alors
Afficher "Le papier recouvre la pierre."
scor2 <- scor2 + 1
sinon
si choix=0 et nb=2 alors
Afficher "La pierre casse les ciseaux."
scor <- scor + 1
finsi
finsi
finsi
si choix=1 et nb=0 alors
Afficher "Le papier enveloppe la pierre."
scor <- scor + 1
sinon
si choix=1 et nb=1 alors
Afficher "Partie Nulle."
sinon
si choix=1 et nb=2 alors
Afficher "Le ciseau coupe le papier."
scor2 <- scor2 + 1
finsi
finsi
finsi
si choix=2 et nb=0 alors
Afficher "La pierre casse le ciseau."
scor2 <- scor2 + 1
sinon
si choix=2 et nb=1 alors
Afficher "Le ciseau coupe le papier."
scor <- scor + 1
sinon
si choix=2 et nb=2 alors
Afficher "Partie Nulle."
finsi
finsi
finsi
Afficher " "
Afficher "Les scores sont :"
Afficher "Joueur1 : ", scor
Afficher "Joueur2 : ", scor2
Afficher " "
Répéter
Afficher "Encore une partie?(O/N)"
Saisir texte
texte <- agrandir(texte)
Jusqu'à texte="N" ou texte="O"
jusqu'à texte="N"
FIN
*/
using System;
namespace Jaken
{
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine(" "); //Annonce du début
Console.WriteLine("Jeu de Jaken"); // rock scissor paper
Console.WriteLine("Licence publique générale GNU"); // http://www.gnu.org/licenses/gpl.html
//Constantes et Variables //variable locale non assignée
string texte1;
string texte2="rien";
bool exit = false;
int choix1 = 0; // choix du joueur 1 ( 0, 1, 2 )
int choix2 = 0; // choix du joueur 2 ( 0, 1, 2 )
int nbtour = 1; // Le premier tour commence
int Maxtab = 531; // Taille maximal du tableau
int[] Tchoix = new int[Maxtab];
int[] Tetat = new int[Maxtab]; //perdu(0), nul(1), gagne(2)
//DEBUT
do
{
int scor1 = 0; // Le score du joueur 1
int scor2 = 0; // Le score du joueur 2
Console.WriteLine(" ");
Console.WriteLine("----------");
Console.WriteLine("(F) - Mode facile");
Console.WriteLine("(M) - Mode moyen");
Console.WriteLine("(D) - Mode difficile");
Console.WriteLine("(S) - Sortir");
Console.WriteLine("----------");
texte1 = Console.ReadLine();
texte1 = texte1.ToUpper();
Console.WriteLine("----------");
Console.WriteLine(" ");
switch (texte1)
{
case "S": // Sortie
break;
case "F": // Humain contre Machine Random
exit = false;
nbtour=1;
do //Début de la boucle
{ Console.WriteLine(" ");
Console.WriteLine("--- mode facile, tour n°" + nbtour + " ---");
choix_humain(ref texte2, ref exit);
if (texte1 != "quitter")
{ convert_to_nb(texte2, ref choix1);
choix_random(ref choix2);
convert_to_string(choix2);
gagnants_et_résultats(choix1, choix2, ref scor1, ref scor2, ref Tetat, nbtour);
nbtour = nbtour + 1;
}
} while (exit != true); //Fin de la boucle
break;
case "M": // Humain contre Méthode Minasi
exit = false;
nbtour=1;
do //Début de la boucle
{ Console.WriteLine(" ");
Console.WriteLine("--- mode moyen, tour n°" + nbtour + " ----");
choix_humain(ref texte2, ref exit);
if (texte2 != "quitter")
{ convert_to_nb(texte2, ref choix1);
algorithme_de_Minasi(ref choix2, nbtour, choix1, Tchoix);
gagnants_et_résultats(choix1, choix2, ref scor1, ref scor2, ref Tetat, nbtour);
nbtour = nbtour + 1;
}
} while (exit != true); //Fin de la boucle
break;
case "D": // Humain contre Algo de Shannon
int[] Tstat = new int[29]; //27 + 1 vide + 1 nul
exit = false;
nbtour=1;
do //Début de la boucle
{ Console.WriteLine(" ");
Console.WriteLine("--- mode difficile, tour n°" + nbtour + " ---");
choix_humain(ref texte2, ref exit);
if (texte2 != "quitter")
{ convert_to_nb(texte2, ref choix1);
algorithme_de_Shannon(ref choix2, nbtour, choix1, Tstat, Tchoix, Tetat);
gagnants_et_résultats(choix1, choix2, ref scor1, ref scor2, ref Tetat, nbtour);
nbtour = nbtour + 1;
}
} while (exit != true); //Fin de la boucle
break;
}
} while (texte1 != "S"); //texte1 != "0" && texte1 != "à"
//FIN
}
static void choix_humain(ref string texte2, ref bool exit)
{ Console.WriteLine(" ");
do
{
Console.WriteLine("pierre, papier, ciseau ou quitter?");
texte2 = Console.ReadLine();
texte2 = texte2.ToLower();
} while (texte2 != "pierre" && texte2 != "papier" && texte2 != "ciseau" && texte2 != "quitter");
if (texte2 == "quitter" )
{ exit = true; }
}
static void convert_to_nb(string texte, ref int choix1)
{ if (texte == "pierre" )
{ choix1 = 0; }
if (texte == "papier")
{ choix1 = 1; }
if (texte == "ciseau")
{ choix1 = 2; }
Console.WriteLine(" ");
Console.WriteLine("joueur1: " + texte);
}
static void choix_random(ref int choix2)
{ Random r = new Random(); //Aléatoire : jeu de hasard pur
choix2 = r.Next(2);
}
static void convert_to_string(int choix2)
{ string texte2 = "pierre"; // use of unassigned local variable
if (choix2 == 0)
{ texte2 = "pierre"; }
if (choix2 == 1)
{ texte2 = "papier"; }
if (choix2 == 2)
{ texte2 = "ciseau"; }
Console.WriteLine("joueur2: " + texte2);
}
static void algorithme_de_Minasi(ref int choix2, int nbtour, int choix1, int[] Tchoix)
{ //Algorithme de Minasi : Stocke les coups joués dans un tableau, recherche le meilleur coups
int cpt;
int Maxproba = 0;
int[] Tstat = new int[3];
Tstat[0] = Tstat[1] = Tstat[2] = 0;
int nboccurence = 0;
Tchoix[nbtour] = choix1;
if (nbtour > 2)
{
for (cpt = 1; cpt <= nbtour - 1; cpt++)
{
if (Tchoix[cpt] == Tchoix[nbtour - 1])
{
nboccurence = nboccurence + 1;
if (Tchoix[cpt + 1] == 0) // pierre
{ Tstat[0] = Tstat[0] + 1;
}
if (Tchoix[cpt + 1] == 1) //papier
{ Tstat[1] = Tstat[1] + 1;
}
if (Tchoix[cpt + 1] == 2) //ciseau
{ Tstat[2] = Tstat[2] + 1;
}
}
}
}
else
{ choix_random(ref choix2);
}
if (Tstat[0] > Tstat[1]) // Recherche du maximum
{
if (Tstat[0] > Tstat[2])
{ Maxproba = 0; }
}
else
{
if (Tstat[1] > Tstat[2])
{ Maxproba = 1; }
else
{ Maxproba = 2; }
}
Maxproba = Maxproba + 1; // choix Minasi = choix adversaire + 1
if (nbtour > 2)
{choix2 = Maxproba ;}
// Choix du joueur 2
if (choix2 == 3)
{choix2 = 0;} // Le 3 redevient 0
//Affichage du choix du joueur 2
convert_to_string(choix2);
}
static void algorithme_de_Shannon(ref int choix2, int nbtour, int choix, int[] Tstat, int[] Tchoix, int[] Tetat)
{ //Algorithme de Shannon : Affecte dans un arbre des probabilités, l'apparition des coups et l'état des parties, séléction du plus probable
int i = 0;
int Maxstat = 0;
int Maxstatcontenu = 0;
int j, k, l ;
Tchoix[nbtour] = choix;
if (nbtour > 2)
{ // 3*3*3=27 possibilités par tour
for (j=0;j<=2;j++)
{
for (k=0;k<=2;k++)
{
for (l=0;l<=2;l++)
{
i = i + 1 ;
if (Tetat[nbtour - 2] == j && Tchoix[nbtour - 1] == k && Tetat[nbtour - 1] == l)
{
Tstat[i] = Tstat[i] + 1;
}
Console.WriteLine("Stat n°"+i+" : "+ Tstat[i]+ " (tour "+(nbtour-2)+"="+j+", choix tour-1="+k+", etat précédent="+l+")"); //affiche l'arbre
}
}
}
for (i = 1; i <= 27; i++) // Recherche du maximum
{ //Console.WriteLine("Maxstat["+ (i-1) +"] : " + Tstat[i]);
//Console.WriteLine("Maxstatcontenu : " + Maxstatcontenu);
if (Tstat[i] > Maxstatcontenu)
{ Maxstat = i;
Maxstatcontenu = Tstat[i];
}
}
// choix Shannon = choix adversaire le plus probable + 1
if (Maxstat == 1 || Maxstat == 2 || Maxstat == 3 || Maxstat == 10 || Maxstat == 11 || Maxstat == 12 || Maxstat == 19 || Maxstat == 20 || Maxstat == 21)
{choix2 = 1;}
if (Maxstat == 4 || Maxstat == 5 || Maxstat == 6 || Maxstat == 13 || Maxstat == 14 || Maxstat == 15 || Maxstat == 22 || Maxstat == 23 || Maxstat == 24)
{choix2 = 2;}
if (Maxstat == 7 || Maxstat == 8 || Maxstat == 9 || Maxstat == 16 || Maxstat == 17 || Maxstat == 18 || Maxstat == 25 || Maxstat == 26 || Maxstat == 27)
{choix2 = 0;}
convert_to_string(choix2);
}
else
{
choix_random(ref choix2);
convert_to_string(choix2);
}
}
static void gagnants_et_résultats(int choix1, int choix2, ref int scor1, ref int scor2, ref int[] Tetat, int nbtour)
{ // Détermination des gagnants et affichage des résultats
Console.WriteLine(" ");
if (choix1 == 0 && choix2 == 0)
{
Console.WriteLine("Partie Nulle.");
Tetat[nbtour] = 1; //"nul"
}
else
{
if (choix1 == 0 && choix2 == 1)
{
Console.WriteLine("Le papier recouvre la pierre.");
scor2 = scor2 + 1;
Tetat[nbtour] = 0; //"perdu"
}
else
{
if (choix1 == 0 && choix2 == 2)
{
Console.WriteLine("La pierre casse les ciseaux.");
scor1 = scor1 + 1;
Tetat[nbtour] = 2; //"gagne"
}
}
}
if (choix1 == 1 && choix2 == 0)
{
Console.WriteLine("Le papier enveloppe la pierre.");
scor1 = scor1 + 1;
Tetat[nbtour] = 2;
}
else
{
if (choix1 == 1 && choix2 == 1)
{
Console.WriteLine("Partie Nulle.");
Tetat[nbtour] = 1;
}
else
{
if (choix1 == 1 && choix2 == 2)
{
Console.WriteLine("Le ciseau coupe le papier.");
scor2 = scor2 + 1;
Tetat[nbtour] = 0;
}
}
}
if (choix1 == 2 && choix2 == 0)
{
Console.WriteLine("La pierre casse le ciseau.");
scor2 = scor2 + 1;
Tetat[nbtour] = 0;
}
else
{
if (choix1 == 2 && choix2 == 1)
{
Console.WriteLine("Le ciseau coupe le papier.");
scor1 = scor1 + 1;
Tetat[nbtour] = 2;
}
else
{
if (choix1 == 2 && choix2 == 2)
{
Console.WriteLine("Partie Nulle.");
Tetat[nbtour] = 1;
}
}
}
//Affichage des résultats
Console.WriteLine(" ");
Console.WriteLine("Les scores sont :");
Console.WriteLine("Joueur1 : " + scor1);
Console.WriteLine("Joueur2 : " + scor2);
}
}
}
Historique
- 31 décembre 2005 12:04:19 :
- J'ai ajouté les contrôles de saisies pour l'utilisateur.
J'ai simplifié les structures conditionnelles.
- 20 janvier 2006 18:07:49 :
- Ajout de l'algorithme du jeu de pierre, papier, ciseau (Jaken).
- 26 janvier 2006 15:31:52 :
- Ajout du zip et contrôle d'erreurs
- 26 janvier 2006 15:35:28 :
- Ajout du zip et contrôle d'erreurs
- 14 février 2006 20:11:34 :
- Ajout de l'algorithme de Minasi qui fait un historique des coups joués afin de porter le meilleur coup.
- 17 février 2006 08:43:26 :
- Correction d'un bug et optimisation de l'algorithme de Minasi
- 01 mars 2006 19:34:11 :
- Ajout de l'algorithme de Shannon : Affecte dans un arbre des probabilités l'apparition des coups et l'état des parties avec séléction du plus probable.
- 12 mars 2006 14:09:40 :
- Correction de bugs dans l'arborescence de Shannon
- 13 mai 2006 16:08:42 :
- Ajout d'une interface graphique pour Windows
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Imprimer des données sur une feuille mise en forme (automatiquement) [ par Sunnyprog ]
Bonjour, Je souhaiterai savoir si il est possible de tirer des données contenues dans une base de données pour les placer automatiquement dans les cha
Feuille de style et "include" [ par Kati83 ]
Bonjour à tous,Je voudrais vous poser 2 questions (pas très compliquées).La 1è : Si j'ai une page aspx qui contient beaucoup d'html, et pour le reste
imprimer 2 pages sur une seule [ par samscapa ]
J'utilise un editeur de texte (TXTControl) style word dans ma form, je peux y trouver du texte, des images ou des tableaux.Je voudrais par exemple ecr
Cherche acces aux controls ajoutés dans feuille Excel (TextBox) en C# [ par rustinefujitsu ]
Bonjour,j'ai besoin de recuperer la valeur contenue dans un control "Zone de texte" (ex:TextBox1.value) inclut dans une feuille Excel ( et également d
Probléme de menu avec Visual Studio.NET [ par silvia12 ]
Bonjours, J'ai un petit probléme sur mon programme. J'ai fait une page principale en MdiParent avec un menu. Ensuite j'ai fais plusieur feuille enfant
Obtenir la classe d'une feuille fille MdiChildren [ par MAQFAB ]
Prenons une application simple avec une classe FeuilleMDI et deux classe FeuilleFille1 et FeuilleFille2.Je veux intercepter l'évènement Closing sur Fe
Affichege d'une feuille MDI fille [ par jacma ]
BonjourJ'ai un problème d'affichage d'une feuille MDI fille dans une feuille mère. J'appelles la feuille par un menu, la feuille s'ouvre mais ne s'aff
chaine + help [ par emmanuel9 ]
Bonjour, Le problème est le suivant J'ai une chaine, par exemple " jean &n
utlisation dans une ihm d'une classe? [ par Cookai ]
Bonjour,voila j'ai un petit probléme.Je sais que quand on créée une nouvelle feuille(WinForm) ,il se crée automatiquement une clas
c# Importation feuille Excel vers un DataTable [ par Caro2005 ]
Bonjour,Je souhaite importer des données situées dans une feuille Excel vers un DataTable. Pas de pb pour l'accès à ma feuille Exc
|
Derniers Blogs
UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|