CSC 15 Horse Race Lab Reminder: Important Linux commands. When running programs that draw graphics, please do not move the window while the program is running. If all goes well the program should stop when the mydraw function finishes. But sometimes you may want to stop it in the middle. For this, the best thing to do is the following: At the terminal prompt where you ran the program, type Control-Z. You'll see a message such as [5]+ Stopped python2 bounce.py This program is now a ZOMBIE. A zombie is a program that should have terminated but didn't. You need to kill it with the following command: kill -9 %5 The "5" needs to match the number in the message above. Don't leave zombies around: THEY WILL EAT YOUR BRAIN (i.e., they will eat your computer's memory and other resources.) At the command prompt, type the word "jobs". This shows all the programs at their current status are were started from the terminal window. You can kill them with the same command. ------------- 1. Make sure you have ready the function that returns an array of the INDICES of the largest number in an array: this function is used to determine which horses are leading the race, and eventually which horses win the race. You can put that in a file called "myfuns.py", in the same directory as the horserace program, then insert the following line at the top of the program to use it: from myfuns import * 2. Horse Race Simulation This is the main part of the lab, and requires you to complete a horse race simulation. You'll need to use the largest-indices function from class. Download "hroutline.py" which contains an outline program, and modify the "mydraw" function. You'll need to use an array to represent the x coordinates of each horse. The number of horses in the race MUST be variable. The program needs to contain a NESTED while loop. The outer loop controls animation, and stops when some horse crosses the finish line. The inner loop needs to iterate through the array of horses and increment the x position of each horse by a random value, as well as draw each horse on the screen. You then need to determine which horse is in the lead and print a message to screen using the drawtext function I've given you. Follow the notes and examples in the outline program. The finished product should look similar to the professor's sample program. The following elements are required in particular: A. Your program needs to work for ANY HUMBER of horses between 2 and 10. Use a variable to define the number of horses in the race. B. You need to draw lines to separate the horses between "tracks". You also need to draw the finish line. The exact position of the finish line is up to you (try width-50), and this is something you may have to experiment with to come up with a good value. ----------------- Options. The following could be done for extra credit 1. name the horses. Try to use the "command line argument array" sys.argv. First put "from sys import *" at the top of the program. When you start a python program, you can start using a command such as $ python2 horserace abc def ghi Inside the program, sys.argv[0]=="horserace", sys.argv[1]=="abc", etc.. Thus you can name the horses, as well as determine how many horses are going to be in the race when you start the program. 2. Find a background image, and instead of using a solid green rectangle, construct a more interesting background for the race 3. Use different animated gifs for each racer.