Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from enum import Enum
- class Strategie(Enum):
- CHANGER = 1
- GARDER = 2
- def play(strategie, nb_tours):
- # On génère deux vecteurs contenant le premier choix du joueur et la bonne porte pour tous les tours qui vont être joués.
- choix_joueurs = np.random.randint(1,3,(nb_tours,1))
- bonne_porte = np.random.randint(1,3,(nb_tours,1))
- #Si la stratégie est GARDER, alors le joueur ne gagne que si son premier choix était la bonne porte
- if strategie == Strategie.GARDER :
- return choix_joueurs == bonne_porte.astype(int)
- #Si la stratégie est CHANGER, alors le joueur ne gagne que si son premier choix n'était pas la bonne porte
- elif strategie == Strategie.CHANGER :
- return np.logical_not(choix_joueurs == bonne_porte).astype(int)
- else:
- raise ValueError("Stratégie non reconnue!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement