Click Here To Go To The Your Computer Archive

Written By John Dawson

Cover Art
Click Here To Enlarge Loading Screen

Loading Screen
Click Here To Enlarge Opening Screen

Opening Screen
Click Here To Enlarge Screenshot

Game Screenshot


John Dawson stops Heartstop here and gives you a chance to win 100 with a look at artificial intelligence and how it works

Computers are capable of the most complex calculations and control operations. And yet the pictures in a child's story book are beyond interpretation by machines. By contrast to the traditional approach in which predefined steps are followed to solve a problem - a Basic program, for example - artificial intelligence work is said to be about "problem solving programs that solve substantial problems generally conceded as being difficult and requiring expertise."

There is a fair amount of confusion about some of the terms used in artificial intelligence - AI - so here are some definitions from a Dictionary of Information Technology:

"Artificial Intelligence. Research and study into methods for the development of systems that can demonstrate some of those attributes associated with human intelligence, e.g. the ability to recognise a variety of patterns from various viewpoints, the ability to form hypotheses from a limited set of information, the ability to select relevant information from a large set and draw conclusions from it.

"Expert systems. In databases, systems containing a database and associated software that enable a user to conduct an apparently intelligent dialogue with the system in a user-oriented language."

Artificial Intelligence

"Heuristic. In problem solving, a trial and error approach involving successive evaluations at each step made in the process of reaching the final result. In contrast, an algorithm represents a consistent approach in arriving at an optimal result."

Alan Turing, one of the first people to work on the theory of computers, devised a test which illustrates practically what is meant by the term "artificial intelligence": Put a person in a room with a teleprinter connected to a remote computer. Allow the person to type questions on to the teleprinter and if he is unable to decide whether or not he is communicating with a person or a machine then the machine exhibits artificial intelligence.

So artificial intelligence consists, chiefly, of representing facts and "rules of thumb" - heuristic search techniques - in a computer and of manipulating them, by a process analogous to human reasoning, in order to achieve specified goals.

Expert systems have to contain three fundamental elements: a knowledge manager - the inference engine, a knowledge base - the 'database' in the definition above, and a situation model. Normally the knowledge manager employs the information in the knowledge base to interpret what is going on at the time in the situation mode. In relation to Heartstop, for example, the knowledge base would contain reference information about:

  • The number of beds in the hospital.
  • The types of medical care that can be given e.g surgery, children's medicine, orthopaedics - surgery on bones, psychiatry, accident and emergency
  • The names and quantities of the drugs kept in the pharmacy
  • How many nurses are necessary to cover each of the wards
  • Procedures to be followed in the event of a major accident, a key member of staff going off sick, fire in the hospital, mains electricity failure and so on.

The situation model might contain changing information on the following lines:

  • How many patients are in the hospital at present?
  • How many operating theatres are ready for use?
  • How many nurses are on duty and on which wards?
  • The drugs currently being prescribed for each patient.

You can see that the knowledge base contains the fixed information that describes the hospital and its capabilities. The more complete the knowledge base can be made, the easier the task of the inference engine becomes.

The situation model has to interact with the outside world, reflecting the current status of the operating theatres, and the level of stagging throughout the hospital.

An alternative approach to the defined knowledge base of the expert rule systems use statistics to predict a probable cause of an event. Thomas Bayne, a fellow of the Royal Society of London, formulated his theorem about the probabilities of events in 1760. Bayes Theorem is used to incorporate information into a decision analysis approach to a problem. The theory can be related to an enormous diversity of problems one of which is medical diagnosis and the refinement of clinical tests.

Suppose that you see a young adult male patient in the Accident and Emergency Department. Before your examination you will have some idea of the probable causes of acute abdominal pain in young adults. If you discover that pain is most severe in the right lower quadrant and that it is made worse by movement, your suspicion that the cause is acute appendictis will be increased.

Your estimate of the probability of the pain being caused by an acute appendicitis has been altered by your tests and observations and this now appears the most likely cause.

The prior probability - the chances of acute appendicitis at the time you were bleeped but before you had examined the patient - has been modified by the event of you performing some clinical tests to give a posterior probability at the end of your examination. Immediately that posterior probably of the patient's condition being due to acute appendictis becomes the prior probability for the next event; along with the other altered probabilities for all the other causes that you considered.

You decide to operate on the young man and successfully remove an enlarged and inflamed appendix. The pathology report confirms your diagnosis and the final posterior probability for this case approaches a certainty that the cause of the pain was due to the diseased appendix.

Tim de Dombal, a surgeon in Leeds, has collected the structured results of thousands of cases of acute abdominal pain through a worldwide network of doctors.

Tim de Dombal uses a newish Commodore microcomputer which sits quietly and unaggressively in one corner of an office. The results of about six thousand cases of acute abdominal pain were entered into a survey and a computer program was developed which would carry out a Bayesian analysis to prepare a set of prior probabilities for the causes of acute abdominal pain in a particular patient. The program is perhaps a couple of hundred lines of Basic in length.

Tim de Dombal has written that: "in the 1476 cases of appendictis, the computer aided prediction matched the final diagnosis in 84 percent. In many centres, the accuracy of match was higher - around 90 percent. This relatively high accuracy of match is less informative about the computer that about acute appendicitis. We concluded that acute appendicitis presents in roughly the same fashion around the world, and is a disease entity which presents in a broadly similar fashion around the world, and is a disease entity which presents in a broadly similar fashion to clinicians in a variety of centres."

Helping With Decisions

However, the paper's conclusions continued "Turning to other diseases, such as acute cholecystitis, perforated peptic ulcer and small bowel obstruction, very similar conclusions emerged. Overall, and in the overwhemling majority of individual centres, there was a high (>80) percent of match between the computer's diagnostic prediction and the actual diagnosis made in the centre concerned."

In this application, a computer is helping doctors to make better decisions about patient care; it is not making the decisions itself.

Heartstop, like most other programs need to record that something has happened, or mark that a particular "thing" is on or off. Flags are used to store the current state of the "thing". A flag is a programming device that can be set on or off - the flag is up or down, it's not allowed to be at half mast. In Slagthorpe Memorial Hospital, for example, you may want to record whether or not a patient has had an ECG examination, or mark the patient's notes to show that the patient has died or been discharged home.

The patient summary can then be made to print only those patients known to be in the hospital, while retaining the whole list of patients who have been "treated" during the weekend in order that it can be printed at the end of the game.

One way of creating flags in Basic is to use an integer variable, or an integer array, to hold the numbers one or zero, representing the flag's on or off state. As each integer variable takes up four bytes that is a pretty inefficient method. The ideal answer is to use machine code where a single bit can be turned on and off, allowing you to store eight flags in a single byte. The Z80 cpu is better equipped than the 6502 for this sort of 'bit-twiddling'.

The 6502 cpu in the BBC machine can only test the most significant bit in a byte, although the problem can be overcome very easily by rotating the bits until the one you wish to operate on is at the most significant position. However, while the BBC Micro has a super built-in assembler, it is a lot of bother to drop into it just for this purpose.

Figure 1 is a test program that shows another way of storing and using flags that takes up only one byte for each flag and gives you additional information about when the flag was set in relation to other flags.

The INSTR instruction - page 280 BBC Microcomputer User Guide - searches one string for the occurrence of another. You can use a single letter to represent a Flag-On condition and the absence of that letter to represent the Flag-Off condition. There is a small space penalty in setting up the string in the first place but after that each additional flag occupies just one byte.

The 36 alphanumeric characters 0 to 9 and A to Z can be used as unique identifiers. Setting a flag is easy - lines 170 to 220. The test program includes a procedure - PROCinputflag - to get the flag you wish to set from the keyboard. If you wish to use these routines in another program just delete the PROCinputflag lines, and add the parameter - FL$ - on to the definition of the two procedures - lines 170 and 350. Calling PROCsetflag(B) will then add "B" to the existing FLAG$ string. The condition of a flag can be tested by PROCtestflag(FL$). PROCtest is included simply to show the result of the test on screen.

INSTR returns a value of zero if the substring FL$ is not found in the main string. Note that both Flag$ and Position% are global variables and these are used in the next procedure - PROCresetflag - and to reset a flag to the Off stage.

The collection of flags in Flag$ is split into two on either side of the flag found in PROCtestflag and then recombined. The flag identified in FL$ is no longer present in Flag$ and has been reset. Because a flag is always added to the end of the string when it is turned on the time sequence in which events take place can be determined by finding the position of each flag in Flag$ using the INSTR instruction.