Racing Car

I created this application as a support idea for Cambridgeshire Software House's Maths in Motion challenge. There is a link to the site here. As sponsors, it seemed like a good idea to design something that would run alongside this challenge.

What I have done is to create some bends for the students to program PIPPIN to go around. These were done in Paint and size adjusted in my DTP package. I have included the pdf file for three bends here.

My first effort used a dark green background with a solid black roadway. This looked great but it used a tremendous amount of ink, so I got rid of the background and made the roadway grey. This is more economical.

In Paint, firstly you change the image size to something large that will nearly fill your computer screen. Then you draw the outline of the bend in a suitable colour. I liked red but yellow is also good. Use the curve tool with a wide line and put the ends of the line at suitable points on the edge of the image. This ensures that you can use the fill tool to fill in the roadway without filling the entire image. Make sure that the two lines are far enough apart all the way along so that PIPPIN can drive along the roadway. Once you are happy with the roadway, fill it with a suitable colour and save the image.

The image will almost certainly not be the right size. I read it into a DTP package and make it fill the page entirely. You can do this in Word if nothing better is available. Make sure that you set the page size to A3 and landscape orientation. You may need to set the margins to the smallest possible.

Once you have a roadway to run on, you will probably want to customise PIPPIN for this role. I used a picture of a racing car taken from the internet. This can then be sized in a drawing manipulation package and also flipped give a representation of the "other side" for the other side of PIPPIN. Then either print them out on magnetic paper, ordinary paper for backing with magnetic material, thin card for holding onto PIPPIN with a magnet or on either side of the blank cover. 

I used a Jaguar as they are also sponsors of Maths in Motion

So, you have a car and a roadway, now to solve the problem! The student has to program PIPPIN to get around the corner in the least possible time. They can start anywhere along the entry side of the bend and finish anywhere along the exit side but they must always stay within the confines of the roadway. For any bend that is wider than PIPPIN there will be a large number of solutions and a large number of run times. You will probably need some kind of stopwatch to differentiate between similar times.


This hairpin bend is typical. PIPPIN can get round with a large number of repeated small turns and movements, staying well away from the roadsides. This will be very slow. Left 45, Forward 15, Left 60, Forward 12, Left 60, Forward 15, works for me and takes about 9 seconds. Starting in a different place, at an angle, Forward 20, Left 90, Forward 12, Left 30, Forward 14, gives about 8 seconds. I am sure that this can be improved as I don't use the full width of the roadway well.

PIPPIN's movements have, in general, three phases: acceleration, cruising, braking. Acceleration and braking are quite short in distance. PIPPIN comes to rest between moves. The action of stopping and turning costs time but may save total distance run. For any bend, there will be an optimum tradeoff between total turning time, number of stops and distance run. I don't have a formula for this. It is probably a question of trial and error, but that's what practice time in a grand prix is for!

If you don't have a stopwatch, you could use two PIPPINs running on identical courses at the same time. If you wanted to, you could use several sheets of paper and make a complete circuit. This would be a very challenging programming task.

When trying a new route round a corner, it helps to use the Test function to try out each step of the program from where you have got to so far. It also helps to mark the exact starting position that you used for PIPPIN so that you can start each run from the same place. Selection of starting position can be crucial.

 Date Last Modified: 1/6/06 

Copyright © 2006 Swallow Systems