5. Vector Race Game


General Description

This program is meant to show how vectors can be used to direct the position of a car round a race track. General instructions are seen when the program is started. The names of the players are requested, and a warning is given that the vectors are 'cumulative' and indicate 'speed' and direction. This means that next position is determined by your previous vector. The game is single key stroke entry, except when putting in your names, when the return key must be used. The 'delete' has not been allowed when selecting your vector . . . ie get it right. The vectors are displayed vertically without the enclosing brackets. You might wish to enhance this.
   When playing the game the person whose go it is and his/her previous vector are displayed. Most textual messages occur at the top of the screen, except for crash and collision which occur in the centre of the screen and generate alarming sounds. The track of the 'car' is left as a white 'echo' on the screen and though it is theoretically possible, as the program is written, to crash on an echo, no third year has yet done so.

Detailed Description

   Lines 10-310 The main structure of the program: nothing surprising except that I have used three flags on lines 280 and 290 when I could have squeezed it down to two. The only important point is that 'CAR = CAR + 1' must go at line 230 and not earlier or later as PROCgetvector assumes CAR values 0 and 1 rather than 1 and 2.
   320-530 The 'X' and 'Y' values in line 370 will hold the previous position of the car. The array 'A$' had to be dimensioned earlier as it also holds the names of the contestants - indeed it is used for several functions.
   540-700 The race track is drawn by overlaying three text and graphics windows to give the yellow track surrounded by red. It is quicker than triangular fill.
   710-890 'UD' stands for up/down and 'LR' stands for left/right. The moves are counted to stop someone cheating by reversing straight over the finish line (see below). Lines 790-830 over-plot the old position of the car in white. If you find the 'bug', which I suspect is there but cannot generate, then line 790 will have to become GCOL0,2 and you will lose the white track.
   900-1280 Information is displayed in the text window at the top of the screen in lines 980-1030. Lines 1040-1250 actually collect the vector from the player. The vector is validated and restricted to a number between -9 and 9. The vector is collected as a single character and translated into a number subsequently.
   1290-1420 If you change the start positions, then you will need to change the start message at line 690.
   1430-1580 The car is checked for off limits by a colour test for yellow at line 1480. The collision check from 1490-1520 sees if the cars are within 12 pixels of each other. On the basis of experiments, this seemed acceptable, but all that needs to be changed is the value 12 in line 1520 if you are not satisfied. The victory check assumes that each car has done at least 15 moves. It is possible to get round in 15 moves so the quick reverse freak has nothing to gain. The victory check makes certain that your final position is within reasonable limits.
   1590-1900 Self-evident, and looking at it again, not quite perfect as there is only one statement's difference between the crash and collision routines. Still, it is easily readable.
   1910-2460 The instructions here are free for you to change. I have noticed that the instructions do not say that vectors are limited from -9 to 9, but when I have loaded the game for the class, I have dropped a word in their ear and they seem to have had no problems.
   2470-end The error trap you may leave off, but the data is the start data for the game.

Educational Notes

I have used this to teach vectors to low ability third years. The idea is developed from an old one which we do with pencil and paper and it helps to play the game on paper first to acquaint them with the concept of vectors. I do not recommend the game as a panacea for actual teaching, but once they have mastered the simple paper track, the entertainment value of the game shows its worth.
   Because we do not have enough machines, they play in groups of four a mini-league between them. It would be possible to do a single class demonstration, but then some of the messages would need to be changed.