Skip to main content
GameDev.net gamedev.net
🔒 Locked

Probability and Training

Started by arithma Jul 29, 2007 at 4:07 PM 0 replies 850+ views
Original Post
arithma
arithma
I'm going to model horses in a race track each as a set of speeds. For each race, a certain speed will be picked and used. To model training, an improved speed will be added instead of another speed. What am interested in is whether there's redundancy in this modeling, because such redundancies unnecessarily complicate code, and the results are over simplistic. Oh, and any ideas about the concept are welcome as well.
mrcheesewheel
mrcheesewheel
Well... the absolute speed of the horses in the race doesn't really matter as such... only the relative speeds. This means that you could simply have a number associated with each horse that represents how good it is at racing (possibly scaled by various factors... the ground conditions, the weather, the track type, training, age of horse etc). Once you have a single value representing how good each horse is... you can add them all up... eg:

horse1=5.0
horse2=3.0
horse3=2.0

Then you add the numbers together (ie 10.0) then you get a random number generator to make a number from 0 to 10.0... then you decide who should win based on:

horse1 wins if rand is in [0.0, 5.0)
horse2 wins if rand is in [5.0, 8.0)
horse3 wins if rand is in [8.0, 10.0]

This tells you which horse should win the race... on the remaining horses you repeat the process to find out who comes second and so on until all horses have a place. Now you know who comes in which place... you can then animate based on some mean velocity the horse must race at in order to win... and add various other effects (eg if the horse that came in last was one of the "favourites" you make him fall). The key here is that the animation of the horses running is generated after the fact based on who won. If you wanted to have the animation more closely reflect the horses absolute skills... the number becomes a speed... and throughout the race the horse moves at a randomly chosen speed distributed normally around it's mean speed. This means the horse will go faster and slower at various parts of the race... and a slow horse may overtake a fast horse "by chance". The probability of winning for each horse in this case is the same as the method I suggested, but it seems to involve a lot more redundant calculation to calculate the winner. In this case the player could "skip to the end" if they wanted and it'd just announce the results rather than them having to watch the race (as in the other approach the race they watch is the race that the winning is based on).

As for ensuring they horses appear to finish in the correct order... all you need to do is have a predicted velocity to cause the horses to end in your determined order... and from that, at any time in the race, you know where each horse should be. At the finish line, the horses must lie exactly on this predicted line, but throughout the rest of the race they may lie behind or in front of that line as you wish. One could for example forward predict where they had to be (relative to the true finish positions) at several points throughout the race (based on some probability). The first and last positions must lie exactly on the start and finish lines... but the other points can be ahead or behind as you choose. These points would be like "keyframes" that the horse would run between. Ideally these keyframes should be different for each horse... otherwise the player might notice all the horses always accelerate and deccelerate at exactly the same time. It's also worth remembering that though a linear interpolation of velocity to correct the position will look ok... it's preferable to have horse gradually accelerate or decellerate to get to its final position. This will lead to a smoother and more natural flow of the race. Anyway, this is the approach I think I'd take.
Hope it helps,

Dan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.