General Description
This long program combines game playing with a simulation. The game is basically a Stock Market game in which you trade with a restricted number of companies and try to make the goal of $100,000 from the $10,000 that you start with. The simulation begins when you are able to set the parameters of the game and play against your own parameters of those chosen for you by the teacher.
When the game begins, you are given the introductory messages, and then you may select the parameters option. Type any key to avoid this, and the simulation moves straight into the stock market panel of information. To control the game there is single key entry as specified except that share purchases must be entered with the 'Return' key. The parameters, if chosen, are also single key entry and must be entered as required including '+' or '-' signs as requested, decimal points if asked for and double digit numbers if required. This is part of the data validation.
You will see the companies displayed, hopefully in green, then two columns in white. The first column is the actual market valuation in pence, and the second column is the last price change in pence. Then follow two more columns in green. The first is your actual share holding and the second is the value of the shares you hold.
Under the yellow line at the bottom is displayed the cash you currently have at your disposal, the week of the simulation, and the total of the valuations of your share holdings.
Information messages are displayed in the remaining area of the screen. Once you have chosen a share in which to trade, you may not return to that share in the current week. You may process the shares in any order. The final messages are a bit trite and you may like to improve on them. Two listings are given: the fully documented listing which will run only on a Model 'B' and the same program, undocumented, which will run on an 'A' or 'B'.
Unfortunately the line numbers do not agree between listings, but otherwise the programs are identical.
Detailed Description
Generally this refers to the documented version.
Lines 10-530 These give the main structure of the program. The GOTO in line 360 irritates me, and could have been avoided with an additional flag. As you go through the program you will notice I have used two variables 'FIRMS' and 'FIRM'. These are different - as intended. In line 480 and subsequently, the word 'Total' must be written as viewed or the reserved word 'TO' will be detected in 'TOTAL'.
550-690 This routine both works out the value of your holding in the last column, called 'PRICE', (as 'VALUE' has the reserved word 'VAL' in it), calls the share display procedure, and sounds a suitable note. You will notice the delay is different between the two listings on line 660. This is because in the shortened version execution is quicker and the time for which the note sounds in the shorter listing would slur into the next note were not the delay extended in the shorter version.
700-910 For this section you need the WIDTH set to 0. That is the BBC default value, but you my have changed it by mistake. Everything must be typed in exactly as shown. You will find that the screen only just holds all the information required, and will not tolerate any deviance.
930-1000 The 'caveats' to the previous routine apply here as well. Do not try to change the display or you will get some very strange results. In line 960, the "" is deliberate. Put it in.
1030-1080 I had trouble in placing characters on the screen without altering the teletext colour, hence the VDU commands. The blank spaces are needed to clear unwanted characters from the screen on sale of a large amount.
1090-1290 The key line here is 1220. This determines the outcome of the game. The TREND of each economic cycle, the length of which you may set as a parameter at the beginning, combined with the programmed success of each company called 'LUCK' and the economic bias you give the program called 'BIAS', determines whether a share will move up or down. The RANGE in line 1230 is another parameter you have control of. This decides the maximum possible increase or decrease in value of a share. A smaller range provides a difficult simulation. Its default is 80, the maximum.
1310-1380 This routine decides whether the TREND for an economic cycle is 'up' or 'down' - 'bull' or 'bear' - and also sets the range of the TREND.
1400-1620 This routine displays the question on the screen and if you type 'O' will set a flag which will send you on to the next week, otherwise selecting the company in which you wish to trade. The keyboard buffer is cleared at line 1470 and the reply restricted to the digits 1-9.
1630-1820 This simply takes in details from the keyboard of the proposed share purchase and does some validation on the input. At this point it is possible to crash the program by typing a character repeatedly till you reach the bottom of the screen and the display is disrupted. Also, if you mix letters and numbers on the input, the numerical value of the numbers before the alpha letters is taken as the proposed purchase. These are features of the BBC input. A fully validated INPUT procedure can be written if you wish. However, in use with 4th and 5th year students, these problems were never encountered accidentally.
1830-1970 This simulation is generous. Overdrafts are granted from time to time and the overdraft procedure is called in the enough-cash procedure, to determine your financial status. Overdrafts are only granted in a boom and when the cash you request is less than $5000 (line 1920).
1980-2060 There is a share limit of 50,000 to inhibit crazy single company speculation. This is not offered as a start parameter but the value in line 2050 is all that needs to be changed.
2070-2150 This routine is included to inhibit large sales after week 8. The disaster will only occur once - once is enough, but should you wish to transfer more than $15,000 when you will lose it to the unscrupulous broker.
2160-2240 This routine combines bankcharges and brokerage fees. Both may be set as start of simulation parameters.
2250-2440 This routine is called anytime a transaction involves a change of screen status and has to be called before the screen is re-displayed. The procedure 'Total' is called from within this to update the total value of your holdings displayed in yellow on the middle right of the screen.
2450-2680 If you choose not to set your own parameters, the default parameters are set up in this routine. It is important that DFLAG1 in line 2580 is set up to '0' rather than FALSE - as it is not truly a flag.
2690-2790 This is not really about cheating at all, but is included to prevent you reneging on a purchase or sale decision. If you wish to allow people to have a 'second bite at the cherry' then ignore procsettle in the main structure of the program.
2800-2960 This routine clears the bottom part of the screen to allow different messages to be displayed. In the delay procedure the delay required is passed into the local variable DEL on calling the procedure.
2970-3120 Self evident.
3130-3250 These conditions are carefully thought out to prevent too quick a win. If you want the disasters to reoccur then leave out the flag from the condition. I think it is fundamentally unfair to hit a person when he's down, so they get hit just once. You will find that there are times when for several games no disasters occur and at other times they seem to pile in.
3260-3550 This routine is meant to teach the folly of heading without worry into debt. If the overdraft is withdrawn then the procedure searches your share holdings one by one (lines 3410-3440) for your largest holding, sells that at a suitable charge and sees if you are still in debt.
3560-4770 These are the details of the disasters and could be changed at will or left out if you did not like them. The only point to register is that they are called from the 'DISASTERS' procedure and the bad disasters recursively call the disasters procedure themselves in case your bad luck can be compounded in some way.
4790-5260 The end of game messages are really at your disposal. My choice is curt and to the point, but as there is about 4k of memory left, you may be fairly effusive if you wish.
5270-5680 Similarly you may change the start messages. The REPEAT (lines 5370-5420) simply generates the double size characters and is quicker than writing everything out twice.
5690-end Apart from typing BREAK, once you are engaged in parameter choosing, you must see it through to the end. The parameters are displayed one by one, and keyboard entry is required exactly as displayed. This removes the need for subsequent validation and guarantees the program cannot crash from choosing strange parameters. They won't get past the keyboard. Thus it is a little tedious, and in general I suggest only an adult does this or produces suitable parameters on a sheet for a student.
Educational Notes
There is no doubt that even played as a straight game, the fourth and fifth years have enjoyed this immensely. Profit and loss, disasters and trading all become quickly apparent. The more interesting aspects lie in planning parameters and playing against them, plotting on graph paper or in note form what you are doing. For example: if you select just two firms and an economic cycle of 6, plot the share values on the graph paper as you sell or buy and see if a cycle becomes evident and how one might predict the onset of another cycle. Try setting a series of different share ranges combined with different share minima, and draw a conclusion as to the combination of events most likely to be profitable. Keep a table of your chosen minima and ranges and final victory totals. Of course you will run into 'disasters' and you can explain the need to produce more than one run of the simulation for better statistical reliability.
I offer a brokerage of 00%, but I felt there always had to be interest charges on bank overdrafts and thus the minimum rate there of 10%. I feel the simulation needs to run for 26 weeks, but you may change this in the initialisation.
Those youngsters who have tried to play against their own freely chosen parameters have been surprised to find out that usually they worsen their overall performance . . . and thus direction here is essential to avoid irritation. Good luck, this game/simulation is very compelling!