I can't determine how to randomly list horses as they cross various parts of the track. Will someone please point me in the write direction?

if bet > 1:   #starts the race, if bet when bet is placed
    print ("""
Here come the horses now, folks.  They're being loaded into the 
starting gate.  It wont be long now.
           """)
    time.sleep(3)   #delay for convenience
    print "And they're off"
    time.sleep(3)
    lead = (horse1, horse2, horse3, horse4, horse5)
    x = random.shuffle(lead)
    print ("As they come out of the first turn, it's: "), x
    time.sleep(3)
    print ("As they pass the halfway mark, it's:"), x
    time.sleep(3)
    print ("As they pass the last turn, it's:"), x
    time.sleep(3)
    print ("This is going to be a photo finish.  As they pass the finish line, it's:"), x

Recommended Answers

All 2 Replies

Please try to make your titles and questions as abstract as possible. This way the "next guy" can search and find something usable. If you ask "How do I randomly select an element of an array?" that is much more reusable than "How do I make a horse finish first?".

Dave

You could just use the random shuffle thing you already have. Or you could decide how long the slowest horse would take for each segment, and call random.random()*intervalMax for each horse for each interval. Add the intervals so far, and show the horses in reverse sorted order.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.