# Défi n°3

{% hint style="success" %}
Voici le dernier défi : **Créer le jeu en entier !** Vous pouvez vous aider de l'exemple de solution ci-dessous. Si le défi est trop difficile, passez directement à la partie exercices.
{% endhint %}

#### Exemple de solution

```python
import random

def jeterLeDe():
  resultat = random.randint(1,6)
  print("Résultat du lancé : {}".format(resultat))
  return resultat

def afficherLeScore(valeur1, valeur2):
  print("_________________________________")
  print("SCORES")
  print("Joueur 1 : {}       Joueur 2 : {}".format(valeur1, valeur2))
  print("_________________________________")
  print("")

print("##########################################")
print("Bonjour, bienvenue dans le jeu du cochon !")
print("##########################################")
print("")

scoreJoueur1 = 0
scoreJoueur2 = 0
tourJoueur1 = True

while(scoreJoueur1 < 100 and scoreJoueur2 < 100):
    if(tourJoueur1):
      print("\n #### TOUR DU JOUEUR 1 ####")
    else:
      print("\n #### TOUR DU JOUEUR 2 ####")
    rejouer = "o"
    resultat = jeterLeDe()
    if (resultat == 1):
      print("Le dé est tombé sur 1, vous passez votre tour")
      tourJoueur1 = not(tourJoueur1)

    while(rejouer == "o" and resultat != 1):
      print("Le dé n'est pas tombé sur 1")
      print("")
      rejouer = input("Voulez vous rejouer ? (si oui, taper 'o' sinon taper Entrer)  : \n")
      if(rejouer == "o"):
        resultat = jeterLeDe()
        if (resultat == 1):
          print("Le dé est tombé sur 1, vous passez votre tour")
          tourJoueur1 = not(tourJoueur1)
          rejouer = "n"
          afficherLeScore(scoreJoueur1, scoreJoueur2)
      else :
        if(tourJoueur1):
          scoreJoueur1 = scoreJoueur1 + resultat
        else : 
          scoreJoueur2 = scoreJoueur2 + resultat
        afficherLeScore(scoreJoueur1, scoreJoueur2)
        tourJoueur1 = not(tourJoueur1)

if(scoreJoueur1 > 100):
  "Victoire du joueur 1"
else:
  "Victoire du joueur 2"
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mathieu-bonte.gitbook.io/cours-i2d/algorithmie-en-python/untitled/creation-dun-jeu/defi-n-3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
