A Day at the Random Races

Objectives
In completing this project you will gain experience with the following Java features:
MVC architecture
ArrayLists
building GUI with various components
listeners, event driven GUI elements
delay loops
Problem Statement
For this project we are going to simulate a horse race. Our horses, or perhaps their jockeys, are
a bit peculiar. When racing, each horse moves either one unit forward or one unit backwards
with each stride. The probability of the forward stride (‘fitness’) is the same for all horses. In
order to avoid an inordinate long race the probability shall be chosen by you between 0.55 and
0.6. A more sophisticated program may allow individual fitness selections for the horses. If we
set the fitness to 0.5 it would follow that if a horse is, say 20 units down the track, about half the
time it ends up 19 units, and about half the time 21 units down the track. If the fitness is greater
than 0.5, then the horse makes forward strides more likely than backwards, a good chance that
all horses finish the race within a reasonable short time. The setup sure makes for an
interesting, and sometimes still very long, race.
The user is allowed to configure the race track by specifying the number of tracks (1-12) which
is also the number of horses running in the given race. The length of the track is a preselected
value, recommended choice is 25.

We will simulate the race by keeping track of how far each horse has galloped down the track.
The program provides a graphical display of the race, horse positions are continually updated
and displayed on the race GUI. At the start of the race each horse is at the starting gate (a
distance of 0). During each step we will simulate each horse making one random stride and we
update its distance. We will not allow any horse to stride backwards from the starting gate.
Whenever a horse finishes the race, meaning that the distance down the track is equal to the
pre-set track length, we will no longer generate a random stride for that horse neither shall we
update its distance. In addition to keeping track of where each horse is on the track, we will also
maintain the number of strides taken and the placement in order of finish.
When all horses have crossed the finish line the race ends, and the final results, the finishing
placement and the number of strides can be read on the race GUI. An independent score board
showing the same outcomes is optional.
The required visual representations of the race at developing phases are shown on Figures 1

Leave a Reply

Your email address will not be published. Required fields are marked *