Advertisement
Guest User

Untitled

a guest
May 24th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. import numpy as np
  2. from enum import Enum
  3.  
  4. class Strategie(Enum):
  5.  
  6.     CHANGER = 1
  7.     GARDER = 2
  8.  
  9. def play(strategie, nb_tours):
  10.     # 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.
  11.     choix_joueurs = np.random.randint(1,3,(nb_tours,1))
  12.     bonne_porte = np.random.randint(1,3,(nb_tours,1))
  13.    
  14.     #Si la stratégie est GARDER, alors le joueur ne gagne que si son premier choix était la bonne porte
  15.     if strategie == Strategie.GARDER :
  16.         return choix_joueurs == bonne_porte.astype(int)
  17.     #Si la stratégie est CHANGER, alors le joueur ne gagne que si son premier choix n'était pas la bonne porte
  18.     elif strategie == Strategie.CHANGER :
  19.         return np.logical_not(choix_joueurs == bonne_porte).astype(int)
  20.     else:
  21.         raise ValueError("Stratégie non reconnue!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement