##### Horse race game
 Horse race game Moreal Unladen Swallow Posts: 1 Threads: 1 Joined: Sep 2020 Reputation: 0 Sep-20-2020, 06:56 PM Hey, I am creating a "horse race" game for a class project. So I have to simulate 16 random numbers, and the player has to guess the 5 firsts. So he can win the "ordre", when he have guessed the 5, the "desordre" when he've guessed the 5 but not in the correct order, and finally the "Bonus 3" and "Bonus 4" when he've guessed the first 3 or 4. So, I have made a few functions, for the "ordre", for the simulation of the random numbers ( simule_arrivee ) and for the "desordre" and the bonus ( comparaison ), but I have to make a function that I'll have too call to simulate the entire game ( joue_quinte(pari) ) in which the parameter will be replaced by the player when calling it in the shell. So I have created this function, but I have no clue on how to do it... Anyone could help pls ? ( sorry for my english and for the french names in the code btw ^^' )import random def simule_arrivee(tabjeu): for i in range (1, 6): variable = random.randrange(1, 17) while variable in tabjeu: variable = random.randrange(1, 17) tabjeu.append(variable) return tabjeu def joue_quinte(pari): tableau_pari=[] tableau_jeu=[] for i in pari: tableau_pari.append(i) def ordre(tabjeu, tabpari): compteur = 0 for i in range(0,5): if tabjeu[i] == tabpari[i]: compteur += 1 if compteur == 5: return "Ordre" def comparaison(tabjeu, tabpari) : compteur_bis= 0 for i in range(len(tabjeu)): for j in range(len(tabpari)): if tabpari[j] == tabjeu[i] : compteur_bis +=1 if compteur_bis == 3: return "Bonus 3" elif compteur_bis == 4: return "Bonus 4" elif compteur_bis == 5: return "Désordre" Reply Posts: 2,736 Threads: 32 Joined: Jan 2018 Reputation: 253 Sep-20-2020, 08:02 PM (This post was last modified: Sep-20-2020, 08:03 PM by Gribouillis.) I think you need to describe a complete scenario of interaction between a player and the program, for example The user starts the program The program displays a welcome message and asks for the player's bet for the next race The player types their bet and hit the return key The program "parses" the player's input and interpretes it as a sequence of horses numbers The program fills the list tableau_pari with the player's bet The program simulates the race and stores the result in a list tabjeu The program finds the result of the bet by calling ordre() and comparaison() The program prints the result of the bet and exits Then you only need to write a function that performs all these steps and call it at the end of the program. Reply

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020