178

WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

  • Upload
    letram

  • View
    226

  • Download
    2

Embed Size (px)

Citation preview

Page 1: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new
Page 2: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

WRITING

ADVENTURE GAMESON THE AMSTRAD

Page 3: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new
Page 4: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

WRITING

ADVENTURE GAMES

ON THE AMSTRAD

Mike Lewis ond Simon Price

MELBOTIN,NE HOUSEPTIBLISHER,S

Page 5: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

O1985 Mike Lewis & Simon Price

All rights reserved. This book is copyright and no part may be copiedor stored by electromagnetic, electronic, photographic, mechanical orany other means whatsoever except as provided by national law. Allenquiries should be addressed to the publishers:

IN THE UNITED KINGDOM _Melbourne House (Publishers) LtdCastle Yard HouseCastle YardRichmond, TW10 6TF

IN AUSTRALIA _Melbourne House (Australia) Pty Ltd2nd Floor, 70 Park StreetSouth Melbourne, Victoria 3205

tsBN 0 86161 196 I

Printed and bound in Great Britain byMackays of Chatham Ltd, Chatham, Kent

EdilionPrinting:Year:

7654321FEDC8A98765432190 89 88 87 86 85

Page 6: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

AKNOWLEDGEMENTS

To Andy Tyson and Doug Walker for playtestingTo Lesley Boxer for the artwork

and Tim Harrison - the "Printer Driver".

Page 7: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new
Page 8: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

CONTENTSSECTION ONE - ADVENTURE GAMES 1

J77

Chapter 1

Chapter 2Chapter 3Chapter 4

Chapter 5

rNTRODUCTrON.............HISTORY OF ADVENTURE GAMES......PLOTTING AN ADVENTURE GAME......THE STRUCTURAL ELEMENTS OF ANADVENTURE GAMESAVING SPACE

SECTION TWO _ THE ADVENTURE KERNEL . .

Chapter 6 WHAT lS AKS?Chapter 7 ACTIONS lN AKSChapter B TRIGGERS lN AKSChapter I LOCATIONS, OBJECTS AND EVENTS

IN AKSChapter 10 EXPRESSIONS lN AKS

Chapter 15 WITCH HUNT PLOTAND DESIGNChapter 16 BREAKDOWN OF WITCH HUNT..

Appendix A LISTING OF AKS AND WITCH HUNTAKS Chexsum ................

5963

2537

45

475'l55

9.1

97

131155

SECTION THREE - IMPLEMENTING AKS ON THE AMSTRAD . 67

Chapter 11 PROGRAMMING TECHNIQUEChapter 12 STRUCTURAL OVERVIEW OF AKSChapter 13 IMPLEMENTING THE EXPRESSION EVALUATORChapter 14 EXTENDING AKS.....

SECTION FOUR - WITCH HUNT _ AN EXAMPLE SCENARIO . 89

697379B5

Appendix B BIBLIOGRAPHY 165

Page 9: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new
Page 10: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

sEcTrolr 1ADVENTURE GAMES

1

Page 11: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

¿

Page 12: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

1INTRODUCTTON

The arcade shoot-'em-up style of computer games is the one mostassociated with home computers. They are games of skill, involvingfast reflexes and goo<j hand{o-eye coordination. While there are someelements of strategy in arcade games, it is more along the lines of"which baddy do I shoot first?" than any complex planning. These aregames of action; adventure games are games of thought, of planning,of strategy. Fast reactions will not help you in a standard adventuregame - you must use your brain, not your joystick.

There are many different forms of adventure game, as we shall seein the next chapter, but they can all be considered to ultimately be thesame type of game. They are all linked at the basic level by a gameformat which involves the player interacting with the computer in orderto solve puzzles, collect objects, and perhaps kill monsters. The playertakes the part of a character, who is free to roam around an imaginaryworld, within his computer, and whose actions are controlled by theplayer through the computer. The best adventure games give you theopportunity to get lost in their worlds, to take on roles which allow youto escape from mundane, ordinary life and become an adventurer, anexplorer. Adventure games can give you the same feeling of enjoymentand involvement which is available from a well-constructed, well-pacednovel; or from a well-run roleplaying game session. Of course, not alladventure games are good, far from it, many lack atmosphere, ideasor even a vaguely logical plot. They can reduce the whole adventureplaying process to a simple game of guessing which word to use,which object to pick up, etc rather than an exploration of the author'sworld. Playing a poorly designed adventure game is mechanical atbest, if you even bother to play it, that is.

3

Page 13: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

WHY READ THIS BOOK?With the growth in popularity of adventure games, and the realisationby computer games companies that a good adventure game can sellas well as a good arcade game, there has been a boom in the numberof adventures being produced. There has also been a comparativeboom in utilities such as The Quill, which allows you to write your ownadventures without knowing any programming techniques. This hasled to a lot of Quilled adventures, some of which are very good - alot of which are quite dire. There seems to be a similar expression to"Everyone has at least orìe novel in them" - with computers, everyoneseems to have at least one adventure in them. These utilities allowthem to produce their one (or even more) adventures.

There has also been a boom in adventure game books, which purportto show you how to write an adventure game easily and simply. Un-fortunately, beyond giving you some form of programming knowledge,which can be picked up by typing in listings, these books have verylittle to offer. The standard format is to show how to write one adventuregame, which is produced by directly coding the adventure in the formof BASIC, and to then claim that this will enable you to write your ownadventures. Sadly, it doesn't do this at all; because of the adventureformat chosen. The adventures presented as examples are directlycoded programs which only apply to their adventure game alone; ifyou wish to write your own adventure, you have to code your game inthe same way, from scratch. What is more, you will have to code eachadventure game you write subsequently, in the same way, program-ming it directly. Far from allowing you to write adventures easily andquickly, this technique wastes a lot of your time, and produces fairlystandard adventures, as well as teach¡ng you very little.

That is the conclusion which we came to, after tiring of reading thesame material time and again in adventure game books and articles.There are so many computing techniques and methods which can beapplied to adventure games, and they seem to remain the secrets oflarge software houses. Well, this book sets out to outline some of thetechniques which you can employ to write your own adventures, someof them fairly advanced; techniques which will actually teach you some-thing new about computing. We have also set out to provide a completeadventure generating system which can be used to design any numberof adventure games, without direct coding, or any programming beingnecessary. The Adventure Kernel System is easier to modify and moreflexible to use than most commercial adventure designers as well, asit enables you to see the structure of your adventure game, in a waywhich mehu systems cannot.

4

Page 14: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

WHY WRITE ADVENTURE GAMES?You may be wondering why anyone would want to write their ownadventure games. The simple, and short, answer is for enjoyment anda feeling of satisfaction. A large adventure game is very similar to anovel, in the way it must be designed, plotted and finally written; andthere is the same feeling of achievement when you finally finish anadventure as you get from writing a book. Designing and implementingadventure games is fun, as well. Your imagination has complete free-dom to produce whatever strange ideas and puzzles you want, andyou are able to stamp your own personality and feelings on an ad-venture game in a way which is not possible with an arcade game.There is also the enjoyment which can be had from watching otherpeople play your adventure game, trying to puzzle through all thoseproblems you carefully designed. ln fact, it is often more fun watchingpeople play your game than playing other peoples' adventures - aninside view gives you a wonderful perspective on the player's actions.

Besides the enjoyment derived from writing an adventure game, youcan learn new programming techniques, something which isn't possiblewith a novell An adventure game is easier to construct and write thana novel, as well, which may be why so many adventure games writersappear to be frustrated novelistsl lf you are creative and as much ofa technophile as we ai'e, it also gives a chance to do something usefuland constructive using your treasured computer for a change. Nolonger will people be able to say that you are wastrng your time playingsilly games - you are creating them insteadl

5

Page 15: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

I

Page 16: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

2THE HISTORY OFADVENTUREGAMES

THE DEVELOPMENT OF ROLEPLAYINGRoleplaying games grew out of the hobby of wargaming in the latesixties and early seventies. Wargames take the form of battles foughton table tops with miniature figures. Each figure represents ten, twentyor more men and the gamers move the armies according to a complexseries of rules which govern movement, terrain, and the like - withcombat being resolved through the use of dice; wargames recreatemany different periods of warfare, from ancient Rome through Napo-leonic battles to the conflicts of the 2Øth century. Wargames themselvesdeveloped from chess and the military strategic games played by thePrussian Military Command at the end of the 19th century.

The first factor which influenced the development of RoleplayingGames, (RPGs as they are known today) was without doubt the pub-lishing of JRR Tolkein's LORD OF THE RINGS in paperback in 1967.This fired the imagination of a vast audience of young people, the ideaof recreating the battles between men, dwarves, elves and orcs ap-pealing to the fantasy fan and wargamer alike. Because of the demandfor rules which could cope with the magic and creatures depicted inthe books, the publishers of medieval wargames rulebooks had ap-pendices added to include the use of fantasy elements such as DragonFire and magic swords.

ln Lake Geneva, Wisconsin, USA a small group of wargamers pub-lished a book for medieval combat called Chainmail through GaryGygax's small press games company Tactical Studies Rules, which

7

Page 17: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

had previously published other wargames rUles. While this essentiallycovered the medieval period, it also had a large fantasy element, withgiants, spells, trolls and dragons. The game was reasonably populardue to these added fantasy elements.

From here, the game grew with Dave Arneson - a member of thegroup - creating a dungeon beneath the castle in his campaign. Hereindividual characters adventured, governed by the rules in CHAIN-MAIL. The new concept of playing a unique character proved verypopular and this idea was developed by Arneson and Gygax into thegame Dungeons and Dragons (D&D)which was published by Gygax'sTactical Studies Rules company.

D&D sold extremely well and vast numbers of supplements weresoon added to the game to cover the inconsistencies present and theproblems that 'combat according to the rules in CHAINMAIL' (as theoriginal rules stipulated) caused.

While the game of D&D was the first, it was obviously incompleteand in many ways had flaws as a games system. There were a numberof individuals around who felt that they could do better and soon severalrival roleplaying games sprung up. These were games such as Tunnelsand Trolls, a very simple level game developed by Ken St. Andre, andpublished by Flying Buffalo with different rules for magic and combatbut still drawing on the fantasy background of elves, dwarves and trollsas inspiration for adventures.

THE GROWTH OF ADVENTURE GAMESBack in the dim and distant days of '1973, when roleplaying gameswere first invented, computers were still immense mainframes fillingrooms, and while computer games did exist they consisted of Noughtsand Crosses and games like Star Trek. While many computer pro-grammers played D&D, they never thought of implementing the gameon a computer system. Roleplaying and computers remained veryseparate entities until two bright students by the names of Crowtherand Woods created ADVENTURE.

The game ADVENTURE was created on one of these large main-frames and coded entirely in FORTRAN and Crowther and Woods wereclearly D&D fans, for ADVENTURE contains many of the elements foundin roleplaying games. lt is set in a vast underground complex of caveswhich are populated with monsters to be fought, puzzles to solve andtreasure to win. The player moves his 'character'around the caves bygiving two word instructions describing his actions. ïhese consist ofa verb and a noun pair such as'GO NORTH', 'KILL DWARF', etc. Thushe is able to manipulate objects, attack monsters and solve puzzlesvia simple commands. The game was tremendously innovative at thetime, and doubtless many hours of hideously expensive computer time

8

Page 18: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

were spent trying to unravel its mysteries. The player receives a scoreout of 35Ø when he dies and the aim of the adventure is to win bycompleting all the actions possible and to thus score 35Ø.

ADVENTURE remained unavailable to all but a select few due to thescarcity of mainframe facilities to those other than students or com-puting specialists. The game might have remained a minor diversionfor computer scientists, but for one person - Scott Adams. Scott hadplayed the game at work, and had found it fascinating, he wanted tobe able to show it to his friends, but couldn't take them into work. So,the obvious solution was to bring the adventure to them! This he didby programming the game in BASIC on the 16K TRS-80 Model 1 , despitehis colleaguest assurances that it couldn't be done!

Once it had been shown that you could reproduce an adventuregame on a microcomputer in just .16k (the original adventure used over64k of main store) other programmers cauglrt on, and soon other ad-ventures began to appear.

Adventure games consisted of the same basic elements: the twoword input, puzzle solving and limited character interaction until rela-tively recently, when the lnfocom games appeared. These grew outof experiments with a parsing system, and as such allow very complexinput and output. Zork was the first of the new breed of games, andit provides a surprisingly user-friendly game with some very intricateand subtle puzzles.

Unfortunately, due to the large amounts of memory and disk spacerequired to run ZORK it is only implemented on a few machines. How-ever, some of the techniques shown in ZORK can be reproduced inany adventure games system extremely effectively and easily.

Nowadays, adventure games are a very common piece of computersoftware, and there are several different types available on all of thesmall home computers, the Amstrad having its fair share of innovativeadventures.

While all adventure games have essentially the same structure -in that they are composed of an interaction between the player andthe game, during which the player attempts to solve puzzles and over-come obstacles - they can be sub-divided. These divisions can bebased on the style of input and output and how these two are linkedthrough the game.

DIFFERENT ADVENTURE TYPES

Text AdventuresThis is the original type of adventure game, and the text adventuresavailable on the Amstrad differ very little in format from the originalADVENTURE on a mainframe computer. The game consists of plain

9

Page 19: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

text input and output on a normal screen with no graphics, sound andnormally no use of colour.

The original Crowther and Woods Adventure is available on the Am-strad as Colossal Caves from Level 9, which not only includes theoriginal 2ØØ locafions, but adds 7Ø more! Quite a programming featfor just a small home computer!

The game includes all the elements of the original and more. You

start the game on a road near a building, with a forest to the north anda valley to the south. Commands are entered by typing in a two wordcommand consisting of a verb and a noun. Thus, "Enter building" willtake you into the building, where the program describes the locationAS:

You are in a small building with a well in the middle of the onlyroom. A rusty ladder leads down the well into darkness.There is a bunch of keys here.There is a small brass lamp here.There is an empty bottle here.

Typing "Get Lamp" will enable you to pick up the lamp and typing"lnventory" will list all the objects you are carrytng. The adventurerecognises the standard abbreviations for directions, such as "S" for"South", "D" for "Down", "E" for "East" and so on. The two word inputis limited compared to some games that allow full sentence input, butit is sufficient to play the game (and indeed to play most adventures).

Graphics AdventuresText adventures with added pictures showing what the locations lookedlike have been around for a while on computers such as the Apple

- the use of discs enabling fast access to picture data. The graphicsadventure boom on small computers, however, was really sparked offby the release of The Hobbit adventure lrom Melbourne House. Thisled to a lot of other graphics adventures, which attempt to add at-mosphere to the game by showing each of the locations you can visitin glowing colour.

The major problem with any graphics adventure is that the additionof graphics to the program eats up the available memory at a ferociousrate! This means that there is less space for locations, objects andactions, and thus the adventure has to be smaller with fewer puzzlesand they generally prove to be less of a challenge. While the graphicsdo add a certain feeling of atmosphere to the game, they can neverbe detailed enough to accurately represent your location, and thusadd little to the adventure element of the game. Most "committed"adventure games players tend to prefer text based games, as theyoffer a greater challenge.

10

Page 20: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Arcade AdventuresThls type of adventure game bears the least resemblance to the originalADVENTURE, as it is entirely graphical in naiure, with very little (if any)text The character in the game is controlled by a joystick, or via cursorkeys, and is moved around the screen collecting objects and fightingmonsters. The screen generally depjcts a set of corridors ot a maze,which must be negotiated, and the monsters are overcome by firingat them - as in arcade games.

Because the action is purely graphical and the standard of animationof the characters in the game has to be high, the graphics will take upeven more memory than with the Graphical Adventures. Thus, theactual adventure element of the game tends to be reduced to justpicking up or dropping objects, fighting monsters and so on. Allthingswhich require skill on the joystick and good reflexes rather than thecomplex thought and calculation required by the traditional puzzleadventure. However, Arcade adventures may appeal to people wholike a little more storyline to their blasting of aliens than in the standardshoot'em up.

Adventure SimulationsAlthough The Hobbit falls into this category in many ways, with itsinteractive characters and their unpredictable behaviour, as do thelnfocom games, the only real program to live up to the name is Valhallafrom Legend (sadly, only available on the Spectrum and Commodore64 at the time of writing.).

The world of Valhalla is that of Norse legend and myth, with the godsand goddesses, giants and dwarves, wolves and dragons. You takethe part of a character in this world and you interact with the othercharacters present. Each of these characters has a unique personalityand acts with complete independence from you or the other charactersaround them. The thing that makes Valhalla very different from TheHobbit or any other game available is that all this action takes placegraphically on the screen. When you type in the command "DrinkWine", one of the little characters on the screen will raise a wine bottleto his lips and take a drink!

Each location is shown as a fairly detailed and colourful picture, withthe terrain varying from plains to marsh or forest, and with castles andhuts dominating the skyline. The characters are shown as little figureswho walk about the central strip of the screen, drop food, pick upweapons, fight, etc, All this while you can stand and watch.

ln fact, one of the fascinations when you start to play the game isjust to sit and watch the other 36 characters in the game interact withone another while you don't do a thing! You can join in this worldthrough a fairly complex sentence input which enables you to ask the

11

Page 21: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

other characters for things, ask them to do things and move aroundthe world.

Due to the graphics again, the adventure element is rather limitedbecause of the sheer complexity of handling the animation and in-dependence of the characters. You are really limited to just eating/drinking ( a vital necessity to avoid dying of hunger), buying/selling,fighting and handling objects. The commands for such actions can bevery complex in structure though, such as: "Sell the axe to Thor for 3Ø

crowns".The purpose of the game is to find the six magical items scattered

throughout the world, which must be collected in order. To achieve thisyou will need the help of the other characters and this can only begained by impressing them with your prowess at fighting etc.

Quite clearly, the adventures currently available on home computersare a massive improvement over the original Adventure, both in termsof complexity and playability, while still owing their format to the originalgame.

MACHINE REOUIREMENTS ANDPROGRAMMING LANGUAGESThe resources required by an adventure game really depend on thetype of game (as classified above) and on the aims of the game. Alladventure games require a reasonable size of computer memory andthey can be greatly enhanced if some form of disk storage is available.

ldeally an adventure game should have at least 4BK available forthe data and the driving routines. lt is possible to get away with lessthan this, especially if some form of text compression is used, but theadventure game which can be fitted into a 16K machine pales intoinsignificance beside a 4BK game! When available memory is limited,you are forced into using compression techniques and machine code,to create a useable adventure. This distracts you from the game itself,as far more time is devoted to perfecting coding techniques than de-veloping the adventure game. There is a lot to be said for using a high-level language rather than machine code, and getting on with the gameitself.

Which high-level language is most suitable for writing adventuregames? Well, the major task which an adventure game performs is themanipulation of large amounts of text, usually in the form of strings; soany language which provides good string handling functions can beused. The original ADVENTURE was written in FORTRAN, simply be-cause that was the only language available, however it is really de-signed for scientific number crunching, not for text manipulation. Themost commonly used language for writing adventure games on micro-

12

Page 22: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

computers is, of course, BASIC, Most BASICs have good string hand-ling, it is a relatively simple language to learn to program in, and it iswidely available, all good reasons for using it.

The major problem with using BASIC is that the larger the program,the slower it will run. For most adventure games this is not too muchof a problem, as the response times to the player's input are still fastenough to be acceptable. The response delay only becomes a realproblem when you are attempting to produce a more advanced ad-venture game, which will allow complex sentence input. The parsingof sentences takes time, and the delays can easily become totallyunacceptable. No player wants to wait thirty seconds between inputtinga command and the program responding ! Thus, as the games becomemore ambitious and complex, you are forced to abandon BASIC infavour of machine code, or a compiled language.

As we have already mentioned, resorting to machine code will slowdown the development of the adventure game by a significant factor.Machine code takes longer to learn initially, as it requires a totallydifferent programming approach to a high-level language, and this canput the development of an adventure game even further back. Onceyou have written your adventure game in machine code on onemachine, you are then faced with the problems of implementing thesame game on a different machine. With a BASIC adventure game,transferring the game to a new machine is simply a matter of translatingthe program into the new dialect of the BASIC. Despite the lack ofstandards in BASIC, this is a fairly straight forward task, and it willcertainly take you far less time than rewriting the game from scratchon the new machine. lf your game is written in machine code, then thisis exactly what you will have to do - rewrite the whole game! Evenassuming that the new machine uses the same machine language.(e.9. both the Amstrad and the Spectrum useZBØ machine code), youcannot simply copy the program across. The routines for printing outtext to the screen, inputting commands from the keyboard, drawingpictures, all the things BASIC does for you, will have to be completelyrewritten.

BASIC has the advantages of making your adventure game portable,so it can run on another machine with minimal changes, yet it is notthe only language you can use. We mentioned compiled languages,and PASCAL is such a language, which is becoming widely availableon a lot of micros - the Amstrad included - for a relatively smallprice. The advantages of compiling a language are that you can writethe game in a high-level language which is as easy to use as BASIC,yet it will run at almost the speed of machine codel Unfortunately,standard PASCAL is not very suitable for adventure games program-ming, as it lacks even elementary string handling functions, makingtext manipulation a difficult and complex problem. Fortunately, the

13

Page 23: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

people developing the new micro-based versions of PASCAL haverealised that the language does have some severe limitations, and theyhave taken steps to overcome them. The most common addition to thelanguage, and the one feature we really need, is string handling, soyou can manipulate text in the same way as BASIC.

lf you write your adventure game in PASCAL, implementing it on anew machine is simply a case of putting the same program on the newmachine and then compiling it, using that machine's version of PASCAL.Your adventure is then ready to run, without any alteration! There aredisadvantages to using a compiled language like PASCAL, as it is notas fast as machine code, and the compiled code is not as compactas machine code; but these are outweighted by the ease of use, theportability, and the fast development time.

The other problem, of course, is being able to afford a PASCALcompilerl While they are becoming more widely available, not everyonecan afford to buy one, and thus we will stick with BASIC in this book

- every Amstrad has BASIC built into itl

THE FUTURE OF ADVENTURE GAMESAs all of computer technology and computer games are constantly

developing, so is the adventure games genre. There are always newideas to be tried and new complexities of programming to be reached.The future of adventure gaming looks very healthy, with a wealth ofnew technology and knowledge to draw on.

We have already seen the use of video disks in the computer gamesfield with arcade games such as M.A.C.H. 3 and the adventure gameDragon's Lair (DL). ln these games, the computer projects images fromthe video-disk which correspond to the players actions. Thus, inDragon's Lair, you control Dirk the Daring, a fearless fighter, and allthe action is shown on screen in the form of an animated cartoon.Unfortunately, games such as DL bear little resemblance to the ad-venture games we know, because the action is so limited. The computercannot access frames continuously from the disk, in response to theplayers actions, and thus the game comprises of a number of scenes,which are "jumped" between. ln DL the player moves Left, Right orwaves his sword at the appropriate point. There is very little interaction.

However, the technology is coming here, and it should soon bepossible to have a fully interactive use of Video. The adventure wouldnow take the form of a live "film" in which the player takes an activepart. The characters in the film will respond to you, and the characterrepresenting you will act out the actions you dictate. Thus it will be likeValhalla in some ways, but far more realistic and with the storagecapacities of Video Disk, the true adventure element can be preserved.

14

Page 24: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Developments in the field of Artificial lntelligence research will alsohave a great effect on future adventure games. There is not only theconcept of using the logic and knowledge processing techniques thathave appeared in games such as Sherlock from Melbourne House andthe lnfocom games, where the other characters in the game appearto be intelligent, and thus you can order them around, hold conver-sations with them, etc. There is also the work in the field of naturallanguage processing which has obvious applications to adventuring.One of the most frustrating aspects of playing an adventure game isthe limited vocabulary available to you, and the problems often en-countered when trying to find just the right word for a desired action.However, if you could type your commands into the computer in yournatural language, in English, there would be no problem;you are freedfrom the restraints of an artificial language and able to concentrate onthe adventure and absorb its atmosphere, without distraction.

Typing in commands is always a problem, especially when you wantto use a long sentence and are a poor typist. Here, Artificial lntelligenceresearch can help as well, in the field of Speech recognition. A trulyinteractive film could be produced if you were able to physically speakto the characters in the game, and to hold a spoken conversation withthem!

Multi-user adventures are already starting to appear with the mostfamous of these being MUD, which is run on a small minicomputer.The acronym standing for Multi-User-Dungeon. MUD enables theplayer to not only enter a large, and complex adventure world, but todo this in the company of other players! Thus, the characters you meetwhile playing the game will not obey simple rules devised by the pro-grammer - these characters have exactly the same potential for un-expected behaviour as you do as their controllers are human. WhileMUD is a fairly limited adventure game, bigger and better versions arealready being worked upon with hundreds of locations, objects andplayersl ïhe concept of multi-user games, either on large mainframes,where the players take part via a modem and a phone line, or via alarge multi-user local network system, each player using one systemterminal, offers almost infinite possibilities for expanding the presentday adventure game and increasing the realism.

Fairly obviously, most of these ideas are a long way from becomingreality, yet they do show that there are many areas of computing whichcan be applied to adventure games and adventure game program-ming; areas which are on the forefront on computing research. Con-sidering the growth of computing and computing techniques over justthe last ten years, they could be here sooner than you think.

15

Page 25: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

9t

Page 26: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

3PLOTTING ANADVENTURE

THE IMPORTANCE OF A GOOD PLOTWhen first confronted by a new adventure game what is it that attractsa player? ls it the style of presentation, the colour the text is printedin or even the packaging? Most adventures on the computer marketbear a very close resemblance to each other, especially with textadventures; there is only so much you can do with plain text outputand input. Packaging may affect a buyer's choice, but it cannot hidea terrible adventure game beneath it.

When you cons¡der any adventure game and the intitial appeal it hasto a player, indeed the whole appeal of playing it - you realise thereis one over-riding factor. The plot. Above everything else the adventuregame must have a good plot. The plot idea is the game, all else is justtrimmings to improve presentation rather than contents. Yet, it isn'tenough to just have a good plot, even a well thought out plot withmultitudes of twists and turns can bore a player very quickly - if he'sseen it all before.

The plot is the very heart of your adventure and as such should bestrong and well-defined. The best adventure games have plots whichlead the player in stages through the game, until the eventual climax.lf the plot meanders along, the player is going to be left wonderingwhat he is supposed to be doing, and is going to lose interest in thewhole thing. There must always be a firm goal in the player's mind asto what the adventure game is about, and what he is trying to achieve

- of course, he may find out that he is totally wrong I But that is justone possible twist in the adventure.

The plot of an adventure game is composed of two elements, theactions and puzzles which make up the plotline and the backgroundto the adventure - the setting in which everything takes place. We'll

't7

Page 27: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

look at the background in a moment, but for now let's consider thebasic elements of an adventure game plot.

(a) The Map

This is the very lowest basis of any adventure game and it will showthe area over which the player can move and where all the action takesplace. While it may seem that the map in an adventure game is reallyonly a list of locations and theirconnections which has no direct bearingon the plot, this really is not true. As the map is the basis of youradventure game so it is the basis of your plot, and a good, well thoughtout map can improve an adventure immensely.

The basic map will contain all the locations necessary for the actionin your game to take place, each location might be used for an object,or an action to take place or even just as a red herring. The problemwhen designing an adventure game is deciding on how detailed themap should be - should you describe each room in a house, or simplyhave one location representing the whole house? Should you representa road on your map as a series of (similar) locations, or just ignore itwith the player moving from one end of the road to the other in oneturn?

These difficulties can only be overcome by considering just howimportant each of these locations is in your game, and how each relatesto the main plot and purpose of your game. lf the only part the houseplays in your game is to provide somewhere for a knife to be found,then why bother with more than one location - or perhaps two witha kitchen? The extra rooms in the house serve no useful purpose andwill either bore the player or side track him from the main part of thegame if he tries to find out what use they are. ln any adventure gamethe number of irrelevant locations should be kept to a minimum -youdo need them to keep the atmosphere of the game flowing properly.lf your player is on foot, making locations long distances apart will onlymake the game seem unrealistic - either provide him with a meansof transport or separate the locations with intermediate ones.

Making your locations and their descriptions interesting is an im-portant part of the adventure writing process. Think about the back-ground and basis for your game and come up with locations whichmatch the atmosphere and style of your game. A mystery/horror ad-venture is best set in a spine-chilling mansion, not in the centre of town !

Location descriptions should be long and evocative as well, two linerslike "You are in the hall near the stairs and the kitchen" hardly conveya rich atmosphere.

(b) The objectsMany of the points already raised about locations apply equally wellto objects. Try to avoid having too many objects in a game which are

1B

Page 28: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

not useful. Just because a kitchen usually has pots and pans in itdoesn't mean you have to provide them if there is no use for them. Theobjects and locations should tie together in some way, without ap-pearing too contrived, and without the objects seeming out of place.

(c) PuzzlesThese are the major component of an adventure game and are whatmake the game a challenge to play. Poorly thought out puzzles canmake a game far too easy to solve and thus bore the player or makethe game impossible to complete, thus frustrating the player. The trickis to balance your puzzles somewhere between the two extremes,something which is not easy to dol

lf you have difficultythinking up puzzles of your own, then it is possibleto adapt puzzles from other adventure games and disguise them byaltering their circumstances and the objects used to solve them. Forinstance, in the originalADVENTURE, you must capture a bird in orderto get past a large green snake. When you approach the snake, re-leasing the bird causes it to drive the snake away. ln other games thishas been translated inio throwing Egyptian bird statues at a snake godwhile exploring a pyramid, and so on! Disguising apuzzle is not alwayseasy and you cannot really rely on other adventure games for all yourpuzzles!

Apuzzle should be both logicaland yet hard to see unless you strikeon the correct sequence of events. There is nothing more infuriatingin an adventure than totally illogical puzzles which have no basis onany reality for their ideas. There must always be some way of solvinga puzzle other than wildly guessing which objects to use and in whichorder and in which room! Because of this, it is important to try out yourpuzzle ideas on other people, just to see that you haven't made alogical jump from the solution to the problem which is impossible tomake in the correct order. Not everyone will think in the same way asyou, in fact very few people might have your knowledge about particularsituations and events, so rnake puzzles fairly general. A solution whichinvolves knowing a complex mathematical formula and how to applyit is not going to be solvable by most people unless you give a lot ofclues!

BACKGROUNDThe major pitfall that new adventure game designers (and severalexperienced ones) fall into is the reliance on the same old standardplot lines for their adventures. Game after game allows you to take therole of a heroic fighter whose mission is to save someone, or thing,from a horde of monsters. Just cast your mind over the games youhave played or seen which are based on quasilantasy lands populated

19

Page 29: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

with Orcs, Trolls, Dwarves and Wizards - all eager to get at yourtreasure. A lot of them, aren't there? All these games draw on the samebackground, that of the fantasy roleplaying games such as Dungeonsand Dragons. Even the original ADVENTURE took this as an influence,and other programmers have been doing it ever since!

So, the first aim behind any adventure game we design is that theplot should attract the player into wanting to play the game, and avoidgiving him a feeling of deja vu as he reads the instructions! This meansconstructing an original and thought provoking plot by using an un-

conventional background for our game or by using a standard plot ina new and unusual way. What we must not do is fall back on the sameold ideas culled from the adventure games that we've seen - thereis no point in recreating some one else's game and ideas!

lf the fantasy genre is out, what can be used as a basis for theadventure plot? The answer is everything else really! There are so manysources for adventure game ideas that it would be impossible to evenbegin to list them all! The following are a few areas that are worthconsidering:

HistoricalThere are a large number of periods in history which could be drawn

upon in a successful and entertaining adventure game. The majorproblems with using a historical period as the basis for your plot is thatof accuracy. You must stick to the period in detail, and avoid anyinconsistencies which a player might pick up, thus ruining the game.For example, you cannot introduce modes of transport such as carsor trains before the period they were available.

There is also the problem of recreating the atmosphere of the period,so that the player feels as though they actually are playing a game setin Victorian England, or wherever, rather than just a standard adventurewith a few oddities thrown in. The secret here is to use the small detailsfrom the period to reinforce the feeling and mood of the adventure, forexample, the music from the period overheard in the street, details ofpeople's clothing, perhaps even the styles of characters' speech canall add to the adventure's atmosphere.

Some periods are obviously more suitable than others for an ad-venture game, as there is more happening, or a more interesting back-ground for the adventure to take place against. Possibly the playerðould take part in an historical occasion, where only their actions enablehistory to come out as it should have done. Or perhaps they can alterhistory, playing the part of a famous historical figure.

It is far harder to write a consistent and believable historical adventuregame than almost any other type, because of the little details neededt,o create the atmosphere, but it is, or can be, one of the most rewardingto write and play.

20

Page 30: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

FictionalBasing the plot for your adventure game on a book may seem a very

good idea - your plot has been written for you! All you have to do istranslate the book into an adventure - far simpler than creating a plotfrom scratch. lndeed, there are a lot of books which would make quiteexcellent adventure games and some have been used (for exampleThe Hobbit) as adventure games already.

The major problem with this approach is if your player has alreadyread the book when he comes to play your adventure. lf the adventurebears any resemblance to the book, it is going to be relatively easyto solve the adventure as all the actions and their correct sequence,are already known. lf the book and adventure are different in contentand style it may make the game more of a challenge, but you are goingto lose the atmosphere of the book, which the player will be expecting.

A better approach is to base the adventure on the style and feel ofone of your favourite books, but without the exact plotline. This makesthe atmosphere of the game easier to put across and the game easierto write - if you are happy with your game and enjoy the book, youwill find it easier to recreate that atmosphere than with an unknownsubject. Pick perhaps the best and most amusing bits from the bookand include these if you wish, slightly altered so that a reader will pickup the reference without making the game too easy for him.

There are also the mercenary advantages of not basing your ad-venture game directly on a book - if it should prove to be a saleableproduct, you will need permission from the book's author/publishersto use it. This means paying them a royalty and less money for youllf you are writing adventures purely for fun, however, this won't reallybother you.

Modern DayThere seem to be very few adventures based on modern day situationsas most people prefer to escape from the present not experience it ontheir computersl For the adventure writer, though, the idea of settingan adventure in the present is not only a challenge, it may prove to beeasier to write than you think. The advantages of such a plot is that theplayer can be assumed to be familiar with the situation he finds himselfin which makes the explanation and background work you have to putinto the game so much easier and shorter!

While there may not seem much you can do with an adventure gamebased on today, there is a whole world of excitement going on aroundyou! We are not suggesting that the adventure should be based ontravelling to work, etc - no one wants to play through the humdrumthings of everyday life. What about foiling terrorist plots, freeing kid-napped people, etc? There is still plenty of scope to create novel and

21

Page 31: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

interesting plots even with the limitations of an up{o-date and modernsetting.

SUPPORT MATERIAL

Adventure games can never create a complete atmosphere whichholds the attention of the player, and totally suspends his belief, be-cause of their limited format. Any graphical adventure game will be letdown by the limited graphics available on home computers. This iswhere adventures can be improved through the provision of additional,non-computer based material.

Rather than waste vast amounts of memory on computer graphicswhich generally fail to convey any real atmosphere, why not providea separate set of pictures tied in to each location. This idea has beenused by several commercial adventures, and enables the adventuregame to be more complex and absorbing by utilising the extra space,as well as improving the quality of the art enough to allow extra cluesto be hidden in the picture information.

Another idea is to provide a map with the adventure game showingthe general area in which the adventure game takes place. This enablesthe player to move around the area he is supposed to know, thusmaking the game more realistic, while not giving away just which lo-cations appear in the actual adventure game, or how they are con-nected. A separately produced map can be made far easier to readand more attractive than any produced on the computer screen. lt isalso far more practical if the player has to refer to the map while heis playing!

There is no reason why you should limit the support material providedwith a game to just the graphical elements from an adventure. lf theplayer starts with a number of items in his pocket then provide actualphysical counterparts for these items! You have to take a practicalapproach to this of course, but such things as bus tickets, cinemapasses, small fragments of map and so on are easy to produce andadd so much more to the atmosphere of an adventure. Providing theactual items cuts down on the detailed descriptions needed and en-ables the player to examine them in far more detail than is possiblewithin the program.

Other ideas for source material which will improve and expand ona simple adventure game include character portraits, if you have char-acters in the game, these will enable the player to visualise just whohe is interacting with; object illustrations, which will show far more detailthan it is possible to include when the player examines the object.Obviously this is only really necessary for important objects, rather thanthe mundane, everyday things such as knives, etc.

22

Page 32: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

The support material provided with Witch Hunt, the example scenariodetailed in later chapters should give you some idea of the type ofmaterial which is suitable for an adventure game. One pitfall to try andavoid is going over the top on support material, to the detriment of theadventure itself. lf your support material contains far more informationand details than are in the actual adventure game, you are going toreduce the players' enjoyment of the game, rather than enhancing it.Once this happens, the aCventure becomes less of a computer baõedgame, and more of a computer assisted game, where the computeradds to the main adventure, rather than controlling it.

23

Page 33: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

v¿

Page 34: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

4THE STRUGTURALELEMENTS OF ANADVENTURE GAME

As we have already seen in chapter 3, an adventure game breaksdown into elements such as locations, objects and puzzles: Each ofthese structural elements can be implemented in a number of differentways, and in this chapter we will describe some of the methods whichare possible, though we will leave the actual programming implemen-tation details until we discuss AKS in later chapters.

A. LOCATIONSLet's leave the methods of storing and accessing the location text untillater, when we will consider all the text the game requires as a whole.For the moment, the major thing we are concerned with is how to linkeach of the locations with its neighbours and how to tie these links inwith the commands the player will use to move around. We will use thesmall adventure map shown below as an example. Each of the locationsis shown as a box, and the directions the player can move are indicatedby the arrows.

25

FIGURE 4.1

Page 35: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Each of the locations in an adventure is connected to others via alink, and the structure we use to represent this is known, reasonablyenough, as a link map. The simplest form of a link map is a straightforward table. The link map for our example is shown belou¡:

LOCAT¡ONNUMBER North

DIRECTIONSSouth East West

Ø

Ø

Ø

Ø

Ø

41

Ø

31

Ø

Ø

2

251

.1

2345

Each of our locations is represented by a number, these running downthe table. For each location we then show which location we will betaken to if we take one of the four directions. Thus, in the above example,assuming we start at location 1, moving South, then East will take usto location 4. Note, if there is a Ø shown for the direction it indicatesthat we cannot move from that location in that direction. e.g. there isnowhere to go to East of location 1. Obviously, there is no reason whywe should limit ourselves to just the four basic directions, and mostadventures include the other compass directions NE, NW, SE, SW aswell as UP and DOWN.

Using this method, we just need to store a series of numbers foreach location, giving details of the links to other locations, and theseare checked each time a movement command is entered. lf it is possibleto move in that direction, the player's location is altered to become thatof the link entry, otherwise the "You cannot move in that direction"message is printed.

While the basic design of link map is fine for simple adventures, itlimits what you can actually do during the adventure to fixed move-ments. The possible directions you can move in from on location nevervary. However, there will be times when you want the player to performan action before he is allowed to go in a certain direction. To returnto the snake and the bird problem mentioned earlier, the player's wayis blocked by a giant snake unless he has the bird and releases it todrive off the snake. Once he has solved this particular puzzle, he isfree to move in the direction the snake blocked, and onto a new location.Thus, we need some method of representing this type of conditionalmove; the answer is to add a link condition to the link map.

This is done by adding a condition to each directions information,which must be true before the player can move in the direction. ln alot of cases the condition will simply be TRUE, meaning the player isable to move in that direction any time he wishes to; for some it will be

26

Page 36: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

FALSE, meaning there is nowhere to go in that direction, while a fewwill have condition to be evaluated. ln the case of the snake and birdpuzzle, the player can only move once he has released the bird andthere are a couple of methods of testing this. We could simply test ifthe bird is present in this location, if it is, the player has dropped it andwe have already dealt with the snake. This presents problems, as ifthe player picks the bird up again, he will meet the snake againl Abetter solution is to use a flag - a variable which can be TRUE orFALSE - and test this to see if the player has released the bird yet.It will have an initial value of FALSE, so the player will not be able toget past the snake, when the bird is released, it is set to TRUE, andthe way is now free.

The úse of conditions can also apply to location descriptions, andit enables the adventure to produce different location descriptionsdepending on which condition is true. Most adventures use this facilityto provide a long description the first time you visit a location, with ashorter, compact description for subsequent visits. The conditions neednot be limited to flags alone, and they can include tests to see if you'vevisited a certain location, are carrying an object, wearing an object,or an object is present at the location.

B. OBJECTSThe first requirement for objects is to have some form of Object Char-acteristics, which will describe each object, and its details. The objectshave to be manipulated by the player, and thus we will need some wayof limiting the number of objects a player can carry at any one time.One simple and commonly used technique is simply to limit the numberof objects to a fixed total, usually around 4 or 6 objects. Yet, this isunrealistic, as objects will have different properties and weights, andthe player should be able to carry more of one type of object thananother due to these properties, The Object Characteristics Vector isa simple table with an entry for each object, which gives the value forthat object for each of the designer's chosen properties. Let us justconsider one property, that of weight: each object can be assigneda weight value, which will represent a proportion of the total weight aplayer can carry. Thus, deciding if the player can carry an object isa simple matter of comparing the object's weight with the weight theplayer is capable of carrying.

This approach allows the player to carry a variety of objects andforces him to balance objects against each other - do you carryaround one heavy object you think you need soon, or a number oflighter ones? lt is also possible to stop players picking up objects whichshould be immovable, simply by setting their weight to more than the

27

Page 37: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

total carrying capacity of the player. lf they attempt to lift them, theyare then told that the object is too heavyl

Only certain actions can be performed on each object, after all youcan't ride a brick or eat a mirror, or whatever, and we need some wayto represent these facts! The solution is to use Action Suitability codes foreach of the objects, which explicitly state which actìons can beperformed on each of the objects. Thus, the entry for a hat might allowthe actions: GET, DROP, WEAR, REMOVE, and EXAMINE to be per-formed on it. lf the player attempts to say something like "EAT HAT",he will just get a standard "YOU CAN'T EAT THATI" reply!

As well as needing to know how much objects weigh, and whatact¡ons the player can perform on them, we also have to know justwhere they arel The object's location is represented by a number,which simply shows at which location the object is present. When thelocation description is printed, the program then scans the ObjectLocation Pointers and prints out the description for all the objects whoselocation matches the current player location.

There are a few special location numbers which can be used to showwhere objects are when they are not in a physical location. Objectsmay also be carried by the player, or possibly worn or they might noteven exist yet! This requires the program to have a standard set ofnumbers to represent this. For example, we might use:

Ø : object does not exist254 : object carried255 : object worn

Thus, if a player picks up an object, its location pointer is altered frompointing to the current location, to being 254 to indicate it is beingcarried. Occasionally, when an object has been used by the player tosolve a puzzle, we might want that object to be used up, or if the playereats some food, we have to take the food off hím. This is done bysetting the object's location pointer to Ø, which "destroys" the object.Resetting an object's location pointer fromØ has the effect of "creating"it.

When programming, it is more efficient and safer to use all datastructures in a consistent way - programs are easier to debug andunderstand. The use of special location numbers is a "dirty" technique,in this respect, as we are using a straight forward data structure in amessy way. lf you can avoid this approach (and it is really a hang-overfrom the early days of adventure games programming) then so muchthe better. The alternative is to have an array representing the objectsworn, which point to the object descriptions.

28

Page 38: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

C. ACTORSThese are the player himself and the non-player characters which mayinhabit the adventure, and with whom the player can interact. Thereare several ways in which to implement actors, some of which involvevery complex and time-consuming techniques. One of the simplestways of dealing with actors is to regard them as a type of pseudoobject. lf this approach is taken, the player can be moved from onelocation to another and manipulated in exactly the same way as anyordinary object. The difference being that the pseudo objects are notdescribed along with the normal objects when the location descriptionis given. Thus, the pseudo objects may only be manipulated by actionsfrom within the program, not by the player himself. This avoids theproblems inherent in the player picking himself up!

One slightly more advanced way of implementing non-player char-acters (NPCs) is to regard each of them as a player in their own right,with a predefined set of commands and desires. Thus, interrupts areused to share the processing time between all the actors, with eachtaking their turn to perform an action if they desire. This enables theNPCs in the game to have an appearance of true independence andlets them perform all of the actions the player is capable of performing.The programming implementation of such a system is harder to pro-duce, and it requires careful calculations on timings to ensure that theplayer cannot be "locked out" of the game by hyper-active NPCs!

D. ACTIONS AND EVENTS

Actions are the result of commands from the player and they causeobjects to be moved around and things to occur. An example of thisis the movement verbs, which will cause the player to change locationaccording to the links in the link map for the current location.

Events are actions which are triggered independently of a commandfrom the player. This is usually implemented using a condition, whichis tested each time the player inputs a command, to see if it has beentriggered yet. When the condition evaluates to TRUE, the relevant eventis set into motion. This approach allows you to implement events whichwill occur after a set number of turns have passed. For example, if theplayer drinks some poison, he may have a number of turns in whichto find the antidote, after which the poisoned event will trigger and hewill be informed he is dead! Alternatively, events can be used to regu-larly trigger an action after every few turns. This might be used toimplement hunger, for example, so the player becomes hungry afterevery 20 turns have passed and then has 5 turns in which to find food;but the effect wears off and thus he has to find food again, and so on.

29

Page 39: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

E. VOCABULARYThe vocabulary of an adventure game consists of the commands avail-able to the player, which can be used while interacting with the ad-venture game. lt is not only the actions and objects which make up thevocabulary (as in "GET LAMP"), even in a simple game. Sherlock hasa vocabulary of BØØ words, and the lnfocom games have a similarrange of words, which allow you to construct very complex sentencessuch as "Get all the boxes except the yellow one and put the blue boxunder the bed"l

. while the storage of vocabulary as data statements is fairly straightforward, a decision has to be made about where the player can accessthat part of the vocabulary. Often, during an adventure game, the playerwill reach a location where a special command is neéded to sblvó apuzzle; this command only works in the one location and it has noeffect elsewhere. lf the vocabulary is stored globally, that is all thewords are available throughout the adventure, the entire vocabularywill have to be searched each time a command is input. Even if thévocabulary is reasonably simple, searching all of it is going to take afair amount of time, and reduce the response time io thè player,scommands even further. Obviously, the number of words to besearched through can be reduced considerably if the ,,special,' com-mands are stored separately.

Within each location, we store a list of special commands which canbe used here, and when a command is input, these are checked beforethe global vocabulary. While saving time, this approach does meanthat words will generate very different messages depending on whichlocation you are in, as the "special" commands will result in ã standard"YOU CANNOT DO THAT" message unless you are at the pertinentlocation. The error reporting could be greatly enhanced if messagessuch as "YOU NEED THE WAND TO DO THAT" coutd be output. tt isa question of balancing the user-friendly responses with the reactiontime you want.

Once we have decided where to store our text, we have to considerthe method of storage. The easiest approach to implement and under-stand is that of a serial list. This is usually just a series of data statementswhich contain the commands available, one after the other, with detailsof which actions to perform for each command. Thus, if we want tohave a command PICK UP, and we already have an action GET, wemight define it as:

IF ACTION : PICKUP THEN PERFORM GET, PRINT OKAY

which would perform a GET and then print out the message "OKAY".We will see more about this when we examine AKS in later chapters.

30

Page 40: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

While the serial list approach is fine for small vocabularies, if thevocabulary is large it will require a long time to search through it all,especially if the word to be matched occurs near the end of the list.A more effective approach, but requiring more memory, is to store thevocabulary alphabetically, with pointers to the start of each letter of thealphabet. While this could be implemented using simple data state-ments, the mostefficient method uses LINKED LISTS and what is knownas an ILIFFE vector. For those of you who have never come across liststructures, we'll explain them before demonstrating how they can beused in adventure games.

Linked ListsA normal list is a straight forward, sequential list, which starts at oneend and which can be followed to the other. This can be implementedusing a normal one-dimensional array, as shown below:

1234567

vo

FIGURE 4.2

The array V has seven elements, of which six contain a letter of thealphabet. The seventh element is empty. lf we wish to search throughthe list V for a letter, we simply start at the first element V(1), andcontinue through the elements until we reach V(7), or find what we arelooking for. lf we wanted to add a new element, D to the array, we caheither place it in V(7), or if we wish to retain our alphabetical order, wehave to place it in V(4), which means moving the elements E to G along.With a small array, as in our example, having to move the elements tomake room for a new entry is no problem, but if you have an arraywhich has several hundred elements it is time consuming!

Let's now look at simple linked lists. These are similar to normal lists,except that each of the elements has a pointer to the element after itin the list. A pointer is simply a variable which contains a value cor-responding to a location in the array. Thus, a linked list version of Vwould look like this:

Vrl

ST.).)FIGURE 4.3

.) .)+

So, each element has a pointer to the element which immediatelyfollows it. We also have two special pointers, outside of the array. Theseare a pointer to the start of information in the array, and a pointer to

31

ùRT'.) ì

F E

GFEcBA

GFEcBA

Page 41: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

the start of the free space - i.e. the first element of the array whichis empty.

lf we wish to add the new element D to the linked list V, there area number of steps to be followed. Firstly, we put the new element intothe first free space, as indicated by the Free Space pointer, this givesUS:

vo

ST RT FREEFIGURE 4.4

We now have to find out where in the list D should be put, this is doneby searching down the list from the element the Start Pointer points at.We then follow the pointers from each element to its successor, untilwe find that D should go between C and E. We now have to insert Dso that it is pointed to by C and it points to E.

We set the D's pointer to point to E, which will give us:

v(l

FIGURE 4.5 FREE

We can now set C's pointer to point to D

FIGURE 4.4

vo

ST T FIGURE 4.6FREE

This has now linked D into the list, without shuffling any etementsaround. lf you follow the pointers from the start, you can see we willgo from A to B, to C, to D, and E and so on. The last thing we mustdo is adjust the Free Space Pointer, otherwise we will overwrite D if weadd a new element. So, we set the Free Space Pointer to the nextelement after D. ln our example, D is the last element of the array, andthus the Free Space Pointer will be set to a . indicating that the list isnow full.

That is only a brief overview of linked lists, a very useful techniquefor manipulating data, and one which can be much more complex withtwo-way lists, circular lists, etc. lf you are interested in more examplesand explanations of how linked lists work, we recommend you look atany computing book on data structures or algorithms,

32

T

DGFEcBA

DGFEcBA

DGFEcA

Page 42: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Right, you now know what a linked list is, and must have alreadyrealised how useful they can be in adventure games for storing data.lf you wish to add an element to a list, you simply need to rearrangea couple of pointers, and avoid the problem of shifting large amountsof data to keep everything in order. For storing vocabulary in such away, that it can be accessed quickly and simply, we require 26 linkedlists, one for each letter, and a method of pointing to them. The pointerto each linked list is known as an IFLIFFE Vector, and is simply a linkedlist whose elements point to other linked lists. The only major problemwith this method being the overheads of storage needed for all ourpointers. Thus, the arrangement we will have is shown in FIG 4.7.

VOCABULARY LINKED LIST

POINTERTO "C"

POINTÊR TOTHE START OF

,,A" WORDS

ILIFFE VECTOR FIGURE 4.7

Now, when we have a command we wish to find, we take the first letterof the command and then follow the appropriate pointer from the ILIFFEVector to the start of the commands beginning with that letter. Forexample, if the command was "KlLL", we would take the K, which isthe 12th letter of the alphabet. This means that the 12th element of theILIFFE Vector points to the start of the commands beginning with K.We follow the pointer and can then scan down the list of "K" words.This ability to go directly to the section of the alphabet we requiremakes the list scanning very much faster, and thus the response timequicker.

The ILIFFE Vector arrangement shown in FIG 4.7 is relatively simple,for very big vocabularies, there is no reason why you shouldn't havean ILIFFE Vector which points to a series of ILIFFE Vectors, which thenpoint to the word list. This enables you to split the words up even more,using the first letter to find the appropriate ILIFFE Vector, and then thesecond letter to find the start of such words in the command list! ltreally depends on the space you have available and the size of yourvocabulary.

Simple Parsing TechniquesNow that we have considered how to store your vocabulary, the nextstep is to look at methods of interpreting the input you receive from theplayer, and matching this up with the vocabulary. The process of an-alysing an input string and breaking it down to the individualcommands

33

Page 43: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

is known as parsing, and we'll look at a few basic methods of achievingthis.

The simplest, most basic form of command input is the one used bythe original ADVENTURE and a lot of adventure games since - thetwo word command. This consists of a verb, which denotes an action,followed by a noun, usually an object. Thus commands along the linesof "GO SOUTH", "GET LAMP", "ENTER BUILDING", etc are all thatare accepted by the program.

The two word command does have a lot going for it, in that it isextremely simple to parse. The command string can be split easily intothe two words, by taking the space (or spaces)between the two wordsas a separator, and assuming that the first word is an action and thesecond an object. The action is compared with the list of possibleactions, and control is passed to the action routine it matches with.This routine will then compare the object section of the command stringwith the list of objects it expects, and will perform the action if it matches.Error reporting is fairly straight forward, if the action is not found, theprogram replies with a "l DON'T UNDERSTAND."; if the object cannotbe found, it simply says "YOU CANNOT action WITH object". Verybasic, but effective.

The first complication which can be built into the parser is to makeit accept "and", "then", "the" and the use of commas. This allows theplayer to say things like:

.,GET THE APPLE, GO SOUTH AND THEN THROW THE APPLE.''It looks a fairly complex sentence, as the player is performing three

actions with just one command. Yet, it is really just three actions whichfollow each other. The parser can ignore all uses of the word "the", asthis is just a {lowery addition to the sentence. The words "and", "then"and "," are simply command separators. The player could have typedin the above sentence as:

,.GET APPLE''..GO SOUTH''..THROW APPLE''

with exactly the same effects. The parser simply has to scan throughthe input string from left to right, building up a list of commands. lt willfind "GET APPLE" first, and this is stored; the comma indicates the endof one command and the start of the next so it can be ignored. "GOSOUTH" is a straight forward command and can be stored as such.The only complication comes with the use of "AND THEN" where theplayer has to use two connectives. The parser has to take "AND" asa connective between two commands, and then realise that "THEN"is another connective, and thus ignore it, leaving "THROW APPLE" asthe final command. Very complex sentences can be parsed using this

34

Page 44: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

method, and it speeds the game up, as the player doesn't have to waitfor the results of each input before typing in the next one.

Very complex parsing techniques can be used, which allow the userto use adjectives, adverbs, etc in his commands. These techniquesrequire some very advanced Natural Language processing, a subjectwhich is a field of Artificial lntelligence Research ín its own rightl Evenin the most advanced Natural Language systems, these techniqueshave not been fully implemented yet.

35

Page 45: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

9e

Page 46: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

5SAVING SPACE

Adventure games can be developed very successfully in BASIC; theAdventure Kernel System described in the next section is a goodexample. lt is possible to create a game which contains most of theelements of the original adventure or the commercial adventures avail-able today. That is, you can create small games which contain theseelements - the moment you try to create a game the size of Adventure(which had over 2ØØ locations) - you are going to run into problems.The home computers available today simply don't have enough mem-ory to contain that big an adventure. Even the Amstrad, with 64Kavailable, would be hard pushed to hold more than 1ØØ locations, andeven then, the descriptive text would have to be kept to a minimum.

So, how can you produce an adventure game with vast amounts offlowing prose, and a large number of locations, puzzles and objects?You can resort to programming your game in machine code, but thiswill only save a small amount of space. The major part of any adventuregame is not the driving routines, the actual program, but the data whichmakes up the adventure. Even using machine code, your data is goingto occupy the same amount of space. However, it is possible to producelarge, complex adventures on even a small machine, as MelbourneHouse has proved with the Hobbit. So, how do they fit all that informationinto the machine? Well, there are a couple of techniques employed bycommercial adventure games which can be used by anyone to producelarge adventure games. These are using discs as a backing storage,and using text compression. We'll look at each of the methods in detail.

DISC ADVENTURESAs well as providing a fast storage medium for the initial loading of theadventure, discs can be used during the game, to load in differentsections of the adventure game, as the player encounters them, thus

37

Page 47: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

abolishing the problems of fitting the whole adventure into the computerat the same time.

ln an adventure game, the player is only evef at one location at onetime - fairly obviously! This means that the location data for all theother locations is not needed, and thus does not need to be in memoryat all. When the player moves from the current location to another one,the new location data is loaded in from disc.

The technique of loading data in from disc, when it is required, isknown as PAGING, and is used by large computers to simulate a muchlarger memory capacity than they actually have, ln the adventure gamesituation, we can divide memory up into several FRAMES (typically 256bytes long) which can each hold a PAGE of data from disc. All theadventure data is stored in the form of pages, including objects, puzzlesand commands, and the relevant sections are loaded in when needed.The drìving routine is the only part of the data to be permanently in

memory, and it searches all the frames of data, for the action, objector location data it requires. lf the data is not currently present in thecomputer, then a PAGE FAULT is generated which causes the requiredpage of data to be loaded.

lf we just loaded in new pages each time we needed the new data,without considering the pages we were replacing, or even which pagewe should replace, then we would soon run into problems. lf a pagehas been altered in some way, and we do not store the alterations, thenext time the page is loaded, those alterations will have been forgottenby the adventure. ln an adventure game, which relies on manipulatingobject data and the player's location, this would prevent us doinganything! The answer lies in developing a PAGE REPLACEMENTPOLICY, which will enable us to save pages which have been altered,and to decide just which page to replace. The latter point is a veryimportant one, if we replace a page which is being accessed all thetime by the adventure - perhaps it contains the data for a commandthe player is using a lot - then the number of page faults will increasedramatically; slowing down the adventure game's response as it con-stantly loads in new data from disc.

The best approach to the problem is to consider the data to be splitinto three distinct types:

A. Resident DataThis is the data which will remain in the computer all the time theprogram is running, and it comprises the main driving routines, andsometimes the most important variables and counters in the game.

B. Pure Page DataThis is data which cannot be altered by the program, and thusit will never need to be written back to disc before replacing it with a

38

Page 48: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

new page. An example of pure data is the location data, where thedescriptions and connections never alter during the game.

C. lmpure Page Data

This is the data which may be altered, and thus must be written backto disc before it can be replaced in memory. Each page contains aspecial marker, which is set when the page is altered in any way. Whenthe page comes to be replaced, the marker is checked, and only if itis set is the page saved to disc. This prevents time from being wastedby saving pages which have not been altered.

The impure data consists of all the volatile, changeable parts of theadventure game, and it is here that the object pointers, flags, countersand variables would be stored. This also allows the adventure gameto be saved during a game by saving the impure data alone, and tobe restored by reloading the same data.

As well as saving pages before replacing them, we must considerwhich pages to actually replace, as we have already noted, and thishas created a large number of very complex PAGE REPLACEMENTALGORITHMS within the world of mainframe computing. We won'tconsider them all here, just take a brief look at one possible approachto the problem. Fairly obviously, we do not want to replace a pagewhich is shortly to be used again, as this only means reloading it fromdisc. But, how do we tell when a page is in use? Or whether it is nolonger required by the adventure game? There is little point in keepinglocation data for a location the player can no longer reach, for example,or object data for apuzzle the player has solved and no longer requires.

Well, in the case of impure page data, we can tell if the page hasbeen used by looking at the marker which says if it has been writtento; if this marker is set, then the page is in use. Thus, we replace thepages which have not been accessed before the pageS which havebeen written to. This is not an infallible approach, however, and uselesswhen it comes to considering pure page data. During the course ofan adventure game, data tends to be altered very rarely, it is read bythe program far more times than it is written to; thus we need someway of telling if a page has been accessed by the program and when,since all loaded pages will have been asked for by the program. Thisrequires the addition of a reference marker, which contains the lasttime the page was accessed. This could be done by putting in the time

- if the computer has a real-time clock, or simply by storing whichturn of the adventure the page was looked at.

When we come to replace a page, we now only have to find the pagewhich hasn't been accessed for the longest time; if two pages containthe same access date, we choose to replace the page which doesn'thave to be saved first. The overhead of a reference and written-to

39

Page 49: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

markers in extra storage is offset by the time which can be saved, andthe reduction in page faults made possible by using them.

TEXT COMPRESSIONThere are a number of text compression techniques, all of which aredesigned to reduce the amount of space required to store text, bycoding it in some way. We will take a look at just two of the morepopular methods in this chapter. The advantage of text compressionis that it offers a method of reducing the size of your adventure database, thus allowing you to develop a much larger adventure; or for thewhole adventure to fit into the machine at once, rather than loadingsections in from disc.

The major disadvantage of text compression is that it requires youto encode all your adventure data using a special encoding routine.This can be time-consuming and drastically reduces the developmenttime if the adventure is so large you have to encode the data duringthe testing stages, and every time you wish to alter part of the adventure.

3:2 Byte GompressionThis technique compresses three bytes worth of information into twobytes - hence its name! Before we can begin to understand how thetechnique works, let's look at how conventional text is stored on theAmstrad.

Each character which makes up text has its own, unique charactercode, this varies from machine to machine, but the Amstrad uses themost popular form of coding - ASCII (American Standard Code forlnformation lnterchange). Each character is stored in the form of a onebyte number, which contains the code for that character. Thus, in ASCll,"4" is represented by the number 65, "8" by 66 and so on. The ASCIIcodes run from Ø Io 255 (the maximum number you can fit into B bits),and offers letters, numbers, special control codes and graphics. Wereally don't need all of these symbols in an adventure game - indeedwe need very few characters.

Adventure game text very rarely uses much in the way of punctuation,and really only requires the upper and lower case letters, space andperhaps "," and "." for punctuation. This is a mere 55 characters, ratherthan the 255 which ASCII provides - and we would only require 6 bitsto store the codes, rather than the normal 8 in a byte, as 6 bits canrepresent the numbers Ø-63. This would allow you to reduce the textto three-quarters of its original size. Ah, but wait a moment, do wereally need to have code for both upper case and lower case letters?Why not simply have a code which means switch into upper case, anda second code to switch into lower case? This would mean we onlyneeded 26 + 3 + 2 codes, or 3'1. This can be represented by just 5

40

Page 50: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

bits, in the form of the numbers Ø-31, allowing us one spare code incase we need it.

To understand how storing a character in just five bits instead ofeight can save us space, let's consider an example, where we wishto store the word GOLDEN.

Figure 5..1 shows how the ASCII representation of GOLDEN's sixletters would look in terms of six bytes.

BYTESI23456FIGURE 5.1

Now, if we assume that our 5-bit codes for our letters start at Ø torepresent "4", the "G", "O", "L", "D", "E", "N" would be representedby the numbers 6, 14,11,3,4,13. The bit pattern for 6 can be storedin the first byte of storage, as shown in Figure 5.2.

000000000000000000000000001 10 000

G FIGURE 5.2We can consider the bytes of storage to be continuous, so we nextstore the 5 bits which represent 14 in last three bits of the first byte,and the first 2 bits of the second byte. This is shown in Figure 5.3.

10001 10 01 1

G o FtcuRE s.3

The bit pattern for the third letter, "L", is then stored in the next 5 bitsavailable. This method of storage is then repeated for the last threeletters of GOLDEN, and it produces the pattern of bits shown in Figure5.4.

GOLDENFIGURE 5.4

Notice that we do not use the last bit of the second byte, or the lastbit of the 4th byte. lf we did use this, it would cause problems whenwe came to decode the text, as it would radically alter the bits a lettercould start at. ln our example, a letter starts at bit B of the first byte,bit 2 of the first byte, and bit 5 of the second byte. This gives only threecases to deal with. Using the last bit of the second byte would mean

NEDLoG

00 0 01 1 1 00001 00110 01011 0101001 10 1

41

Page 51: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

that a letter could start at any one of the bits in a byte, making decodingfar more difficult.

Once your data is encoded using the 3:2 byte compression, you willobviously need a decoding routine to uncompress itl This simply hasto step through the bit patterns, decoding the letters, translating theminto ASCIl, and then printing them out to the screen. This will have tobe a machine code routine, as BASIC is far too slow at this type ofthing, and doesn't provide the facilities to access individual bits likemachine code does.

Huffman GodingHuffman coding is a text compression technique which is based onthe relative frequency of each letter. This means that if all the lettersoccur with the same frequency, there will be no space saved I Thisnever occurs though, as the frequency of letters always varies in apiece of text - with "e" being fairly frequent and "2" fairly infrequent,for example.

The technique is to build up a dictionary tree, which can be usedto decode the encoded text. The dictionary which allows you to decodethe text is specific to one piece of text, and must be built up anew foreach fresh set of text. This can be very slow, and time consuming, butthe space savings which can be achieved by Huffman Coding morethan make up for this disadvantage. Besides which, you would normallyonly compress your adventure text once - after each section has beencompletely tested.

The Huffman method represents different letters with a different num-ber of bits, depending on their frequency. Thus, the most frequentletters will be represented by 'l or 2 bits, with the least frequent beingrepresented by B or even more bits. Because the coding and decodingtechnique doesn't use a fixed number of bits, it must ignore byte bound-aries, as the bits representing a ietter can start in one byte and end .

in the next one.The best way to explain the Huffman Coding technique is to give an

example of its use. As the technique is quitê long winded to do byhand (in practice, we would write a coding routine to scan through textand code it automatically), we will consider just one word, as an illus-tration of compression. ln this case, we'll use minimum as the word wewish to code.

The first step is to find out which letters occur in the word, and thefrequency of these letters. Using our example, we can build up thetable below: Letter Frequency

i

mnu

231

1

42

Page 52: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Having done this, we search through the list of frequencies to find thetwo least frequent letters, and then pair these together, giving us:

i2m3n-u 2

We then repeat this pairing, with the next two lowest scoring letters,to give us:

i-(n-u) 4m3

And, finally, we pair up the last two frequencies, giving:

(m-(i-(n-u))) 7

Having built up this pairing of frequencies, we can now build up ourdictionary tree, as shown in figure 5.5

FIGURE 5.5

When we wish to encode a character, we start at the top of the tree(known as the root - in computing, trees grow upside down!), andwork our way down the tree until we reach the desired letter. For eachtime we take a left fork in the tree, we write down a Ø, and for everyright fork, we write a 1. This means that the letters in minimum will berepresented as follows:

m:Øi :1Ø

n :11Øu :111

lf you take the paths indicated by these numbers, you'll find that youend up at the letter they represent, and that is all there is to decodinga Huffman tree!

Now that we have calculated the dictionary tree for the word mini-mum, we can now code it into bits. The resultant code is shown inFigure 5.6.

FIGURE 5.6

43

0111001011010

1st BYTE 2nd BYTE

Page 53: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

As can be seen from Figure 5.6, the representation for minimum is nowa byte containing Ø1Ø11Ø1Ø and 5 bits containing Ø111Ø. Thus, theword now occupies just over one and half bytes. Using standard ASCII

representation, it would normally occupy seven bytes (one for eachletter). That is a reduction to just 23/" ol its original size - quite asaving I Obviously, the Huffman Coding technique works especiallywell witn a word like minimum, due to the large number of repeatedletters - the reason we chose it. The reductions in size for a normalpiece of text won't be quite so spectacular, but should be in the regionoÍ 5Ø-6Ø"/" of original size at the worst.

One way to compress text even further, using Huffman Coding, isto use not just the frequency of letters, but also commq! phrases' Thus,you can répresent phrases such as "A LARGE CAVERN"' which may-be

quite common using just a few bits. This technique is used by a lotof the commercial software houses, as it enables adventures with sev-eral hundred locations to be fitted into most of the home computerscurrently available.

44

Page 54: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

sEcTlolt 2TI{E ADVENTUREKERNEL SYSTEM

45

Page 55: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Page 56: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

6WHAT IS AKS?

This section of the book describes the use of AKS - the AdventureKernal System. This has been designed as a data driven adventuregames system which enables you to change the adventure scenariodata without needing any knowledge of programming and without hav-ing to modify the main driving routines. Yet, it has been written in BASICso that you can understand and modify the data simply and easily, ifyou so desire.

What can you use AKS for, and why would you want to use it? Whatare the advantages over writing your own adventures? Well, we'll tryand give you an idea of the wide range of possibilities available withAKS, and the uses to which it can be put.

The first and obvious use for the AKS system is to create and playyour own adventure games. This section outlines the commands avail-able in AKS and gives examples of each of them. You will find thatvery complex games can be created using the techniques and com-mands shown and that they can be developed quickly and easily, asthere is no actual programming work involved. The advantage of notwriting your own adventure from scratch is that we have done all thehard work for your already! There is little point in duplicating programswhen you can use the time creatively to design adventure gamesl

The fact that AKS is based on a data-driven structure means thatnew adventures can be constructed simply by changing the actualscenario data, without having to modify the program, or rewrite anypart of it. The approach most adventure game books have advancedin the past is that of specific coding - each action and event in thegame is tied to a specific piece of code which deals with that one partof the adventure alone. This is extremely inefficient, and a criminalwaste of time and effort as the basis of most adventure games is exactlythe same, although with different data components. The specific codingapproach requires you to rewrite the whole adventure game from

47

Page 57: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

scratch each time you create a new scenario;the data-driven approachsimply means coding your scenario data each time.

Àpárt trom designing your own adventure games without resortingto programming, the AkS system can teach you a lot of useful tech-niques for adventure games writing, and careful study of the program

wili prove extremely helpful. After you have mastered designi.ng ad-venture games usiñg AKS, you can then move on to expanding the

system, using your own programming skills. We will look at the ex-pansion possibilities of AKS in a later chapter.'

We have included an example AKS scenario WITCHHUNT in the

book, and you might wish to buy the cassette tape version of AKS and

WITCHHUNT befóre you read through the relevant chapters on thescenario, so that yotf can enjoy the game, and then study the plot

details after you have finished playing it.

DATA REPRESENTATION IN AKSThere are basically two approaches to representing the actual scenariodata for an adventure game, The first of these is to store the data as

straight forward BASIC DATA statements as any ordinary program datamight be stored; or to store the data in arrays, which are generatedby-a special data preparation program and loaded into the programfrom tape or disk each time it is run. There are advantages and dis-advantages to both of these methods, and the method we have chosento use w-ith the Adventure Kernel System is the first approach' Let'slook at the two methods and try to explain why we found our chosenstyle of game the most suitable for AKS.

Advantages of readability over codingWith all the scenario information stored directly in the program itself,

all the data is immediately visible to the scenario designer, you caneasily list the locations or objects you are interested in, without havingto print out array values or load in separate programs. This advantagewill be immediately evident to someone who has tried to design anyadventure game using either commercial adventure creators, or otherprogramming methods. The adventure game data can be seen as awhole using OATR statements, something which is not possible other-wise; and ii you want to check just what object 16 is, there is nothingmore annoying than having to go through several menus, or printing

out an array.Coding the scenario within the program does mean that data cannot

be easily edited or altered. Adding a location can mean having tochange a large chunk of the program as well as just the locations array.Data statements mean the data can be easily added to and correctedusing nothing more than the Amstrad BASIC editor, which allows you

48

Page 58: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

to simply alter lines of scenario data in the same way you would alterany program line. This also avoids the necessity of having to write aspecial editor for the data, or having to learn to use one!

Not only can the data be entered and corrected more easily usingthis method of representation, but the whole process of debuggingand developing the adventure game is speeded up. lf the data is storedseparately from the main adventure program and has to be loaded in

to the machine each time, it is going to slow development work downenormously. Each time you edit and correct an invalid part of theadventure game, you will have to load in the data generator, load thedata, edit the data, save the data, load the adventure driver, and finallyload the edited datal With the AKS method you simply have to loadthe adventure program and your data is already there. Simply edit anydata which is wrong and re-run the driver. The only time the programhas to be loaded or saved is at the start and end of the design session.Clearly, the use of a separate data generator on a tape based machineis totally impractical, as most of the time will be spent swapping tapesl

The other major advantage of using BASIC and a very readable formof data is that the BASIC interpreter is already resident in the machine,and avoids the necessity of loading in yet another program for eacilsession. This is a major failing with adventure design systems whereyou have to load the programming "language" and the database everytime you wish to use them.

Disadvantages of readable data compared with coded data

Despite all the advantages listed above and the fact that we havechosen this method for the AKS system, it is not totally perfect and cancause some serious problems.

One problem on a lot of machines is that the data is in no waycompacted. Using text compression techniques can reduce the sizeof the data by a significant amount. The problem is balancing the needfor space against the need for readability and ease of development.Compressing text can take a lot of time, and you don't want to haveto do that each time you test a new part of the adventurel On a machinewith limited memory - say only 16 or 32K, the need for space isextremely pressing if the game is going to have more than just a fewlocations, or a reasonable number of locations and little descriptivetext. ln this case, text compression would probably be advisable,though it may be possible to test at least part of the adventure gamebefore compressing the text for the final version. On a 64K machinesuch as the Amstrad, this is not such a problem and you are unlikelyto find space a major concern while using AKS, unless you are tryingto write a truly enormous adventurel

The use of large amounts of uncompressed text also results in alarge program, which will slow the game down. The more data the

49

Page 59: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

program has to scan through, the slower it will become and the useof DATA and RESTORE can slow the program by a significant amount.

Adventure games are meant to be a challenge and they should keepthe player occupied for at least several hours, if not days or months.However, players can often be driven to extremes by a puzzle theycannot solve and thus they may be tempted to "cheat". This is notpossible on most games where the text messages and responses forthe game are coded - in order to find the solution to a puzzle you willhave to write a decoding routine of your own; and this can be a majorpuzzle in itselfl However, with the AKS approach the whole idea is tohave adventure puzzles, solutions, etc as visible and as easy to findas possible, so that the writer can easily debug and finish the game.This will allow any player to cheat, simply by listing the program andfinding the pertinent DATA statement. On most machines this is aproblem, but there is a solution on the Amstrad. Develop your gameusing the normal mode of files and tape handling. Once you are surethat the program is fully debugged, tested and finished, save it usingthe PROTECT option. This will allow other people to load in your ad-venture and play it, but they won't be able to break into the listing tofind the solutions to problems. Keep an unprotected copy for yourselfthough, just in case there are any bugs left undetectedl

Considering the overall advantages and disadvantages, it can beseen that the use of easily read, easily edited DATA statements is thebetter approach for the Amstrad AKS system. The problems are faroutweighed by the advantages.

THE LAYOUT OF AKSAKS is designed rather like a programming environment, in that eachpart of the program and data has a set place in memory. The diagramin FIG 6.1 is a memory map of the AKS system, and shows you theorder of data.

FIGURE 6.1

F.END OF DATA.EVENT DATAOBJECT DATA.LOCATION DATAAKS DRIVING ROUTINES

MEMORY MAP OF AKS

Thus, all the data is located below the AKS system, and it should bepresented in the order of Locations, Objects and then Events. The endof the data section is marked simply by an F. Within each section, thedata is ordered by location, object or event number in numerical, in-creasing order,

50

Page 60: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

7ACTIONS IN AKS

The AKS actions are the parts of the vocabulary which cause an actionto take place, there are nineteen separate commands, each of whichis represented by a two letter abbreviation. A command line starts withan A, to indicate an action. The actions are only performed:

a) as the result of a triggeror b) as the result of an event firing.

We'll take a look at each of the Actions in turn, together with an ex-planation of the effect of using each one. Later chapters will show howthese commands are actually incorporated within an AKS database,as well as expressions and triggers.

Assign Flag (AF)AKS provides a number of flags, which may be set to TRUE or FALSEby the user, and then tested in later operations. The assignflag com-mand will set the specified flag to the specified state, and takes theform of:

AF, <f num>, <f lagstatus>e.g. AF,11,T

where <fnum> is the specified flag and flagstatus is T or F.

NOTE: lf flagstatus has a value other than T, then the flag will be setto FALSE, without an error being reported.

DRop (DR)

This will result in the object mentioned in the player's command linebeing dropped, providing it is being carried, and that it can be dropped.Otherwise, a suitable error message is produced.

51

Page 61: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

EXamine (EX)

The object in the player's command line is tested, and if it is presentand may be examined, the description is then printed.

GEt (GE)

As with the drop command, the object to be taken is checked forsuitability, and to see if it is present. lf all the conditions are met, theobject is added to his inventory.

GO (GO)

This command causes the player to move in the direction given, mcvinghim to a new location if a connection exists from the player's currentlocation; otherwise printing "You cannot go that way". The commandtakes the form:

GO,<direction>e.g, GO,N

where <direction> is usually one of N, S, E, W, U or D - indicatingnorth, south, east, west, up or down respectively. The direction maybe any word, providing it has been used in both the action and locationdefinition.

HaltGounter (HC)

The AKS system provides a number of counters, which are decre-mented each move. The HC command will stop the specified counterfrom counting. The command's form is:

HC, <cnum>e.g. HC, 11

lncScore (lS)A scoring facility is provided by AKS and the lS command will add thescore increment to the score. The command format is:

lS, <int>e.g. lS, 25

The increment can be positive or negative,

In itialiseGounter (lC)

This will initialise the counter indicated to <int>, and starts the count-down of moves. When Ø is reached, the event <cnum> will fire. Thecommand format is:

lC, <cnum>, <int>lc, 11, 1Øe.g

52

Page 62: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

lNventory (lN)

Displays the objects which the player is currently carrying or wearing.

LOad (LO)

This reloads a SAved game from tape.

MoveObject (MO)

This will move the object specified to the location number specified.It takes the format of:

MO, <obj>, <loc>e.g. MO, 12,24

PutOn (PO)

This changes the status of the object referred to in the command lineto show that it is now being worn by the player.

PRint (PR)

Prints the following string onto the screen. The print command takesthe form of:

PR <string>e.g. PR, you cannot eat thati

ou¡t (ou)This will quit the game (note: without requesting a confirmation fromthe player), and then prompts "Another Game?".

SAve (SA)

This saves all the variables associated with the game to tape, so thatthe game can be reloaded later on.

SCore (SC)

Prints the player's current score on the screen.

TakeOff (TO)

The opposite of PutOn, fairly naturally, this changes the status of theobject referred to in the command line from being worn, to being carriedby the player.

Zaptn (ZllThis takes an object from whatever location it is currently at, and bringsit to the player's current location. The command form is:

Zl, <obj>e.g. Zl, 11

53

Page 63: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

ZapOut (ZO)

This takes an object and changes its location to "nowhere", effectivelydestroying it. lt takes the form of:

ZO, <obj>e.g. ZO, 11

RANGESThe parameters to the above actions have maximum and minimumvalues, which cannot be exceeded; an Amstrad Basic error "subscriptout of range" will occur if you do exceed the values. These are definedas follows:

<int> : BASIC integer (signed).<fnum> : Ø..maxflag.<string> : BASIC string. NB must be surrounded by quotes if

the string contains commas.<obj> : Ø..noofobjs (where Ø is the player).<loc> : -1..nooflocs (Ø is the player, -l is nowhere)<cnum> : Ø..maxcount.

The upper limits to some of these ranges are set within the program,by the constants at the start of AKS. The initial (and arbitrary) vãluesare:

maxflag :36maxcount :5maxobi :2Ømaxloc :3Ø

Their values can easily be changed using the normal BASIC editor.

54

Page 64: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

ITRIGGERS IN AKS

Actions in AKS can be activated in two ways, either directly from theplayer input, or indirectly inside the program, These are known astriggers and events respectively, and we will look at the former in thischapter.

The format of a trigger command is:

T, word list, conditionA, action

The word list is simply a list of words, which will cause this trigger tobecome active if they appear in the player's input. These are followedby a condition, which governs the condition under which the actionsmay be performed. The trigger line is then followed by a list of actionswhich will be performed.

While triggers are easy to implement, it is important to pick the correctwords for the word list, to ensure that you have covered all the possibleplayer input, which should cause the actions to trigger. For example,if the player has to give an object to another character in the game,he might use "G|VE", but you should also include words such as"SHOW", "HAND", etc. Only using one direct phrase such as "GIVETHE COlNS", results in a very limited vocabulary and causes greatfrustration to the player. You want players to enjoy your game - nottear their hair out while playing itl

There are two forms of trigger in AKS, local and globaltriggers. Thefirst of these, as their name suggests, are triggers which can only beactivated when the player is at the current location, and which areignored at all other locations. The second type, global triggers, areactive all the time, and can be triggered by player input from anylocation. The AKS system examines the local triggers before the globaltriggers are searched, which enables you to alter the behaviour ofcommands within different locations. Let's look at some examples to

55

Page 65: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

see what we mean by this, and how to use triggers in your ownadventures.

Firstly, the global triggers. These are entered in the database as partof location Ø, This is a special location, which does not appear in theactual adventure game - the player can never visit location Ø. lt ishere that we can declare all the synonyms for our global vocabulary.For example, we might want the player to be able to perform a "GET"action, enabling them to pick up objects. As well as "GET", it wouldbe convenient to allow the player to type in "TAKE", "PICK UP", andso on. This is done by declaring a global trigger as follows:

T, get, take, pick up,.A, GE

So, if the player inputs any of the words in the trigger line, then thesystem performs a GET action. We can do the same for all the usualcommands as well - if you look at the listing for WITCH HUNT, youwill see that most of the global commands you'd ever want to use havebeen declared,

The local triggers are very similar to this, except that they are declaredwithin the location description they apply to. They are declared inexactly the same way, so a declaration of :

T, feed ducks, feed duck,*A, PR, the ducks gobble up all the bread and leave.A, ZO,5

would only trigger if it was at the player's current location. lf this wastrue, and the player typed in "FEED DUCKS", then the system wouldprint the appropriate message and then remove the ducks from thatlocation (the ducks being object 5).

As well as declaring actions which manipulate objects, we canchange the possible directions the player can move. lf the currentlocation has connections east and west, with a small building to theeast, the player can move east or west by using the usual movementcommands. However, most adventure players will expect to be ableto go east to the building by typing "1N", not just "EAST". This can beallowed by declaring a trigger such as:

T, in, enter,*A, GO, E

which will move the player east when they type "lN" or "ENTER".We can also alter the actions a command word had in each of the

locations. For example, suppose we have declared this global trigger:

T, rub amulet, stroke amulet, .C5

A, PR, nothing happens.

56

Page 66: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

lf the player rubs the amulet (object 5) the system will simply informhim that "NOTHING HAPPENS". ln one location, however, we wantrubbing the amulet to actually cause a very different action. This canbe implemented by declaring a similar trigger in the desired location.This might take the form of :

T, rub amulet, stroke amulet,.CSA, PR, The portcullis rises up and out of sight!A, AF, 1Ø, T

This means that rubbing the amulet causes a message to be printedand the flag 1Ø to be set to TRUE. This is possible because, as notedbefore, AKS scans the current location for triggers before scanning theglobal triggers. When a trigger is found, it is activated, and the triggersearch is terminated. This ensures that only one trigger will be activatedfor each of the player's inputs.

57

Page 67: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

89

Page 68: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

ILOGATIONS,OEIECTS ANDEVENTS IN AKS

An AKS scenario is based around the structures of Locations, Objectsand Events, as these govern which actions take place where, whichobjects can be manipulated and so on. ln this chapter we will take alook at how the Actions and Triggers we have already considered fitinto the Location and Object structures.

The ordering of different data types is important in AKS, as thememory map in chapter 6 shows, and thus we will deal with thesediffering data types in the order they will appear in an AKS scenario.

LOCATIONSLocations must be declared in an AKS database in ascending orderof location number. Location zero is the special global location, as wehave already mentioned in the previous chapter while looking at Trig-gers. Each location has a very similar header, which might look likethis:

L, 15D, *, ln the dark woods.c, N, ., 16c, s,., 18

This declares location 15, with a description of "ln the dark woods",which has no condition attached. The location is connected to location16 to the north, and location 18 to the S. There are no conditionsattached to the player moving to either of these two locations. There

59

Page 69: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

can be as many descriptions (each with an associated condition) asyou wish, which enables us to simulate darkness, or to abbreviate thedescription if the player has already visited this location. We simplyinclude these facts in the relevant condition; see the next chapter fora detailed description of the conditions available in AKS, and their use.

The above location declaration is very basic, as it does not includeany triggers, these are simply added in before or after the connectioninformation. An example location might be:

L, 15D, *, ln the dark woods.c, N,., 16C, S, -, 18T, climb tree, go tree, *

A, PR, you cannot climb trees.T, plant acorn, plant, bury, * C7A, PR, the planted acorn grows into an oak treeA, ZO,7A, ZI, B

This adds triggers which will detect attempts to climb trees, and plantacorns!

OBJECTSObjects must be declared in numerical order, any out of sequenceobjects being reported by the AKS system when you attempt to executethe adventure. ln the same way that location Ø is special, so is objectØ, as it represents the player! This does mean that object Ø can bemanipulated in the same way as other objects - so you can move theplayer around, but, the declaration for the player will normally onlyinclude an initial starting location and nothing else.

There are a number of elements to an object declaration, and wewill look at each of these in turn. The best method is to consider thefollowing example, and we can then look at what each element standsfor:

o,4D, *, A small rusty lamp,P, 19N, rusty lamp, torch, "S, GE, -

S, DR, -

S, EX, "

This declares object number 4. The first line of the declaration givesthe object a description, which will be printed out with no conditions

60

Page 70: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

attached. The "P, 19" says that the lamp's initial position at the startof the adventurewill be location 19. We need to letthe player refertothe lamp by different names in his command input, so we declare aset of names using the "N" command, which allows you to attach acondition to the player using that name.

Finally, the "S" construct lets us set the suitability of the object to beused with certain of the inbuilt AKS actions. ln our example above, ourlamp is suitable for GEtting, DRopping and EXamining; there is no limttto the actions which can be performed on an object (except com-monsense of course!).

EVENTSAn event is acted upon whenever the counter associated with it reachesa value of zero, after it has been activated by another part of thedatabase. This is where the lnitialise Counter action comes in, as wecan set the counter to a number of turns, after which the event associ-ated with that counter will come into action.

An example event might be declared as follows:

This declares event Ø (which is not special in the way location andobject Ø are) and lists a number of actions to be performed. ln the caseof our example, when the event is triggered, a message "You have runout of time . . . " is printed, the player's score displayed and then thegame ended. This could be used if the player had a maximum numberof moves to complete some actton, or even the whole game, in. lf hefails to do so, event Ø comes into action.

E,OA, PR, You have run out of timeA, SCA, QU

61

Page 71: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

¿9

Page 72: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

10EXPRESSIONS INAr(s

At certain points in AKS you may wish to attach a condition to something.lf the condition is true then some operation is performed othenruise itis not. When writing an adventure game scenario in Basic a conditioncan be expressed as an "lF condition THEN perform operation" state-ment. AKS aims to do away with the need to write in Basic in order tospecify your scenario and so cannot use this technique. However, theneed for some form of conditional testing when specifying an adventuregame cannot be overlooked. How could the puzzle with the big greensnake barring the way of the player be implemented if the scenariowere unable to test if this puzzle had been solved. Obviously, AKSmust have conditional testing. A glance at the scenario definition forWITCHHUNT will reveal the presence of a large number of asterisksat various positions in the definition statements. Each of these may befollowed by a string of characters terminated by the end of the line orby a comma. The absence of this string represents the absence of anycondition - i.e. the associated operation is unconditional.

As in Basic, an AKS condition may have the value of true (T) or false(F). lf the condition is true the operation is performed. An lF statementwhich only allowed you to say "lF T THEN . . . " or "lF F THEN . . . "would be useless. To be of use the condition must be allowed to besomething which is evaluated to either T or F. At the simplest level thiscould be a flag variable. For example, a flag variable could be setaside to indicate whether or not the snake puzzle has been solved.AKS has flags called FØ, F1, F2 . .. and so on. Supposing we haveallocated F1Ø to represent the snake puzzle then we can write thecondition as *F1Ø. AKS initialises all flags to F at the start of a game.When the player solves the puzzle the scenario assigns the value T

63

Page 73: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

to F1Ø. The AKS coding for the snake puzzle could be implementedby defining the appropriate location (18) as follows :

DATA L,1BDATA D, *, You are in the Hall of the Mountain King.DATA D, . F1Ø, A large green snake bars your way aheadlDATA T, release bird, *

DATA A, PR, The bird drives the snake away,DATA A, AF, ,1Ø,

T

When the player first arrives at this location he will be greeted by thefollowing description:

You are in the Hall of the Mountain King.A large green snake bars your way aheadl

The player can now drive the snake away by entering the command"RELEASE BIRD" to which AKS will respond:

The bird drives the snake away.

The AssignFlag (AF) command then sets F|Ø lo T indicating that thepuzzle has been solved. Now the description of the location will appearas just:

You are in the Hall of the Mountain King.

This is fine but there is nothing there which states that the player mustbe carrying the bird in order to release it. Another test is required toreplace the unconditional indicator at the end of the trigger line. Onepossibility would be to set a flag to T when the player catches the birdand test this as we did for the snake puzzle. However, you then haveto remember to reset the flag to F if the player drops the bird. A neatersolution is to have a function which tests to see if the object is beingcarried by the player and becomes T or F accordingly. This type offunction is called a predicate and can be tested in a similar way to aflag. So that CØ, C1,C2,.. . indicate whether objects Ø, 1,2,... arebeing carried. Therefore, if the bird is object number 3, the snakepuzzle coding can be updated to:

DATA L,18.DATA D, *, You are in the Hall of the Mountain King.DATA D,* F1Ø, A large green snake bars your way ahead!DATA T, release bird, . C3DATA A, PR, The bird drives the snake away.DATA A, AF,1Ø, T

AKS supports six different types of predicates and flags for use inexpressions. With the exception of the flag type discussed earlier, the

64

Page 74: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

AKS program maintains the necessary information to return a value ofT or F for each of these tests. The flag variables FØ,F1,F2 . . . are onlyaltered by actions in the scenario definition and their meaning is de-cided by the scenario designer. The AKS predicates and flags arelisted below:

Cx ......... Carrying object xFx ......... Flag xLx ......... at Location xOx ......... Object x at current locationWx......... Wearing object xVx ......... Visited location x

Although these flags and predicates allow a number of tests to beperformed it is often useful to be able to invert the result of a test. Theoperator "NOT" allows you to do this in Basic. The "NOT" of true is

false and vice versa. AKS uses a minus sign to perform the sameoperation. For example, -C3 can be used to test for the bird not beingcarried and to print an appropriate message if you try to release it:

DATA L,18DATA D, ", You are in the Hall of the Mountain King.DATA D,.F1Ø, A large green snake bars your way ahead!DATA T, release bird, .C3

DATA A, PR, The bird drives the snake away.DATA A, AF, 1Ø, ÏDATA T, release bird, .-C3

DATA A, PR, Good idea, but you don't have it.

ln addition to the "NOT" operator, Basic conditional expressions allowthe use of "AND" and "OR" to construct complex tests. AKS uses thesymbols "." for "AND" and "/" for "OR", So far there is nothing in theexample scenario location to stop the player passing the snake eventhough he has been told his way is barred. This requires that all theconnèctions from this location except up (U) which is the way backout of the location, only be opened when F1Ø is T:

DATA L,18DATA D, *, You are in the Hall of the Mountain King.DATA D,.F1Ø, A large green snake bars your way ahead!DATA T, release bird, .C3

DATA A, PR, The bird drives the snake away.DATA A, AF, 1Ø, TDATA T, release bird, "-C3DATA A, PR, Good idea, but you don't have it.DATA C, N, -F10,17

DATA C, E, *F10,12

65

Page 75: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

DATA C,W, -F1Ø,25

DATA C, U, -, 5This has defined the connections north, east and west to locations 17,12 and 25 to be open only when the snake has been driven off. Now,let us introduce another problem the player is faced with at this location.Once the snake is disposed of, the player is free to explore the con-nected locations and is able to find three treasures. However, certainof these treasures are too large or heavy to carry up the stairs from theHall of the Mountain King together. lf the player is carrying the goldbar (object 4) and the axe (object 5) or alternatively, the gold bar andthe jewels (object 6) and wearing or carrying the armour (object 7) thenhe may not go up. This can be expressed by:

L, 18D, ., You are in the Hall of the Mountain King.D, *F1Ø, A large green snake bars your way ahead!T, release bird, .C3

A, PR, The bird drives the snake away.A, AF, 1Ø, T

T, release bird, .-C3

A, PR, Good idea, but you don't have it.c, N, .F1Ø, 17c, E, -F1Ø, 12c,w,.F1Ø, 25c, u, .-((c4.c5y(c4.c6 .w7 tc7)), 5

AKS evaluates conditionalexpressions starting with the highest priorityoperators first unless brackets specify otherwise, as does Basic. Thepriority of operators in descending order are - (not), / (or), . (and). So inthe above example the order of evaluation is:

<a> (C4. C5)<b>W7lC7 "/" is higher than "."<c> C4. C6<d> result of <c> . result of <b><e> result of <a> / result of <d><f> - result of <e>

DATADATADATADATADATADATADATADATADATADATADATADATA

66

Page 76: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

SEGTIO]I THREE

IMPLEMENTTNG AKSON TIIE AMSTRAD

67

Page 77: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

89

Page 78: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

11PROGRAMMINGTECHNIOUE

AKS has been written in a highly structured format with an emphasison readability and robustness of the Basic code. The techniquesadopted in the programming of AKS to achieve this structured formatare described below,

1. PROCEDURAL APPROACHThe problem tackled by AKS has been divided into several sub-problems and each of these divided into sub-problems and so on untileach sub-problem becomes trivial. These trivial sub-problems are thencoded as Basic Subroutines. lt is important that the interaction betweenthese subroutines is tightly controlled and made clear in the listing. Tothis end, the assignment of a value to a variable which is to be usedin another subroutine is made on the same line as the 'GOSUB' state-ment (e.9. 'loc:Ø:GOSUB 123Ø:REM .isobjatloc.'). lf a subroutine re-turns a value in a variable then where possible any test¡ng of that value,or any use of that value is performed immediately after returning fromthat routine.

2. SENSIBLE VARIABLE USAGEThe most obvious point here is the use of meaningful variable namesto increase readability. Amstrad Basic allows multi-character variablenames for this reason. ln addition to enhancing readability, the use oflong variable names reduces the chance of conflicting use of a vari-ables (i.e. attempting to use the same variable for different things atlhe same time). All variable names are in lower case to make themstand out from the upper case Basic keywords.

69

Page 79: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

AKS initialises several constants at the start of the program (e.9. thenumber of scenario locations is set by 'rnaxloc:3Ø'). As their namesuggests these 'variables' are not changed anywhere else in the pro-gram, even though it is strictly possible to do so. Thìs has two effects.Firstly, it increases readability and secondly, it makes it easy to modifythe program because the value need only be changed in one place.

3. COMMENTINGComments are used in an orderly and consistent way. Lines containingjust a colon are used extensively to space the program out and divideit into logical blocks. ln the main part of the program a logical blockis a group of instructions with a similar function. For the rest of theprogram, a logical block is a subroutine. In addition, every subroutineis headed by two 'REM' statements. The first of these has the nameadopted throughout AKS for that routine bracketed by three asterisks(e.g. 'REM *** resetflags ***'). The second is just a blank'REM'statementto highlight the routine title.

Any subroutine call is followed by a comment containing the nameof the routine bracketed by single asterisks (e.9. 'GOSUB 5ØØØ.AEM*resetflags*'). To maintain this standard some 'lF condition THENgosubsomewhere ELSE gosubsomewhereelse' statements have beensplit into two statements (i.e. 'lF condition THEN gosubsomewhere' and'lF NOT (condition) THEN gosubsomewhereelse') to allow the 'GOSUB'sto be followed by a comment.

Although the game is written to run in Ìhe 4Ø column I\i ODE 4, thecommenting has been written for viewing in the BØ column MODE 2.

Where possible, comments about the operation of program lines areon the same line and use the single quote character instead of ':REM

. . .' to start the comment. This helps to distinguish normal commentsfrom subroutine labels on 'GOSUB's. Should the comment be too longto fit on the same screen line or if it is syntactically invalid to have acomment on the same line as that type of statement then the commentis placed, where possible, on the line preceding the statement. ln thiscase a normal 'REM' is used instead of a single quote to make thecomment stand out from the Basic statements. Unless emphasisingsomething, comments are in lower case to make the upper case Am-strad Basic keywords easy to see.

4. CAREFUL CONTROL OF FLOWSomething which explicitly controls the flow of a program is potentiallyvery dangerous. Apart from having the potential to make a programtotally unreadable, incorrect use of flow controlling instructions canresult in corruption of the Basic stacks, The most obvious control flow

70

Page 80: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

instruction is 'GOTO'. Much has been written about the use and misuseof 'GOTO', but few will deny that it is difficult to program in Basic withoutit. Amstrad Basic goes some way towards removing the need to use'GOTO' by allowing the use of 'WHILE..WEND' loops as well as thenormal 'FOR..NEXT' loops. AKS makes much use of the'WHILE..WEND'construction. Another common use of 'GOTO' is to implement multiline'lF..THEN..ELSE..' statements. AKS avoids using 'GOTO'for this by theuse of multistatement Iines instead. However, AKS does make use of'GOTO'as a quit instruction to skip over the rest of a'WHILE'loop'sinstructrons and go directly to the 'WEND'. This technique of jumpingto 'WEND' is used to terminate the loop without corrupting the Basicstack. When AKS does this, a comment is used to identify the 'GOTO'as a quit instruction.

Another frequently misused control flow instruction is 'GOSUB'. Tomake a subroutine easily understandable, a subroutine should haveonly one entry point. ln the AKS Iisting the entry point to each subroutineis the line immedìately following the title 'REM'. lt is a good idea notto 'GOSUB' or'GOTO' a'REM' statement, as these are often removedfrom the runtime version of the program; thereby causing a'line doesnot exist' error. The last instruction in every AKS subroutine is a 'RE-

TURN'. The practice of using 'GOTO'to jump in and out of subroutinesis avoided. However, it is often desirable to skip the remaining instruc-tions in a subroutine, This could be done using 'GOTO' to jump to the'RETURN' instruction. A cleaner solution is to use another 'RETURN'instruction instead of the 'GOTO'. Even here, AKS comments the pi'e-

mature subroutine exits as quits.

DIRTY TRICKSExamination of the first few lines of the AKS listing will reveal thateverything is not perfect. To implement AKS in Amstrad Basic a signi-ficant problem must be overcome. AKS works by interpreting a scenarìodatabase specified in 'DATA' statements at the end of the program.Each statement occupies one 'DATA' line and AKS must be able tofind the start of any given statement. Unfortunately, Amstrad Basicdoes not allow use of the 'RESTORE' statement with a variable linenumber (i.e. 'RESTORE fred' is illegal). lnstead, it insists on a literalline number (e.g. 'RESTORE 5ØØ'). Totally legitimate use of 'RESTORE'

in AKS would require a ridiculously time consuming search from thefirst 'DATA' statement, reading a string (not a line) at a time, until thedesired line is found. Therefore, AKS resorts to a'dirty technique'which'POKE's the value of a variable into the space occupied by the literalline number part of a'RESTORE' statement lN THE BASIC PROGRAM.This explains the existence of the first few lines of the program' For

example, to'RESTORE'to line 37Ø, AKS would perform'lin:37Ø:GOSUB

71

Page 81: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

2Ø:REM *restorelin*'. This fudge routine is placed at the front of theprogram along with comments giving a warning of the dangers inherentin this technique. Obviously, changing this routine will result in thewrong part of the program being altered and may corrupt the code.Things are further complicated by the fact that the 'RESTORE' state-ment's line number must be set to a non-existent line number beforeattempting to 'RENUM'ber the program. The small 'ENTER' key is pro-grammed to do this. AKS requires the 'DATA' statements in the scenarioto be numbered in increments of the constant 'lineinc'. The normalvalue of 'lineinc' will be 1Ø - which is the default line number incrementused by Basic'RENUM' and'AUTO'.

ln addition to knowing the line number increment, AKS must knowthe line number of the first 'DATA' statement of the scenario definition.It is unreasonable to expect a programmer working on AKS to find thisout and set a variable to the value everytime he adds a new line ofBasic. For this reason, a second 'dirty technique' is used. Ïo find thisvalue, AKS jumps to a purposely included invalid program line thatimmediately precedes the first 'DATA' statement of the scenario defi-nition. AKS traps the error generated using 'ON ERROR..' and assigns'datastart' the line number of the line after the invalid line (i.e.'ERL + lineinc'). Although not as dangerous as the firsT'dirty technique',this technique is also heavily commented.

72

Page 82: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

12STRUGTURATOVERVIEW OF AKS

The overall structure of the AKS driving routines can be broken downinto six different sections, which we will consider and briefly outline tnthis chapter. ln order to understand how the routines work in detail,you are advised to study the full listing of AKS in Appendix A, as it isfully commented, with meaningful variable and routine names. To detailthe program within this section, in the same way, would simply duplicatethe information in the Appendix. This chapter is merely considering thestructural elements of AKS, and the way these elements relate to theoverall program.

INITIALISATIONThe first stage of the program requires it to initialise all the variablesit is going to use. This is done by the three routines lnitlocations,lnitobjects, and lnitevents, As their names suggest, they initialise allthe variables associated with the locations, the objects, and the eventsrespectively. We'll look at each of these separately.

lnitlocationsThis routine starts at the beginning of the data, with location Ø, and

it searches through the data, until it encounters a data declaration foran object, event or the F end marker. While it is scanning through thesedata declarations, the location numbers declared in the "L, < locnum >"command are noted, and any missing or out of order locations arereported. The array element "locline(loc)" is set to the program line atwhich the data for the location "loc" begins. This process of scanning

73

Page 83: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

continues until a non-location declaration is found, at which point"nooflocs" is set to the number of locations found, and the routinereturns to the main initialisation.

lnitobjectsThis routine works in a similar way to lnitlocations, except that it dealswith Objects, and it scans until it finds a declaration for an Event or the"F" end marker. During this scanning process, the array element"objline(obj)" is set to the data line which begins the declaration forthe object "obj", in the same way as "locline(loc)" is used. Any out oforder, or missing object numbers are reported by the system, and thescanning is stopped.

This initial scanntng process also allows us to find the start locationsfor each of the objects and to set their position in the "objloc(obj)"array where all the object positions are stored. When the scanningsearch for objects has finished, the "noofobjs" can be set, and theroutine returns to the main initialisation section.

lniteventsThis initialisation routine deals with any events which may have beendeclared at the end of the data block, and sets the array "eventlin(cnt)"to mark the data line at which each event begins. The search for eventsfinishing when the "F" encj marker is encountered.

After initialising the locations, objects and events, all the programflags are initialised by Resetflags, which simply sets all of them to thevalue FALSE. This then completes all the initialisation the program hasto do.

MAIN PROGRAM LOOP

This is a very simple WHILE loop, which runs continually until the flag"eogame" becomes TRUE, whereupon the game ends. This flag isobviously only set by the player losing, winning or quitting the game.

Thus, the loop consists of five different operations:

(a) Describing the current location,(b) Noting that the current location has been visited.(c) lnputting a command from the player.(d) Processing this command line.(e) Updating any countdowns r,vhich are currently active.

The second action is simply a case of setting a flag corresponding tothe current location in the visited array to TRUE, which is very straight-forward. The other routines are a little more complex, so we will considerthese separately.

74

Page 84: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

DESCRIBELOCThis is the routine which prints out the appropriate description for thecurrent location, in a neat and formatted form. The first step is to findthe data line at which the player's current location is defined, and thento call Describeln, to print out the current description. We then test tosee if any objects are at the current location. lf there are objects here,we search through all the objects, printing out the object descriptionsfor all objects at this location. This done, we return to the main loop.

DescribelnThis routine searches through the data statements for the current lo-cation, looking for description data (beginning with a "D"), until itreaches the start of another location, object or event. Once it finds aline of description, the condition attached to that description has to beevaluated, and this is done with a call to the expression evaluator(which is covered in great deta¡l in the next chapter). lf the conditionevaluates to TRUE, we can then print the description by calling Print-descr, and carry on searching for the next one.

PrintdescrThis is the routine which performs the actual act of printing the locationdescription to the screen. This is not a simple matter of printing out thetext in a straightforward fashron. lf we did this, some words wouldoverlap the edge of the screen, being split across two lines. This wouldnot only be diff icult for the player to read, but it would g ive ou r adventuregames a very untidy, messy appearance. A lot of the appeal of theadventure game is the way in which it is presented to the player. Aslapdash, untidy presentation only a discourages the player from botir-ering with the game.

The printdescr routine gets around this problem by making sure thatwords are not split over two lines, and that punctuation is not put inat the beginning of a line. This is done by taking the description stringa screen width's worth at a time, e. g. if ou r screen width is BØ characters,and we have already printed the first 1Ø characters on the currentscreenline, we consider the next BØ characters of the description. Thisis then checked to see if the end of the string occurs in the middle ofa word, if it does, we search backwards through the string to find theend of the previous word. The string can now be printed up to thatpoint. We then consider the next BØ characters from this point and soon, until the string left is less than (or equal) to the screen width whenwe simply print it, and return from the routine.

This printing routine is very general-purpose and not just specific tothe AKS program, so you could easily use it to present neat, word-wrapped output in your own programs.

75

Page 85: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

GETCOMLINEThis is a very short and simple routine, which prompts the player withthe question "What now?". The player's command line is then input intothe variable "in$". Obviously, we cannot provide for all the possiblecombinations of upper and lowercase which the player might type in'so we use LOWER$ to convert the input string to be totally lowercase.This does mean that all the commands, and object name which youinclude in the object and location declarations must all be in lowercasealso. But, this is small price to pay in return for faster processing of thecommand line.

PROCESSCOMLINEThis is the most important routine in the program, in many ways, as itchecks the player input against the database and causes actions tobe performed if matches have been found. The first stage is to searchfor triggers in current location, and then in the global location; matchingthe input string against the trigger phrases. lt is worthwhile noting at

this point that it is important to order trigger phrases in the correctorder - substrings after the main string. By this, we mean thal "FEED

THE DUCKS" should come before "FEED", "WIND UP THE CLOCK"should come before "WlND UP" and so on. lf you fail to do this, then

the main phrases will never be activated, due to the search methodthat the Triggertest routine uses. lf no triggers are found then the "Sorry

I do not understand that" message is printed and control returns to themain loop. lf the command is recognised, then the Actions routine is

called to carry out the required action.

TriggersThis routine steps through the current location data (until it reaches anew declaration for location, object or event) searching for Triggercommands. lf a command is found, it is tested by the routine triggertest.

TriggertestThis routine attempts to match the command line with the triggerphrases for the current trigger, This is done by scanning the triggerline until the end marking "." is found, which marks the start of thecondition. A test is made for each of the trigger phrases to see if it

occurs within the command line (using the string function INSTR). lf

a match is made, the condition for that trigger is evaluated. Only ifthere is a match and the condition evaluates to TRUE, is successreported back to Triggers and PROCESSCOMLINE.

ActionsThis routine simply scans down the list of actions which follow a Trigger

76

Page 86: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

command. The type of action is read in, and then the appropriate actlon

routine is called, depending on the action. when all the actions have

been read in, the routine returns to the main loop. Each of these actions

then performs the required tests and manipulations to carry out their

function, before returning to the main action routine. lf you wished to

add more actions to the AKS system, it is simply a matter of addinga new test on "act$" inside this routine's WHILE loop, with a GOSUB

to your new action routine.

UPDATECOUNTDOWNSThis routine steps through all the counters possible and tests to see

if they are currently counting. lf a counter is active, then it is decre-mentód by one, lf ihe counter value is still above Ø, nothing further is

done, and the routine returns to the main program loop.However, if the counter has reached a value ol zero, the counter is

reset to a non-counting state and the appropriate event is actlvated.This is done by setting the current dataline to the start of that event,

and then calling the A-ctions routine to step through and perforrn the

required actions. Once this is complete, the main program loop isresumed.

That completes the rnaìn program structure You should find all the

above routìne descriptions relatively easy to follow, using the comments

in the program as a guideline Many of the routines described in this

chapter ca"n quite easily be used in other programs, not just adventuregames. The pretty priÁting abilities of Printdescr being iust one such

ãxample, along wltii the whole method of data searching employed by

AKS

77

Page 87: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

8L

Page 88: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

13IMPLEMENTINGTHE EXPRESSIONEVALUATOR

The behaviour of the AKS expression evaluator has already been dis-cussed. This chapter explains how the AKS Basic program arrives ata result of true or false for a conditional expression, This descriptionof the expression evaluator will be invaluable should you decide toalter the terminology, ìmplement additional operators or allow the useof further flags and predicates. ln addition, the expression evaluatorin AKS illustrates some fundamental programming techniques and datastructures.

The Basic code corresponding to the expression evaluator is con-tained in the subroutine .evalthis. and the subroutines it invokes. Onentry to this routine, the expression string should be stored in thevariable 'expr$'. On exit, the variable 'res' holds the result of true orfalse. The integer values representing true or false are -1 and Ø re-spectively. This is the same as the internal notation used by AmstradBasic when it evaluates conditional expressions in lF statements. Con-sequently, the AKS program can test the result returned by .evalthis.

as follows:

lF res THEN . . ,

Thus to evaluate an expression, AKS copies the expression string intoexpr$ and calls .evalthis.. Often, the AKS program wishes to read inthe next string and then evaluate it. This is reflected in the presenceof the subroutine .evalnext., which reads the next string in the DATAinto'expr$'and then calls .evalthis. to evaluate it.

79

Page 89: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Considering that the function of .evalthis. is to return somethingwhich can be tested by a Basic lF statement, it may seem pointlessto go to the trouble of writing a conditional expression evaluator to dothe same thing as the existing Amstrad Basic conditional expressionevaluator. Take for example, the AKS condition string (having alreadystripped off the preceding '.'):

-(w3/c3).v12

It is not difficult to see how, by substituting 'NOT'for'-', 'OR' Íor'l' and'AND' for '.', this could be transformed into the string:

NOT (W3 OR C3)AND V12

Now if you replaced all occurrences of sequences of digits by'(', thesequence of digits itself and ')', the resulting string appears to becomea Basic conditional expression:

NOT (w(3) OR C(3)) AND v(12)

Given that the arrays W, C and V existed and contained true/falsevalues (-1 or Ø), it would be very convenient if Amstrad Basic couldthen be made to evaluate this for us. Unfortunately, this information islocked inside a string variable and Amstrad Basic is unable to evaluatea string variable. For example, it is INVALID to write in a program:

lF expr$ THEN . . .

Some Basics have a command to overcome this problem and forcethe Basic interpreter to evaluate a string. A very 'dirty' way in whichAmstrad Basic could be made to evaluate a string would be to convertthe string into Amstrad Basic's internal representation and POKE thisinto the program between an lF and a THEN and then execute this line.However, AKS expressions are variable lengths and so other parts ofthe program would need to be adjusted to create exactly the rightnumber of spaces between the lF and the THEN. An alternative methodof evaluation must be used.

Therefore, the AKS program is forced to do a step by step evaluationof 'expr$', lgnoring the trivial case of 'expr$' being just '*' where*evalthis. returns true, the evaluation process can be divided into threestages:

1. Substitution of flags and predicates (eg. C3,W3,V12) in expr$for 't' or 'f' representing their true or false values.2. Reorganisation of the expression according to operator priorityand bracketing (ie. '-' before '.' and '.' before '/' unless bracketsdictate otherwise). The now redundant brackets are discarded.3. Evaluation of operators and their't' and 'f'operands in the orderestablished in stage 2.

BO

Page 90: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Although the evaluation takes place in three logical slages, in practicestage 1 can be performed during the same scan through the expressionstring as stage 2. A brief glance at *evalthis* reveals that it has twosubroutines performing the three stages:

1 . *converttoRP. - stages 1 and 2.

2. *evaluateRP. - stage 3.

The letters 'RP' stand for Reverse Polish. An expression written inReverse Polish notation requires no brackets or operator prededenceas the ordering of the expression precisely represents the order ofevaluation. To achieve this, Reverse Polish notation places an operatorafter its operands, giving rise to the alternative name of postfix notation.The normal notation used in mathematics and Basic is called infixnotation and places an operator in between its operands. The scenariowriter is allowed to write AKS expressions in infix notation for the sakeof readability. lt would be unacceptable to force the scenario writer tolearn Reverse Polish before he could use AKS. However, anyone whohas done a lot of programming in the language Forth, which usesReverse Polish all the time, may be happier writing expressions inReverse Polish. lf this is the case, the *converttoRP. subroutine canbe replaced by a subroutine which just performs stage 1 of the eval-uation process. A slight increase in the execution speed would alsobe achieved. To help convince you to stick to infix notation, someexamples of infix AKS expressions and their corresponding ReversePolish versions are given below:

INFIX REVERSE POLISH

w3/c3-(w3/c3)-(w3/c3).v12(c1 .c2y(c3.c4,c5.c6)

w3c3/w3c3/-w3c3/-v12.c1c2c3c4c5c6 .../

The subroutine *converttoRP- converts the infix expression held in'expr$' into the Reverse Polish equivalent which is returned in 'revpol$'.It repeatedly calls *getlex* to get the next operator or operand from'expr$'. lt is the subroutine *getlex. which performs the substitution offlags and predicates for either't' or 'f' to perform 1 of the evaluationprocess. When -getlex* encounters an operator (ie. next character is'l' ,'.' ,'-' ,'(' or ')'), it simply returns it to *converttoRP. in 'dat$'. However,if it encounters a flag or predicate (ie. next character is 'F', 'V', 'W', 'C','L' or 'O') then it calls .evalflag. to determine a value of true or falseand set'dat$' to't' or'f' accordingly.

Having performed stage 1 of the evaluation, .converttoRP* mustreorder the lexical units returned by calls to *getlex* to form ReversePolish. There are several algorithms which could be used to do this

B1

Page 91: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

reordering and removal of brackets. All of these algorithms require ameans of determining the priority of operators shown below:

OPERATOR PRIORITY

highest

lowest

The algorithm used in AKS is often referred to as the Shunting Algorithm.This name arises from an analogy with a simple railway network, shownin the diagram below.

OUTPUT(REVERSE POLISH

EXPRESSION)

SIDING

Let us ignore brackets for the moment. The algorithm takes carriages(lexical units) from 'input' (infix expression) one at a time. lf the carriageis type-A (operand) then it passes straight across to'output' (ReversePolish). However, if the carriage is type-B (operator) it goes into the'siding'. Each carriage has a priority (operator priority). When a newcarriage approaches the 'siding' it allows carriages already in the 'sid-ing' to go to 'output' one at a time until a carriage of lower priority is

at the front of the 'siding'. The new carriage then takes its place at thefront of the 'siding'. Eventually, there are no more carriages at 'input'and all the carriages in the 'siding' are allowed to continue to'output'.The Reverse Polish expression is now at 'output'. An example con-version using this algorithm is given below. For clarity, flags and pred-icates are shown as therr identifiers instead of their actual 't'or'f'valuesfrom stage 1.

INPUT SIDING OUTPUT

INPUT(INFIX EXPRESSION}

c5.-v7tF4.-v7tF4-v7tF4v7tF4lF4F4emptyempty

emptyc5c5C5C5V7c5v7-.c5v7-.F4c5v7-.F4t

emptyempty

empty

82

Page 92: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

By a simple extension, this algorithm can be made to remove bracketsafier they have served their þurpose. Firstly, the symbol ')' must be

considered as the highest priority operator. when a '(' is encounteredit goes into'siding'o[eying the same rules as the other operators. The

allorithm then cóntinues as normal until a ')' is encountered. This

causes all operators in 'siding' to be released to'output' until a'(' is

reached. This bracket pair can now be discarded. For example:

INPUT SIDING OUTPUT

-(c3/w3).v12(c3/w3).v12c3/w3).v12/w3).v12w3).v12).v12.v12v12emptyempty

c3w3C3W3/c3w3/-c3w3/-v12c3w3/-v12

:emptyemptyemptyc3C3

mpty

(

(-

t(

:

empty

ln computing terms, a structure called a stack embodies the idea

of the 'siding'.-Machine code programmers will undoubtedly be very

familiar with-the operation of the Amstrad's hardware stack. The AKSprogram is unable to use this stack freely because Amstrad Basic is

using it as the program is running. Therefore AKS maintains its ownsoftriare stack. Whétfier it is implemented in hardware or in software,a stack has the same logical structure. There are two operations associ-ated with a stack, adding an item and removing an item. ln ZBØ as-

sembler these operations are known as PUSH and POP respectively.AKS uses somewhat the more readable names of .stack* and *unstack*

for the subroutines performing these operations. The important thing

to remember about a stack isthe Last ln First out (LlFo) rule, whichmeans last item in will be the first item out. This is the reason for theanalogy of the shunting Algorithm where the last carriage in is always

the fir;i carriage out. The internal mechanism by which the status of

a stack is maintained is by a pointer to the next free element of the

stack. The AKS stack elements are held in an array called 'stack' andthe pointer to the next free element of 'stack' is 'stacktop'. At the start

of the program 'stacktop' is initialised to point to the first element of'stack'. Frõm then on, 'stacktop' is only changed by the *stack* and*unstack* subroutines. stacking or unstacking a variable is done by

storing the value of the variable in 'dat' and calling *Stack* or *unstack*

respectively.

B3

Page 93: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Having converted the infix string into Reverse Polish it must be eval-uated. This can be done very simply by the use of a stack. As*converttoRP* has finished using the software stack, .evaluateRP. canmake use of the same stack. The algorithm scans through 'revpolg'one character at a time from left to right. lf the character is an operand('t' or 'f') then stack it. lf the character is an operator then take therequired number of operands off the stack, perform the operation andstack the result of 't' or'f'. The binary operators, '.' and '/' will unstacktwo operands whereas the unary operator '-' will just unstack one op-erand. When all the characters in 'revpol$' have been processed, asingle value remains on the stack. lf this value is 't', 'dat' is set to 'true'otherwise 'dat' is set to 'false'. The expression has now been fullyevaluated.

However, what happens if the original 'exprg' was incorrect? For-tunately, thto be madeof the ex

is method of expression evaluation allows simple checksat each stage of the evaluation process to detect the validityression. Firstly, if any invalid characters (ie. not in "-.1

disit)rough

'ora are included then these are recognized duringthe initial scan th the string stage 1 of the evaluation process.Missing numbers afte r a flag or predicate character (eg. '(C/W3)') aredetected when the evaluator attempts to substitute 't' or'f'for the flag/pledjcate - stage 2. Finally, an incorrectly structured expression (eg.'(C3/W3)V12') will be detected after the Reverse Potish eipression hatbeen evaluated because the stack will hold more than just the result

- at the end of stage 3.

84

Page 94: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

14EXTENDING AKS

While the basic AKS system does provide a complete adventure gamegenerator, and one which can be used to create some very complexand large adventures, obviously there are additions which could bemade. Everyone has their own ideas for adventure games, and for thetypes of actions and situations they would like to include in their owngames. ln this chapter we will detail some of the additions we havethought of, as well as methods for adding your own additions andextensions to the basic AKS format. We hope that you will experimentwith AKS, and add your own new actions, commands and so on; youwill learn a lot more about programming and adventure games writingin this way than from any commercial games designer.

EXTRA ACTIONS

This is the simplest addition to AKS, and the easiest to carry out. Theactions included in the basic system cover all the usual adventuregame requirements, but you may well wish to add other actions whichcannot be constructed from several existing ones. Possible new actionsmight be EAT, DRINK or even SLEEP! These can be fitted into thesystem by inserting a new subroutine which deals with the objects thenew action affects. This new subroutine is then accessed by addinga new line into the Actions routine, which tests "act$" for the new value.An example might be:

lF act$:"SL" THËN GOSUB 6ØØØ : REM .Sleep.

where the subroutine dealing with the sleep action is located at line6ØØØ.

85

Page 95: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

REAL TIME ACTIONAlthough the AKS system already provides a system of counters whichcan simulate a timed event, where the time is measured in turns, thismay not be enough. ln many games, the adventure is played in real-time, with time ticking away between turns (while the player is makinghis decisions and typing in a command) as well as while the computeris actively engaged in processing a command. ln machine code, thisis fairly easy to achieve, using interrupts to update a clock. lndeed,on some machines a realtime clock is provided by the computer'shardware. ln the case of the Amstrad, we are fortunate that the Basicitself provides for interrupts, and allows us to create real time eventsfrom Basic.

The way such a feature could be implemented is to alter the lnitialiseCounter subroutine so that it sets an interrupt timer in progress. Thus,we would use the Amstrad AFTER statement to say that a certainsubroutine would execute after a certain amount of time. This wouldenable us to set an event going, and then the basic hardware wouldinterrupt whatever process was going on in order to execute our eventafter the elapsed time. Once the event has occurred, we can returnto the main program at the point we left it.

It would also be possible to implement an event which occurredevery so often using the basic command EVERY, instead of AFTER,as in the above example. This would cause our event subroutine toexecute at regular intervals, instead of just once. One possible use forthis would be intelligent characters, who could move through the gameof their own accord, with their position updated after every three minutesor so.

The Amstrad manual gives full details of the interrupt facilities avail-able in Chapter 10.

DON'T CARE MATCHESAt the moment, we have to match all of our command input against a

set of trigger phrases, wìth a match for each word in the trigger phrasebeing nðCessary. Wouldn't it be better if we didn't always have to matchevery word, but could just make sure that some of the input phrasewas correct, while not caring about the rest? This is where what isknown as a "don't care" indicator comes in. This enables us to saythat we are not bothered about what value some part of the phrasehas, just that we want that part of the phrase to be present. To add thisfeature to AKS, we simply have to add a "don't care" facility into theroutine triggertest, which compares the phrases with the command lineinput. This could be a symbol such as "Ê", which would represent a"don't care" word. For instance, in:

86

Page 96: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

T,eat Ê,*

we are simply testing to see if the player wants to eat an object, weare not bothered about which object he is trying to eat!

This facility also allows us to set unconditional triggers which willactivate whenever the player inputs a command at their location, re-gardless of what that command is. This is done by using the trigger:

T,Ê,*

which will ignore the player's input completely. This might be usefulif we wish to cause an action the first time the player tries to do some-thing in a location, or perhaps to simulate something like the playerbeing drunk, where it will trap any of the player's inputl

A RANDOM FACTORAlthough, personally, we do not like random happenings in adventuregames, as they can spoil an otherwise excellent adventure by takingaway any skill factor, some people do like them. lf you wish to add arandom facility to AKS, it would be possible by adding the randomfacility to the conditions part of a trigger. Thus, the trigger:

T,jump,.R25

would only happen 25% of the time, where the "R25" condition indicatesthe random 25o/" chance.

SKILLSwith the growth of roleplaying games and the increasing interest in

sueh gamãs, there are more and more adventure gam.es being pro-

duced-whicl-r attempt to emulate a roleplaying game. This means add-ing player character skills to the adventure. ln AKS, this would require

a ðharacter generating section, which would enable the player to createhis charactei. You could then test these skills in the normal conditionalchecks to see if the player is capable of performing an action, or tosee if the player is affecied by an event. Again, skills do tend to addto the random elements in the adventure game, and produce a poorer

adventure in our opinion. There is no way a computer can substitutefor a human games master!

87

Page 97: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

BB

Page 98: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

SEGTIO]I FOUR

WITCH HUNT - ANEXAMPLE AKS

SGENARIO

89

Page 99: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

06

Page 100: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

15WITCH HUNT PLOTDESIGN

Designing the plot for an adventure game is very similar to designingthe plot of a novel. You begin with basic ideas about the situations andcharacters you want to deal with, often just in the form of short, dis-connected notes. These must be brought together, and interlinked, toform a continuous storyline. Within the adventure context, you do nothave to bother quite so much about detail, or even realism, but youare faced with several other problems. ln a novel, the main characteror characters, stick to the storyline you have set out - they don't havea mind of their own; in an adventure game, your central character isthe player, and they can think for themselves! ln this chapter we willbe looking at how an adventure game is designed, and how to developthe basic ideas into a fully-fledged plotline.

The example plot and adventure game we will be considering isWitch Hunt. This is a relatively simple and fairly short scenario whichhas been implemented using AKS. As such, we are able to break downthe whole scenario into sections, and show just how each of thesesections connects with each other and the overall plot. lf you have notyet played through Witch Hunt, and would like to puzzle out the gameby yourself, we suggest that you do so before reading this chapter.The following pages discuss Witch Hunt in detail, and thus give awaymost of the solutions to the scenario.

BASIC PLOT IDEASThe basic idea behind Witch Hunt was to develop a short scenariowhich offered a chance to interact with some characters, and whichhad an overall goal. We also wanted to get away from the very over-worked theme of magicians, knights and dragons - in fact the wholefantasy milieu has been done to death.

91

Page 101: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Thus, we settled on an approximation of Middle Ages England, withthe player's task requiring him to find the identity of a witch in a smallvillage. With both of us being firm fans of Monty Python's Holy Grailfilm this was a fairly natural choicel Once we had decided on the themeof the adventure, we had to decide on some of the basic elements ofthe plot.

The Settingln order to keep the adventure within a reasonable size, and thus keepdown the number of locations, we decided to base the adventure inand around a small country village. Once this had been fixed, it wasimmediately possible for us to work on the map of the adventure game.As the game was relatively small, we needed only show the majorbuildings and sites of interest during the game, thus people's housescould be left out, along with miles of road, fields, etc. This enabled usto produce the map shown in Figure 15.1, which is a rough sketch mapof the area the adventure takes place in. Note, that at this stage weare not bothered about how each location is connected, or what eachlocation contains, just with what locations we have; all the connect¡on,etc information comes later, when we start to produce the actual scen-ario data.

/-

.oO

FIGURE 15.1

92

Page 102: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

The Purpose of the GameWhile we have already said that the player's mission is to find out whichperson in the village is the witch; just how does he do that? We cameup with, and discarded, several ideas before hitting on the conceptused in the Witch Hunt scenario. The player finds a hat which belongsto the witch in question, and thus, he must find the person this hat fits(shades of Cinderella!).

Characterslf the player is looking for a witch in his village, then there must besome inhabitants for him to try the hat on! Thus, we will need somenon-player characters for the player to interact with. Well, we havealready drawn up the map, and this shows a number of importantlocations within the village. Obviously, the owners of the various prem-ises within the village can be used as characters, as this has theadvantage of tying them down to a logical, fixed location. This givesus a woodcutter, innkeeper, blacksmith, priest, goatherd and miller.

The Objects and PuzzlesThe player has to try the witch's hat he finds on everyone in the village,without them realising what he is doing, that is the major puzzle, butthere has to be more than this in the game. We have to introduce somepuzzles (and objects associated with them) that will hinder him in histask, and prevent the player just breezing through the game.

One limitation is to set a time limit on the game - either he solvesthe mystery and finds the witch by midday, or he is burntl This givesthe game a sense of desperation, but doesn't really stop the playercompleting the quest simply and easily. What else is there associatedwith a witch? Black cats, of course, and thus the black cat in the churchyard enters the game. This sets another time limit on the player, butrequires him to solve this puzzle (how to lose the cat, before he isburned as a witch), rather quickly; it also adds extra puzzles whichmust be solved to achieve this aim, Alì these puzzles use the locationswe have already put on the map, and objects which would naturallybe there.

Having developed a few rough ideas for our adventure, we canconnect these into a complete plot, for the whole adventure. The bestapproach to plotting the adventure is to consider the actions the playermust take to solve the game as a short narrative - thus we write themout as a short story. This enables us to spot inconsistencies in actions,and helps us check that it is possible to perform the actions in theorder we require. The plot line for Witch Hunt, our example game iswritten out below:

93

Page 103: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

WITCH HUNT: THE PLOTIntroductionYou are a simple village lad, who works for the local miller, fetchingand carrying grain for him. Your life was reasonably happy and setiled-,very little disturbs the tranquil lifestyle of your small country village.That is, nothing disturbed it until recently; there have been some strangegoings onl The crops have been turning bad, the corn at the mill hásbeen plagued with rats (previously unseen locally) and the goatherdhas vanished. These occurrences would be worrying by themselves,even if they didn't relate to you; unfortunately, the villagers have decidedthat your working at the mill has something to do with the corn, andthe fact you found a secret crypt near the church (and were discoveredthere by the priest) has led them to accuse you of being the witchlYou have protested your innocence, of course, to no avãil, and theyhave given you until noon today to prove your innocence by findingthe "real" witch - if there is onel

PlotThe game starts on the village green, at the centre of the village. Wherecan you go to find the witch, or even to find out if there is one? Thefirst clue comes from the village pond, here you find a smalltoad, whichggems strangely afraid of water! So, you pick up the toad and dropit into the pond, and to your surprise there stands the missing goatherd.He is wet and confused, but manages to tell you that he wãs attackedand turned into a toad in the woods, You also discover that the duckson the pond are guarding something, and they appear to be hungryenough to object to you reaching it,

Once you are in the woods, your surroundings all look very similar,and you find yourself lost. Whilst wandering through the mazeof trees,you hear someone running away from you, and there on the groundis a witch's hat! This must belong to the witch - and you quickly realisethat whoever it fits will be shown to be the witch! you now hav-e a wayof identifying your quarry. You slip the hat onto your own head - itdoesn't fit!

ln the centre of the woods is a small clearing, and here you see thewoodcutter, he is breathing heavily and looks hot and bothered. Heshades his eyes from the sun and then notices the hat you are wearing.Commenting that it will shade him from the sun, he tries it on for sizê

- it doesn't fit him. That is one suspect you can strike off your list.Coming out of the woods, you pass through the churchyârd, and as

you do so, a black cat steps out in front of you. You almost trip overit, but manage to keep your feet, only to find that it follows you. youquickly realise that if the villagers find you with the witch's hai and theblack cat, they are not going to believe in your innocence for very long!

94

Page 104: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

You have to find some way of getting rid of the cat - food seems agood idea, and then you remember the rats at the mill. You will needio catch them, and that will require cheese, so you head for the inn.

Unfortunately, the innkeeper is in the inn kitchen, and he preventsyou from taking his cheese, or his last loaf of bread. Luckily, however,you are able to steal the cheese when his back is turned. So, armedwith some bait you (and the cat!) head for the mill. Once inside, you

can see some movements on the rafters, and dropping the cheesebrings a mouse scurrying down. This you catch and give to the cat,hastily leaving while its attention is diverted! While you are up at themill, you wonder if the miller is the witch - he might have spoilt his

own corn as a coverl When you find the miller he is busy carryingsacks of flour, and he Iooks thirsty and tired. An idea strikes you, andyou fill your witch's hat from the stream, offering it to the miller. He

ihanks you, gruclgingly, and drinks some of the water, before pouringthe resf overhis head. You can see that the hat will not fit him, as he

does this. Another suspect can be. crossed off the list'As the miller takes the hat, he drops a sack of f lour, and you remember

that the inn-keeper wanted one, which would enable you to get thebread to feed the ducks. You head back to the inn, where the innkeeperaccepts the sack and lets you have the loaf of bread. As you leave thekitchen, you notice that the innkeeper is continually running backwardsand forwards between the main part of the inn and the kitchen. Thisgives you an idea for testing the hat against the innkeeper's head. You

óarefully balance the hat on the door between the two rooms, and thencall in ihe inkeeper - the hat falls from the door onto his head! lt

doesn't fit, but he is so furious with you that he throws you and the hat

out of the inn! Ah well, you can't go there again but at least you knowthe innkeeper isn't the witch, as the hat didn't fit him.

The next place to try is the church, where the priest will be. He isn'tin sight when you enter, so you climb the belfry to look for him. Onceby the bell, you cannot resist the urge to strike it, and so you ring thebell. There is a shout below you, and you see the priest run into thenave of the church, and stand looking up directly below you! This is

too good an opportunity to miss, and so you drop the hat, which sailsgently down and over the priest's head. And over his shoulders aswelll You hurry down to the nave and pull the hat from his head, he

seems annoyed and hurries back to the crypt. You follow him, and findthe strange carvings on the floor of the crypt that you saw earlier, aswell as torches lining the walls. Strangely, the brackets holding thetorches onto the wall are made of iron - an expensive method! Thatreminds you - you haven't been to see the blacksmith yet!

The blacksmith is very unhelpful and very unfriendly, when you tryand approach him. Perhaps he is trying to hide something? Like theblacksmith's ducks are? lt is time to find out just what the ducks are

95

Page 105: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

hiding, and so you feed them the bread. They scatter and reveal thegold which they have been guarding. The woodcutter appears andclaims the gold as the money which was stolen from him - obviouslyby the blacksmith! This is a fairly serious offence, and so the blacksmithis put into the stocks on the green.

This gives you the opportunity to try the hat on the blacksmith, nowthat he is immobile, and . . . it fitsl The blacksmith is the witch, and youhave proved your innocence! You celebrate that evening with the búrn-ing_of the blacksmith, glad that it isn't you who is beinþ burnil

Obviously, when you are constructing your own plot lines, you donot need to write them out in such a detailed and structured way asthe one above. That is written out like this, to make it interesting to íeadand follow for other people - you are the only one who has to under-stand your plot notes.

The next stage in preparing your adventure is to go from the plotnotes to the actual data statements required for coding the adventureusing AKS. The next chapter shows how this is done, witn a full breakdown of the Witch Hunt plot described above. lf you study both thechapters together, you will see how a plot idea càn be translated ina straight forward way into AKS statements.

96

Page 106: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

16BREAKDOWN OFWITCH HUNT

This chapter consists of a detailed breakdown of each location, objectand event in the example scenario Witch Hunt, explaining how theycan be implemented using the AKS system. The breakdown consistsof the following:

1) The location map of AKS, showing how each of the locationsis connected.

2) Tables listing each of the flags used, the scores given, thelocation names, and the objects with their start locations.

3) Locations.4) Objects.5) Events.

FLAGSFlag no.

Ø

1

234567B

91Ø

11

Meaning

found hatrung church bellhat dropped on priest's headput toad in pondbeing followed by cathat balanced on inn doorbanned from innfed mousehat full of watergiven miller waterblacksmith in stocksstarted counting game moves

97

Page 107: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

LOCATION MAPFOR

WITCH HUNT

25.WOODCUTTER'S

24.

wooos22.

wooDsWOODS

18.19_

't 3.CHURCH.YARD

11.BELFRY

10.CHURCHNAVE

12.CRYPÏ

9.FORGE MEADOW

8.6.GBEENSOUÏH

PONOK

3.INN

2.INNBAR

t_

GREENMIDDLE

5.

GRAZINGLAND

14.ROAO

4.GREENNORTH

15.BRIDGE

16.MILL

17.STREAM

TWO.WAY LINK

98

+ ONE-WAYLINK

Page 108: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

SCORESPuzzle Score

Trying hat on woodcutter 1Ø

Trying hat on priest 1Ø

Trying hat on innkeeper 1Ø

Trying hat on miller 1Ø

Trying hat on blacksmith 2Ø

Getting blacksmith in stocks 2Ø

Getting rid of the cat 1Ø

Freeing goatherd from spell 5Finding gold 5Loading a saved game -1Maximum score is 100 points.lf you save the game, you only get 99 points

LOCATIONSLocation no. Location

Ø

1

234567B

91Ø

11

12131415'16

171B'19

2021222324

global location/playergreen middleinn barinn kitchengreen northgrazing landgreen southpondmeadowforgechurch navechurch belfrychurch cryptchurchyardroadbridgemillstreamwoodswoodswoodswoodswoodswoodsclearingwoodcutter's25

99

Page 109: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

OBJECTSObject no, Object

Ø playert hat2 load3 ducks4 cheese5 bread6 mouse7 bellB goats9 priest

1Ø sack of flour11 woodcutter12 cat13 innkeeper14 gold15 miller16 blacksmith17 stocks

lnitial locationgreen middle (1)woods (23)meadow (B)pond (7)inn kitchen (3)inn kitchen (3)mill (16)church belfrey (11)grazing land (5)church crypt (12)nowhere (-1)woodcutter's (25)nowhere ( -1)inn kitchen (3)nowhere (-1)mill (16)forge (9)green north (4)

LOCATION Ø - THE GLOBAL LOCATIONMany of the definitions in this location will be standard for most AKSscenarios. Commands which are usually explicitly coded in the Basicprogram of other adventure games, such as movement, inventory, getand drop, are defined in the AKS scenario global location. The explicitcoding in AKS is associated with the action (A) statements not with thekeywords which cause their execution. Witch Hunt defines the actionof going east as:

T,e,east,*A,GO,E

This associates the keywords 'e' and 'east' with the action 'GO,E' sothat when the player's command line contains either then word 'e' orthe word 'east' AKS will perform the action of moving the player east.Supposing you wished to adapt Witch Hunt to print ã messaçje on thescreen confirming the action, it is a simple matter to add an extra actionto this trigger as follows:

T,e,east,*A,PR,Going eastwardsA,GO,E

No modification of the AKS program itself is required. ln addition to

100

Page 110: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

allowing modification of the fundamental actions of an adventure gamescenario, actions may be deliberately omitted from a scenario byomitting their definition from the global location,

ïhe way Witch Hunt implements the cat following the player aroundshows the flexibility of AKS triggers. From the above example, it canbe seen that adding actions to triggers allows extension of an action.A brief examination of the Witch Hunt global location definition willreveal that it has two versions of every movement command. Bothversions contain the same keywords but have different trigger condi-tions and actions. The first version will fire when flag 4, the'player beingfollowed by cat' flag, is set to true (ie. '.F4' evaluates to true). Thesecond version will fire unconditionally and so if the first version doesnot fire the second version will. ïhe first version, which fires when flag4 is set to true, results in the player being moved by the 'GO' actionand the object 12 (the cat) being Zapped ln to the player's new location.The second version, which fires when version one fails to fire, just doesa normal move player using 'GO'. To cause the cat to start or stopfollowing the player merely requires setting flag 4 to true or falserespectively.

The global location in Witch Hunt also contains triggers for actionsnot fundamental to adventure games in general but which may beperformed at any location in the Witch Hunt scenario. An example isthe action of eating something. Commands containing 'eat loaf'or'eatbread'will cause 'Yummy yummyl'to be printed and the loaf (object5) to be Zapped Out to nowhere; provided, of course, that the playeris carrying the loaf (ie. '.C5' is true). A similar trigger exists for eatingthe cheese. However, if the player enters 'eat church' then neither ofthese triggers will fire and AKS will reach the 'T,eat,*' trigger and print'No thanks'. The addition of these extra scenario specific commandshelps to give the scenario credibility.

The global location cannot be reached by the player and so requiresno description or connection statements. Triggers which may occurin any location must be defined here. However, remember that triggersdefined in the player's current location (localtriggers) have priority overtriggers defined in the global location (global triggers). lf a localtriggeris satisfied then the global trigger will never even be tested. This isillustrated in Witch Hunt by the global trigger'T,n,north,.'and the localtriggerdefined in location 13,'T,n,north,church,.-F4.012'. lf the player isat location 13 and enters the command'go north'then AKS try tomatch the local tngger lirst. The keyword 'north'will match and so thecondition '.-F4.Ø12'will be evaluated. When this evaluates to false, thetrigger is not satisfied and so AKS continues to try the remaining localtrigger statements; only when all these have been tried are the globaltriggers tried resulting in the firing of the unconditional 'T,n,north,*'. lnthe case where'.-F4,012'evaluates to true, the actions immediately fol-

101

Page 111: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

lowing the local trigger statement are executed and no further triggertesting is done; hence AKS does not reach the global trigger statement.ln this way, the same keyword can be made to have different effectsin different locations. Here, 'north' is made to cause an entirely differentaction in location 13 to the normal global one.

769ø77ørò77tø772ø773ø774ø77ãø776ø777ø774ø779ø7Aøø78t@782ø7t,3ø7841ì7Bãû7e6ø7A7rì788ø7ecø79øø7911â7?2ø793ø7?4ø795ø7?6ø797ø794ø799ø8øøø80t1øBø2ø8ø3ø8ø4øaø3øeø6øeø7û8øBøEø9øatøø811ø8t2øB l3ø814øa 150'E 16øat7ø818ø819ø82øøtjzLø822ø825øa24ø

DATIIDATADATADATADATADATADâTADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATfIDATADATADATIIDATADATADATADATADATADATADATADATADATA

LtØTtnfnorthr*F4

ATGOTNAr¿l r12

Trnrnorthr*ArGlOrN

Trereåstr*F4ATGOTEArZ¡r12

Trereastr*ArGiOrE

TrBrEouthr*F4ArCìOrSArZIrl2

Trsrsouthr*ArGiOrS

TrHrwestrtF4ArGiOrWArZr. t12

Trwrwestr*ATGOTW

Trurupr*F4ATGO,UAr¿l rL2

Trurupr*ATBOTU

Trdrdownr*F4ATGOTDAr2l r12

Trdtdownr*ArCìOrD

TrwearrFut onr*A, PO

TrremovÉrtake off,*ArTO

Trget rtakerpick up rEåtch r*AtGE

T , drop , put i throw t rel eåse | *A,DR

T r ex , exan, exåml ne I I ook at , *ArEX

Tti tinvrinventoryr+A,IN

Ttscoret*ArSC

Trloadr*ArLOAr ISr-l

T , save, *AtSA

Treat breadreåt loå+ r*CsArFRryummy yummy!ArZOrS

Treåt cheeÉer*C4ATPRTFår too nouldy!

Treåtf*

102

Page 112: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

825ø826ø€27ø

DATA A,FRrNo thanks.DATÉì Trfeed catrdrop mouEerreleåse nouser*C6.Ol2DATA ArPRrThe cåt tåkeE both mouse ånd cheese and then runs o{{.DATA A, IS,1ODI\TA llrAFr4rFDATA ArZOr6DATA A, ZOr l2DATA A,HCtODATA Trhitrklll rettåckr*DATA ArPRrSorry, No violence ls allo¡¡ed in thls gäme.

929øe29øB5øø831øs52ø833øE54Cl

835ø836ø637øgSBqt839ø

DATADtìTADATADATADATA

T I show, gi ve I accuse r {eed r *ArPRrNot lnterested.

Trquitr*ArBCAt nu

LOCATION 1 - GREEN MIDDLEThis is the first real game location in the scenario definition. Witch Huntstarts the player off at this location. This location has two descriptiondefinitions (D statements). The description the player is given will al-ways start with the first of these which has no condition attached. Thesecond description is only glven when the player has not spent onegame turn at this location (ie. not visited location 1, '.-V1', is true). Beingas the player starts at this location he will only receive the seconddescription once - before his first move. ln this way, Witch Huntimplements the usual introduction to an adventure game (ie. as thesecond description).

The player is only allowed 100 turns in which to complete Witch Hunt.The counting of moves is done using one of the AKS counters (counter1). When the counter reaches zero event 1 will fire automatically andthe actions defined in event 1 will be executed. These actions aredescribed later in this chapter. However, for a countdown to be started,

the player's first move must result in an initialise counter (lC) action.For this reason ther:e is a trigger for each possible direction of movementfrom this location (N,S,E,W). ln addition to the normal effect of movingthe player (by 'GO,N', 'GO,S', etc.) each of these triggers initialisescounter 1 to 100 (by'1C,1,100'). Although this would have the desiredeffect on the player's first move, if the player later returns to this locationand moves off again then the counter will be reinitialised to'100. Thiswould be fine if you wanted to implement something like a playerholding his breath as he leaves a diving bell and having to return tothe bell within 100 moves or drown, but we don't. Therefore a flag (flag11) is used to indicate whether the initialisation has been done or not.AKS automatically initialises all flags to false (F) at the start of a game.The movement triggers test for this flag not being true (by '.-F11')before firing and once fired they assign a value of true to flag 11 (by'4F,11,T'). Counter 1 will only be initialised by the player's first move-ment as these triggers will never fire again.

103

Page 113: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Travelling east from this location will take the player to location 2

- the inn. The trigger keyword 'lnn' allows the player to enter com-mands.lr-ke 'go inn' or 'enter inn'. However, if the player has beenbanned from the inn (ie. flag 6 is set to T) then the tiigsier 'T,inn,*-F6'will not fire. lnstead, the 'T,e,east,inn,.F6; trigger will fiie and print amessage saying that the player may not enter. The latter is anotherexample of the local trigger having priority over the global trigger.a4uÀ841øgJ42ø

DATA L,1qil! Dr*rIn the niddle of the village green.DATA Dr*-VlrBeyond the north end of-thã grecrn you cânsee your home - the nill. To east is the inn. The churchwherê åll this trouble begån iE to the south. you can hear the goats making goaty noiEes to the west.DATA T, Ínn r*-F6DATA A, GiO T EDATA Tre, east, inn, *p6DATA ArPRrThr innkeeper refuEes to let you enter thei nn.DATA T, e, east t i nn r *-Fl IDATA A,GO,EDATA ATAFTlITTDATA ArICrlrløCtDATA T, n rnorth r*-Fl IDATA A,GOTNDATA AtAFrlltTDATA A, IC, I,1øøDATA Trwrwestr*-F11D/ITA ATGO,WDATA A,AF,11,TDATA A, ICr t, løøDATA T, s, south r*-Fl IDATA A,GOTSDATA AIAF,lltTDATA Ar¡CrltlelclDATA CrNr*t4DAÏA Crgìr*r6DATA CrEr*r2DATA CrWf*rE

443ø844øB45et846ø

447ø848ø849ø85øø851ø852ø8530854ø855ø85åEt8570B5BøBs?øaóøøBA 1ø€j62ø863øEé4ø8ó5øe66ø

LOCATION2-INNBARThe bar in the Melbourne lnn has an unconditional short descriptionand a long description for the first visit to the location implemented inthe same way as for location 1. The long description mentions that thekitchen door is slightly ajar thereby giving a clue to the way of tryingthe hat on the innkeeper. A third description is given when ihe playelhas balanced the hat on the door. Triggers exisfto allow the haito-beplaced on the door and to retrieve it should the player fail to completethe puzzle. Two versions of calling the innkeeper allow him to enter theroom when the hat is either on or off the door (flag S). Notice that theinnkeeper object is never actually moved as the messages displayedmake this seem to happen without having to genuinely move the objôct.When the innkeeper is called and the hat is on the door, the playerdiscovers that the hat does not fit him, gains ten points for solving tiris

104

Page 114: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

a67ø869øsó9ø

a7øø

871øa72ø

ouzzle (bv lncrement score -'1s,1Ø'),

gets thrown out of the inn with

[r," nat änO OanneO from returning (by 'AF,6,T')'

DATA LI2DATA ór*rThe bar in the Plelbourne Inn'ó;ii;{ ol*Ës's"ti {ool ha¡ belanced å pointed hat on topo{ the kltchen door!

oÃra D.+-v2.The lnn lg closed at the ßoment due to the-'Åä*oiåi""ã'=pãtii"c-ã+ tt" ale. The kttchen door çltssliohtlv ajar àt thc :a:¡t end o{ the room'õÁià iruar".,.r hat rput het rplaca |tit tlclpnfe ArPRrYou manage to balanc; the håt on toP ot tntkitchcn door.

DATA AtAFtSTTDATA AIZO,IDATA T,èreast, ki tchen t*FSDATA ArPRrThe h¡t {rll¡ to thr floor.DATA A, ZI t 1

DATA A,AFt5,FDATA AT60,EDATA Trget hðtr+DATA A, ZI T 1

DATA ATAFISTFDATA AtEEDATA T, cal I r Ehout r *-FsDATA Á, PR, 'i The^i nnkeeper ^cones^i nto^the^room r ^but ^:9Fi ng^you-he^Érosses^hl msè1 { ^and^dashes^back-i

nto-thc^kl tchen.'lDATA Trcall rshoutt*FsDATA ArPRrÌhe tnñkeeper pushes the kitchen door openand steps fn the room.DATA ÀrpRrpLoPl The hat lånds on hís head. lt looks Ilke a thinbie on a gtantE head. He throvrs you and your h

873ø874ø875ø87âøa77øa7eøe7iøABøO881øEB2ø883øBB4øBB5ø

886ø8A7ø

EBBO

BB9ø89ø0a91ø892ø893ø894ø895øs96øa97rÐ

at out of. the inn.DATA ll,Isr lQlDATA A,GOtWDATA A, ZI ,1DATA A,AF,5IFDATA A,AFT6ITDATA T, I eaverout t*DATA AtCìOrWDATA CtEr*r3DATA Crl¡¡t*r 1

-.-

105

Page 115: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

LOCATION3-INNKITCHENThe kitchen in the Melbourne lnn is the home for two puzzles - thecheese and the bread. The innkeeper will not allow the player to takeeither of these objects. Provided that the objects are present, localtriggers will trap an attempt to'get cheese' or any mention of the words'loaf' and 'bread'. lnstead of performing the normal get action, a mes-sage is printed telling the player that the innkeeper has prevented hisaction. Both messages contain clues to a way of obtaining the appro-priate object. ln the case of the cheese, the clue is in the words ". . .

openly trying to take . . .". The solution is to not try and take the cheeseopenly - 'steal' it. ln the case of the bread, the clue is in thê words". . . last loaf . . ." and in the fact that on entering the inn bar the playeris told that the innkeeper is broke. Giving the innkeeper a sack of flourfrom the mill allows him to bake some new loaves and so he gives theplayer the old one. This is implemented by the trigger "T,give,. C1 0.05"which may fire when the player is carrying the flour (object 10) andwhen the innkeeper has the loaf to give away (object 5 is at this location).Although dishonest enough to accept stolen flour, he will not be in-terested in receiving money from the player because of the danger ofbeing accused of stealing the woodcutter's gold.

DATA L,3DATA Dr*rKitchên in the helbourne.DATA Dr*-VSr¡t seens surprisingly enrpty. Perhåps the innkeeper fs a little short o{ money at the nonent.DATA Trsteal cheeser*DATA AtBEDATA Trcheeser*O4DATA AIPRIGET OFF t'lY CHEESE! What do you meån openlytrying to take ny {oodl

E9Bø899ø1øøø

9øtø9ø?ø9øsQt9ø4ø

9Et5ø9ø6ø

9ø7ø9ø8ø9ø9ø9tÍiø

DATA T rgi ve, *Cl0l. OsDATA ArPRrThe innkeeper saysr"'Oh^goody^goodyålte^some^more^loaves-now. " and grabs your sack -I^can^bof {lour.

"You^can ^have^th Í E^l oaf . "DATA Arl'1O,5,øDATA A, ZOr lQlDIITA Trloa{ rbrÊådr*OEDATA AtPRTGìET OFF l,lY BREADI Whet do you rneån trying t

?l tøçt2ø913ø

o take my lastDAïA T, I eave,DATA A,BO,WDAÍA Crh¡r*r2

loaf !

outrbarr*

T

106

Page 116: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

LOCATION4-GREENNORTHThe north end of the village green is the location where the game canbe completed. With the blacksmith in the stocks here for stealing thewoodcutter's gold (flag 1Ø is set to T), the hat can be tried on thewoodcutter and found to fit. The final twenty points are awarded fordoing this (by '1S,2Ø') and the player clears himself.

I 14Cr915ø916ø

9t7ø918ø919ø

92øøs2tø922ø923ø924ø925ø926ø

DAÎA L,4DATA Dr*rAt the north end of the village green.DATA Dr*-V4rYou rernember coming here in the påst to throw rotten food (and the odd brick) at people ín the stocks. This is where they ålr{åys burnt witches. You remember throwing on wood... Those were gÕod tlmes.DATA Trput hatrplace hatrtry hatr*ç1.p¡gDATíì A,PR,It .fits!DATA ATPRtA crowd of villågerE gather. "The^blacksmlth^is^the^witch! " s¡creems the prfest. "Þurn-himl ^Burn^hfm!^Burn^him!". And they do. Everyone haE a real good time... roåsting chestnuts and potatoes in the {íre. You have cleared yoursel{.DATA A, Igr2CtDATA AtSCDATA A, GIU

DATA T rroad r*DATA ATGOTEDATA CrSr*, IDATA CrEr*r 14

þ 'l\t,

LOCATION 5 - GRAZING LANDThis location is a red herring. lt is a very good way of losing bread andcheese to the goats. lf the player is carrying either the cheese or thebread and tries to feed these (or any other object) to the goats thena goat will help itself to either cheese or bread. The order of triggersmakes the goats prefer cheese to bread. ln addition to this, any attempt

107

Page 117: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

to perform an action using either cheese or bread will result in thegoats snatching one or the other.

927ø?28ø92Cø93øø931ø932ø933ø934ø935ø

ATPRIArZO,

T, feedATPRTArZO,

ErEr*t

DATA LtsDATA Dr*rAn åreå of grazing land.

ch€ese r *C4goat ånatches your cheese and eats it.

breådrloaf r*Csgoat'snatches your bread ånd eats lt.

DATA Tr{eedDATADATADATADATADATADATA

tA4Ill5I

LOCATION 6 - GREEN936ø DATA Lr69370 DATA Dr*rAt the southern938ø DATA D,*-V6!A foul odour

the meådow at the west of935ø DATA Ttmeadowr*94øø DATA ATGOTW94Lø DATA Ttchurcht*942ø DATA ArB0rg943ø DATA CrWr*rB944ø DATA CtNr*t I945ø DATA CrSr*rlø

SOUTH

end of the vtllage green.drifts {rom the direction o{the greÊn.

LOCATION 7 - PONDThe water in the pond is stagnant and may not be reached by theplayer. The pond does provide a means of releasing the goatherd fromthe spell which has turned him into a toad. Throwing the toad into thepond undoes the spell and so he turns baek into a boy. Five points areawarded for this and a clue from the boy tells the player to try exploringthe woods. The changing of the toad to a boy is only a change in thedescription of the toad object (object 2) brought about by setting aflag (flag 3) to true. This technique is explained in the description ofthe toad object later in this chapter.

108

Page 118: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Feeding the ducks the bread from the inn makes the ducks move

away frori their nest and reveal the woodcutter's gold. Unlike the toad

to bóy change, the ducks to gold change_ involves a g_enuine substi-tution of objects. The ducks object (object 3) is Zapped out to nowhere

and the golb object (object 14) is Zapped ln from nowhere. The reason

for this aTternatiúe a¡Jpróacn is that the gold object can be manipulatedby the player whereas the boy object can not. were the descriptionswitcf ing technique used here, the player could create strange effectsby referrìng to thb gold as ducks. While not doing any harm in. terms

oí tne sceñario, this would make the game appear rather stupid to theplayer

s46ø947ø948ø949ø

DATA L,7DATA Dr*rAt the edge of the village pond.onrn Di*J.v7rTne poñd ts stagnant ånd smells {oul.OÀrn irput ioaOrårop toadrtñrow toadrrelease toedr*82'-F3DATA A,DRDATA AiPRrsptash... I The toåd turns lnto a small boy'

"þlhere^ám^i?^l¡lhat^hapPened?" he mutters aE he climbs out o+ tr,ã pãna. "Uaãt^ti¡lng^t^remcmber^I^was^strolllng^in^the^woods

! "DATA AtAF,SITDATA A, ISISDATA Tr+eed duck¡feed ducksr*C5DêTA ArPRrTh" ducks gobble up the bread and leave' There was somethlng hldden tn their neEt.DATA A, ZOrSDATA At ZOrSDATA ArZIrl4DftTA Ai ISrSDATA Trf¡ll rwaterrPondr*DATA A,PR,it is ímpossible to get at the wåter,DATA CtSr*tB

95øø9516

9.52ø953ø954ø955ø

95ôA!957ø95BO9s9Qt96øø961ø962ø

109

Page 119: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

LOCATION 8 - MEADOWDATA Lr8DATA Dr*VBrIn the meådow.DATA Dr*-V8,In the rniddle of å meådow. To the north the ground beco¡nes marshy. At the weËtern end {'f the neadow you cen see a ¡looden buildlng.DATA CrNr*r7DATA CrWr*r9DATA CrEr*tó

9ó30964ø9ó5ø

966ø9671Ð96eø

LOCATION 9 - FORGEThe description the player is given on the first visit to this location saysthat the blacksmith is well known for his all round handyman skills. Thismight give the player a clue as to who carved the intricate markingson the floor of the secret crypt.

Showing the blacksmith anything other than gold coins, or accusinghim of something when the coins (object 14) are not carried results inthe player being told to go away. However if the player is carrying thecoins the blacksmith will confess to stealing the woodcutter's gold andis dragged away by the villagers. The player is not told where they takehim - to the stocks on the north of the green (by'MO,16,4'). A ftagis set (flag 1Ø) to indicate that the blacksmith is in the stocks. Twentypoints are awarded for completing this puzzle.

DATA LrgDATA Dr*rAt the blacksmith's {orge.DATA Dr*-V9rYou remember coming here often in the påst. The blacksmith always repairs everyone:l tools. He is apretty good all round handyrnan.DATA Trshow goldrgíve goldrEhor.. coinsrgive coinsreccuËÊr*Cl4DATA ArFR,The blacksmith bursts lnto tears. ,'Alright.-I^con{ess^-^l^stole^the^woodcutter's^gold.', he blurts out.DATA ATFRTA crowd o{ villegers ruÊh up ånd dråg the pleading blåcksmith aþrey.ÞATA A, IS.zQl

969ø97øø97tø

972ø

973ø

974ø

975ø

.:¡ti.::,1

110

Page 120: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

976ø977tÐ97tlø979ø

DATADATADATADATA

9Êøø DATA

ArAFr 1øArMOr 16

TrshowrgArPRrHe

crEr*rB

T4ve, accuse r{orge, anvi l, *shouts I'Bs^of.f ¡with.you! ^Llttle^witch. ".

Ii

I

LOCATION 1Ø - CHURCH NAVEOnce the player has managed to get the hat to land over the priest'shead and shoulders as described in the next location explanatíon, thehat must be retrieved. The trigger which traps the keyword 'hat' whenthe hat is on the priest's head Zaps Out the priest (object 9), Zaps lnthe hat (object 1)and then does a Get to pick it up.

æ

DATA L, TøDATA Dr*rIn the church nåve.DATA Dr*-VlOrThe Eecret entrance to the crypt you found lies open. High åbove you is the be¡{ry balcony. The {ront door is to the north. In the Eouth wall is a smalldoor.DATA T,hat, *F2. 09DATA ArFR,Tug...DATA A,ZI,IDATA ATAFT 1 tFDATA Ar ZOr9DATA AtGEDATA ArPRrThe priest storms o{{.DATA Trcrypt,*DATA ATGOIDDATA Trbel{ryt*DATA AtG¡OtUDATA CrNr*rêDATA CrSr*r 13DATA E,Dr*rl2DATA CrUr+r1l

981ø9426983ø

984ø985ø986ø9tJ7ø988ø949øs9øø991ø992ø993ø9940995ø956ø997r4998ø

111

Page 121: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

LOCATION 11 - CHURCH BELFRYThe puzzle at this location is a two stage one, given that the player hasalready found the hat. The first stage is to ring the bell which causesthe priest (object 9) to come from the crypt and stand in the nave(location '1Ø) directly below you (by'M0,9,1Ø'). Setting flag 1 to truecauses the priest's description to change to say he is looking up at thebelfry. The second stage of the puzzle involves dropping the hat fromthe belfry onto the priest's head (indicated by setting llag 2 to Ï) toreveal that it is too large for the small priest and gain ten points. lf thebell has not been rung when the hat is dropped (flag 1 is F) then it justfalls onto the nave floor, as a result of the second 'drop hat' triggerstatement.

999øtøøøøLøøIøtøø2øLøø3Tìtøø4øløø5ø

Løø6øløø7ø1øøBCt10ø9øtøtîìtì

DATA L, I IDATA Dr*tIn the belfry.DATA Dr*-VtlrFar below you côn see the church nave.DATA Trrlng bell

'*-(FllF2)DATA ArPRrTtre bell tolls and nearly deafens you!DATA AtNOr9r lgtDATA ArFRrYou see the prlest run into the church dfrectly below you.DIìTADATADATADATADATAr theDATADATADATADATA

ArZOrlTrdrop hat¡throw håtr*Cl.-F1

112

ArAFrlrTT'ring bell t*ArPRrDing dong... !

Trdrop hatrthrow hattArPRtThe håt droPs +

priest's head.Ar ISt 1e'ArAFr2tT

*c1.F1roo the belfry and lands ove

tø1 løLø12ø1ø 13ø1ø14ø

Page 122: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

lø15øtøtéøtø17ø1øIBølø19ø

DATADATADATADATADATA

ArFRrlleeee.... it falls from th€ belfrey.Arl.lorlrlCl

T, nave, I eave t *Ar60rD

crDr*t1ø

LOCATION 12 - CHURCH CRYPTThis is the location discovered by the player (before the game started)and where he was caught by the priest. The function of the crypt in

the Witch Hunt scenario is to provide the player with clues to the identityof the witch, without providing any hard and fast evidence' The cluesare obtained by examining the location. Examination of the markingson the floor reveals nothing of their meaning but the player is told thatthey are well carved. When the player first visits the blacksmith, he isreminded that the smith is well known for his all round handyman skills.This clue is a little vague whereas the clue given by examining thetorches on the wall is very informative. Just mentioning torches saysthat they are firmly attached to the wall by brackets. The unwary playermay tak-e this to only mean that the torches may not be taken. However,this should prompt the player to examine the brackets and discoverthat they are made of iron. This points very strongly at the blacksmith'sinvolvement. Notice that the markings, torches and brackets are notobjects and so their examination requires explrcit triggers in the cryptlocation definition; whereas objects have their examination detailsembedded in the object definition.

lø2øø DATA Lr121ø21ø DATA D,*rIn thr Eecret crypt.tø22ø DATA Dr*-Vl2rThe air iE icy cold. The floor is intrica

tely carved with strange narkings, On the v¡al1 are lit torcheE.

lø23ø DATA Trtorchesrtorchrwall rwållsr*1ø24C1 DATA ATPRTA couple o{ torches are firmly attatched to

the wall by brackets.1ø29ø. DATA lrbracketrbracketst*1ø2óø DATA ArPRti¡Llst plain iron bracketg,1ø27ø DATA TrfloorrmarkÍngsr*¡ø?8ø DATI\ ArFRrYou cån ñåke no sense of the markings but y

ou c¿ln see they åre well carved.182?ø DATA1ø34}ø DATAIø3Iø DATA

Trlnaver*ATGOTU

crur*r1ø

113

Page 123: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

LOCATION 13 - CHURCHYARDWhen the player goes north from here he trips over a black cat whichwill then follow him around for 20 moves before a crowd of villagersnotice he has a black cat familiar and decide to burn him. The countingof moves is done using counter Ø and the villagers burning the playeris event Ø.The localtriggerwhich traps an attempt to move north startsthe countdown by the action 'lC,Ø,2Ø'. ln addition to this, a flag is setto indicate that the player is being followed by the cat (flag 4). Thisprevents the same trigger from firing again when the player tries to gonorth again and it allows f iring of the alternative set of movement triggersdefined in the global location. These alternative movement triggersmove both player and cat. The way in which the player may get rid ofthe cat is described in the explanation of the mill location definition(location 16). lt should be noted that the cat will appear again shouldthe player return here and go north again after having got rid of thecat at the mill. However, the objects to get rid of the cat have beendestroyed (Zapped Out to nowhere) at this stage in the game so thecat can not be disposed of again.tø5.2ørøs3ø1034ø1ø35ø

ere !

1ø36ø DATA1637ø DATA

DATA L, 13DATA Dr*rIn the churchyard.DATA Trdl g, graverheadstone;tombt*DATA AiFRrCareful... they bury grave robbers åround h

T rn, north r church r *-F4ArPRrYou trip over å blåck cat which appears {ro

m behind a headgtonel1elsBC!I ø39øt.ø4øø1ø41øtø4210I ø43øLø44øI ø45ø1ø460

DAfêDATADATADATADATADATADATADATADATA

Ar¿l tL2Arl\Fr4rTA rrc tø 12ø

Trchurchr*ArGìOrN

114

Page 124: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

tø47øIø48øtø4?ø

LOCATION 14 - ROADTo prevent the player wasting many hours trying to give a hat full ofstream water to characters other than the miller, a local trigger will fireas the player moves westwards carrying the hat of water. This triggertells the player that he tripped and spilt it. The flag indicating that thehat is full of water (flag B) is reset to F; thereby emptying the hat.

DATA LI 14DATA Dr*rThê roåd.DATA Dr*-Vl4rYou know this road u¡ell. To the north itpåsses by the mÍll on its way to town.DATA TrwrHestr*FBDATA AIPR,u¡HOOPS! You tripped and spilt the wåter.DATA A,AF,g,FDATA Trfollow roådrålong roadt*DATA A,GOINDATA CrWr*t4DATA CrNr*r l5

LOCATION 15 - BRIDGEThe player may not fill the hat at this location. lf he attempts this thenthe trigger will say that he is unable to fill it here. A careless adventurermay take this to mean that the hat may not be filled instead of 'not filledhere'.

DATA LDATADATADAfAe.DATADATA

165øøl ø51øLøá2øtø53øtø54ølø55øtø5éø

tø57øletsBøt ø59øLø6øø

1Cr6l0ttø62ø

ctsr*rl4crNr*r1ó

IDT

15r*r0n å brldge over å stream.,water,streåm, f i I I I down, d | *ArPRrThe stream ls totally inaccessable {ron her

115

Page 125: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

LOCATION 16 - MILLThere are two problems to be overcome at the mill. Firstly, the mousemust be caught. However, the player is not automatically told that thereis a mouse here. lnstead he is told that something is moving aroundin the rafters. Examination of the rafters or listening in this location willinform the player that he thinks that there is a rat in the rafters. lf theplayer then mentions the keyword 'rat' or 'rats' he is told that it is amouse not a rat. These tr¡ggers only fire when the mouse is in the rafters(ie. flag 7 is F). The mouse can be tempted from the rafters by feedingit the cheese or just dropping the cheese. When this happens, thecheese object is Zapped Out (by '20,4') and flag 7 is set to T indicatingtile mouse is no longer in the rafters. The description of the mousechanges as a result of setting flag 7 and becomes a 'piece of cheesewìth a mouse attached to it'. An attempt to get the cheese when flag7 is set to T results in a message saying that the mouse refuses to letgo of it. lf the player has the hat he may catch the mouse in it otherwisethe mouse will slip through his fingers. From hereon the mouse andcheese may be manipulated as one object.

The second problem faced by the player in this location is findingout if the hat fits the miller. This is solved by giving the miller the hatfull of water. He will drink some of the water and then pour the restover his head at which point the player sees that the hat would not fitthe miller. Ten points are awarded for doing this. However, if the playerhas already done this once (ie. flag 9 is T) and tries a second time,the miller just smiles and says go away creep. When the miller tookhis drink, he put down the sack of flour (object 1Ø) he was carryingand did not pick it up again when he started working again. The sackcan now be picked up by the player. Previously, any mention of flouror sacks caused a trigger to fire which said the miller growls at you.

1ø63øla}64atlø65ør86ó0

DAlADATADATADATAonderDATADATA

L,16Dr*rThe nllI.Ttllstenr*-F7ArFRrYou can hear a faint Ecurrying noise. You w

1{ it is a rat.T, råf ters r *-F7tø67ø

1øóBøt is a rat.

Iøó98} DATA TIø7øø DATA1ø71ø DATA TLø72ø DA'TA

tø73ørø7 4øtø7ãø

1ø76øLø77øIATBø

ArPRrSomethfng fs making noises. You wonder if i

tråt rråtsr*-F7ArPRrRat! Påh! I'm a nouse you fool.,{eed mousetdrop chceset*C4ArPRrThe mouse scurrleE down and nlbbles the che

ese.DATA AIAF I7 ITDATA A, ZO r4DATA Trcåtch mouserget mouse¡take mousetplck up mouser*F7.Ê1. - (W1lFB)DATA A, GiEDATA ArPRrYou caught the mouge in the hat.DATA Trcatch nouserget mouserteke mouserplck up mousetrFz

116

Page 126: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

tø7søIøBøø1ø81øLø92øtø8sorø9401ø85ø

rø86ø

DATA ArPRrHe slips through your fingÉrs.DATA Trcheeser*F7. lo,ble6',DATA ArPR.ThÊ Írouee holdq onto the cheese,DATA Tr{lourrsackrgrålnrbågrmlrl rl-FqDATA ArPRrThe mfller growls et youlDATA Trglver*F8.-F9DATA ArFRr "The^mi l ler^puts^the^såck^down r ^takes^the^håt ^ånd ^dr I n ks ^some^water.DATA ArPRrHe says "Ta^Lad." and then pours the rest over his head. As hE doès this you noticc th¡t the hat lstoo småll {or him to wear.

løs7ø1 øEBø1ø89øtøsøølø91øLû92øtø?3ø1ø940

DATADATADATADATADATADATADATADATA

A, I5, løATAFIBTFArZIrlOArAFr9rT

Trgiver*FÊl.FqArPRrHe smiles åñd Eåys "Eio^awåy^creep."

crE¡r*rl5Crl¡¡r*,l7

<

__+_,.__

LOCATION 17 - STREAMUnlike the bridge over the stream and the pond this location allows theplayer to fill the hat with water. To indicate the hat is full of water, flagb is assigned the value T. Should the player be foolish enough to forgetto take the hat off (ie. 'Wf is T) before attempting to fill it, he is toldwhy his action failed.1095ø DATA Lr17109éø DATA D.*,By the stream.1ø97ø DATA Dr*-V17tA loud sploshi

er wheel. The wåter looks as1O9Bø DATA Trfill r*81.-(wtlcó)1ø99ø DATA ATPRII{ you insist.

sound cones fron the watre9h end cleår ås ever.

ng{

I 1øøø DATA ArAFrEfTll0fø DATA Tt+ill hatr*Wltlø2ø DATA ArPRrBargle..,gargle...bubble! You ere unable to

hold your breåth any longer and take your head out of the stream.

1lø3ø DATA T'mill'*t 1ø4ø DATA A r E¡O, El1ø5ø DATA C,E,*r¡ó

117

Page 127: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

LOCATION 18 - WOODS (a)This location is the first WOODS location the player reaches. When theplayer arrives here for the first time, the second description is givenin addition to the main description as a warning to the player.l1øóø DATA LrlEl1ø7ø DATA Dt*rIn the deepI 1ø8ø DATA Dr*-VtErCarefulItø9ø DÉìTA CrEr*r13111øø DATA CrWr*r19

LOCATTON 19..22 - WOODS (b)These locations all have the same description as location 1B makingit difficult for the player to find his way around. To further complicatenavigation of this maze, moving in a certain direction does not alwaystake the player to the next physical location in that direction. Referenceto the location map will quickly clarify this idea.

dårk Hoods,! You mfght get lost.

DATA L, 19DATA Dr*rln the deep dark woods.DATA CrEr* r l8DATA C,Sr*tzQlDATA Crt¡r*r21DêTA L,2øDATA Dr*rIn the deep dark woods.DATA CrWr*r23DATA CrNr*r l9DATA CrSt*r22DATA CrEr*r21DATA Lt21DATA Dt*rIn the deep dark woods.DATA CrWr*tzQtDATA CrEr*t21DATA CrSr*r23DATA L,22DATA DrtrIn the deep dark woods.

1111øLtt2ø1113ø1114ø1115ø1t róøtt17ø111SølI I l9q'tL2øøI LztÍÀLt22øI 125øIt24rDI 125øLt?.6øLt27øLtzgøtt29ø1 130ø

DATADATA

crNr*r20CrErrr23

LOCATION 23 - WOODS (c)This is another location in the maze but, as the player arrives for thefirst time a second description tells the player that he thought he sawsomeone run away. The player finds the hat here.

1131ø DATA L,231132ø DATA Dr*rIn the deep dark woods.1l330l DATA Dr*-VzsrAs you árrived you thought you saw Eiofneon

e r'Lrn ¿rwåy.1134ø DATA CrNr*t2ø1135ø DATA C,Er*r24113êø DATA CrWrxr22

118

Page 128: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

LOCATION 24 - CLEARINGThe clearing in the woods exists to provide the player with a hint forgetting the woodcutter to try the hat on. One part of the location des-cription says that the clearing is sheltered from the wind and the sunseems very hot. Wearing the hat removes this part of the description.The player must be wearing the hat when he first moves south to thewooiJcuiter's house. Seeinþ that the player is wearing the hat, theoverheating woodcutter takes it and tries it on for size to see if it willshade him from the sun. lt does not fit so he replaces it on the player'shead. The player is awarded ten points for solving this part of thescenario.

1137ø DATA L,241138ø DATA Dr*rIn å clearlng in the woodE'113eø Drlrr¡ ,3,1;lhiå.å:oi?"ÀåEi"d {rom the wtnd here and thc

I r4øø Dr*-Vz4rYou hear ¡ loud chopplng sound to thc gou

1t4loLt42ø1r43øLT44ø1 145ø

DATAth,DATADATADATADATADATA

Trsrsouthr*-v25.t¡JlA, rs r 1gtATGOTB

c rw r* r22crst*r25

119

Page 129: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

LOCATION 25 - WOODCUTTER'SThe woodcutter can be found here. Any mention of the woodcutter'shut results in the player being told off by the woodcutter.1146ø DATA Lr251147ø DATA Dr*rThe wood cutter,s hut.1l48ø DATA Trhutr*1149ø DATA ArPRr.The woodcutter bars your wåy. ,,.I ,ve^already

-hed ^rny^gol d^stol en. ^I' m-not ^goi ng ^to^l óse^anytñi ng ^el åe

. ^Keep^out ! "

llSAtCt DATA CrNr*r24

-=:i== - -

OBJECTØ - THE PLAYERln AKS the player is considered to be a special type of object. Theplayer object is defined in a simitar way to ail the othái objects ättnougnany description statements will never be printed by nks. The initialpositio.n.of the player can therefore be defined using ihe position state-ment. witch Hunt starts the player off at location 1-, the'middle of thevillage green. unlike otherobjects, it makes no sense to start the playerobject off at a special location (ie. either location Ø - carried,or location-'1.:nowhere). The p]ayer object may be given names (using the Nstatement) and suitabilities (using the s statements) to allow relerenceto the player character in the gáme. lt makes no iense to allow theplayer to get himself (by 'S,GE,.') or wear himself (by ,S,pO') whereasil ryV be desirable.-to.attow the ptayer to eiamine himsetf (by'S,EX,.,description'). Witch Hunt, howevér, sticks to the more conven_

120

Page 130: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

tional adventure game format and does not implement actions on theplayer by the player.

1151ø DATA Orø1152ø DATA Pr1

OBJECT 1 - HATThe witch's hat can exist in two states depending on the value of the'hat full of water' flag (flag 8). As far as the hat object is concernedthese states are just different descriptions - one for each state of flagB. The hat starts off at location 23 (position 23 -'P,23').

The hat isfundamental to completion of Witch Hunt and the player can get animportant hint by examining it. Note that the hat may not be put onwhen full of water (S,PO,.-F8').

11530 DATA Orl1154ø DATA Dr+-F8ra witch's hat.1155ø DATA D,+FBra witch'E hat {ull of ¡{åter.I 156ø DATA Pr23ll57ø DATA Nrhåtr*1158ø DATA SrEXr*tIt has a label on the inside which såys 'A

Cl4E Witch's Hat - s¡ZE 9'. You wonder who wears a Eize Ihåt I

tl59o DATA SrGEr*116ø0t DATA StDRr*-(FBlCå'1¡61ø DATA SrPOr*-(Fg/C6'11620 DATA SrTOr*

121

Page 131: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

OBJECT 2 - TOADThe toad has two states, toad and goatherd, implemented in an identicalmanner those of object 1. when in the goatherd state (ftag 3 ¡s r) in¡sobject may not be picked up ('s,GE,.-F3'). Names are detiñeo for bothstates to allow the object to be examined in either state. The descriptiongiven depends on the state of the object.I 163øI 164ø1 165øI 1660Ll67øt 168øI 1698It7øøtt7 tø

DATII Or2DATA Dr*-F3ra gnall wart-covered toad.PîIî Pr*FS,å ¡{et end {rlghtancd goet hard.DATA F,EDATA SrGìEr*-F3DATA SrDRr*DATA Nrtoadrboyrherdr*91If StEX'*-¡3r¡ very human looking toad.DATA S'EXr*Fsra very toady loðklng human.

OBJECT 3 - DUCKSThe ducks object can be referenced by the names 'duck' or 'ducks'.It is important not to make a scenario tóo fussy about small details ofthe vocabulgry. ln general a plural object shoulá be made to recðgniseits singular form.

1172ø DATA O,31173ø DATA Dr*rseveral ducks.1 174ø DATA F 17I l75At DíITA Nrducksrduckr*It7óø DATA SrEXr*rThey seem to be sitttng on something.

12

á--

't22

Page 132: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

OBJECT 4 - CHEESE1177ø DATA Or4t178ø DATA D,*ra small plece o+ cheese.r179ø DATA P,5tl8øø DATA N,chee:et*ttBlø DATA SrG¡Er*llB2O DATA SrDRr*118sø DATA SiEXr*rLooks å blt cherEy!

OBJECT 5 _ LOAF11S4ø DATA Or51rB5ø DATA Dr*rå loaf of br.¡d.l1860 DATA Prs1f670 DATA Nrloaf ¡breadt*tr88ø DATA StGEr*11A9ø DATA SrDRr*

OBJECT 6 - MOUSEThe mouse object exists in three states:

1) mouse2) mouse and cheese3) mouse and cheese in hat

The current state and description of the object is controlled by onlyone flag, the 'mouse fed' flag (flag 7). lf the mouse has not been fedthe cheese this flag has the value F and the mouse is in state 1. Onfeeding the mouse this flag is set to T. After feeding the mouse, butbefore picking it up ('.F7.-C6), the object is in state 2. Once the objecthas been picked up ('.F7.C6'), it enters state 3. The sequence oftransitions from state to state is fixed as 1-2-3. This object is known bythe names cheese or mouse. Another cheese object already exists soa condition must be attached to the recognition of the name. The mousemay not be handled before it has been fed; by which time the realcheese object has been Zapped Out to nowhere. Therefore, when themouse has been fed (flag 7 is T) it is valid to refer to the mouse objectby the cheese name. This is implemented by the 'N,mouse,cheese,*F7'statement.

119øø DATA 016llgfø DATA Dr*-FTrsomething movlng around in the råfterç.1192ø DATA Dt*F7.-cérå piece o+ cheesÊ erith å nouse åttatche

d to ft.1193ø DATA Dr*F7.C6rthe mouse and the cheese lñ the håt.II?4ø DATAIT95ø DATA1196ø DATA1197ø DATA

P, 1éNrmouse¡cheeEer*F7SrGEr*EitDRr*

123

Page 133: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

OBJECT 7 - BELLDATA OrDATA DDATA PDATA NDATA Sters'r

7,*ra ¡årgr bregs b:I1.tlt¡bell,*,EXr*rl largc church bell lnscribed wfth the letlng ne!'.

T I9Bø¡ 199øL2øøøt2øtøt2ø2ø

OBJECT 8 - GOATSThe.goats object is a, red herring. Examination of the goats will justconf¡rm the genuine disappearanõe of the goatherd.12ø30 DATA Orgl2O4ø DATA Dr*rå lot of goats.t2ø5ø DATA P,51206ø DATA Nrgoet rgo.rtsr*l2O7ø DATA SrÊXr*rThey are tethcrtd to posts. Btrangel They

seem to have eaten all the good grass they cen reåch. perhåps they have not been mov¡d for a whlle?

OBJECT 9 - PRIESTThe priest may be described as do¡ng one of three things dependingon whetherthe bell has been rung (flag 1) and whethelthe hat ¡s onthe priest's head (flag 2). The sequencã oÍ state transitions is 1-2-3-1.

12øAø DATA O.912ø?ø DATA Ór*-(FtlFz),å very smetl prleet blesslng the secr

et crypt.

'124

Page 134: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

lzloct DATA Dr*Fl.-F2ra very ågltated prlast looklng uP åt the belfrey.

1211ø DAiA DriFzra prlest e¡eårfng e blåck hat over his headand Ehoulders!

1212ø DATA P, l2l2l3ø DATA N'Priest.*iãíõõ oärÀ sJEx'*'¡tÉ looks very anall to vou.

OBJECT 1Ø - SACK OF FLOURNote that the initial pos¡tion is 'nowhere' (location -1)

1ø,*ra sack of flour.

irå.k,uag ¡{lour r*l+,*r*r It is labelled 'Megal'li1I Flour Co. '

1215ø DATA O.1216ø DATA D

12T7ø DATA P12IBø DATA N

T219ø DATA SI22øø DATA S1221ø DATA S

GEDREX

OBJECT 11 - WOODCUTTER

When the player first encounters the woodcutter ('.-V25'), he is given

the first desciiption. lf the player is also wearing the hat (object 1) onthis first encounter ('.-v25.W1') the first two descriptions are given. Thefirst description will appear in the object list, indented as normal' Thesecond description will appear underneath the object list and will notbe indented. În¡s ¡s another way ¡mplementing an event in AKS' Sub-sequent descriptions of this object will only give the third desciiption.

125

Page 135: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

t222ø1223'ø

1224A

t225øt226ø1227øt22Aø

DATA Ot I 1DATA Dr*-V25ran out of br"rth woodcutter rerting on hi!i AXerDATA .Dr*-V2S.WlrSuddenly the woodcutter snatcheE the hat. and trys it on.',t^wonder.i+^thic^wf lf-Ehiã'iã-rã-i.ã,-the^slrn^?" he^ says. ,'pi ty. . . ^not^my^sI zeI', he ;.úbi.;-anct replåces the hat on your heåd.DAÍA Dr*V25rthe woodcutter hard at work.DATA P,25DATA N rwoodcutter, *DATA SrEXr*rA r¡ther hot sweaty woodcutter.

OBJECT 12 - CATt22qø123øø

1231øt2s2ø1233øt234ø

DATA ODATAnkl €s.DATADATADATADATA

t12Dr*F7ra frlendly blEck cat drooling around your å

Dr*-F7ra friendly bl¡ck cat.Pt-lNrcåtr*SrEXr*rIt lookc frlrndly.

126

Page 136: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

OBJECT 13 _ INNKEEPER1255øL23è1àt237øI23Bø1239ø

DATA ODATADATADATADATA

l5,*rthe innkeepcr.

tDFtIN, i nnkeeperSrEX¡*tHe I

,*E råther large.

OBJECT 14 - GOLDDATA O,14DATA Dr*rsome gold colns!DATA P,-IDATA NrcofnstgoldriDATA Sr6Er*DATA S,DRt*DATA S'EXr*rNo. They are not sllced golden egg.ust håvé c(]ñe 'from somewhere eIge.

L24øøt24tøL242øI 24Sø1244ø124Sø1246ø They m

OBJECT 15 - MILLERExamination of the miller will give different descriptions before and afterhe has been given the hat full of water.

1247øI 248ø1249øt25øø125rø1232ø

DATA ODATADATADATADATADATA

t15Dt*tThe niller humping sacks about.Pr 16Ntmlllert*SrEXr*-p9r¡e lookE hot and thlrsty.srExr*FtrHe look¡ wet.

127

Page 137: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

OBJECT 16 - BLACKSMITHThe,blacksmith object may be in one of two states depending onwhether he has been put ln the stocks or not (ie. tøg ñ ¡s i or rrespectively).

I 253øI 254øt2s5ø1256ø1237øI25Eø123r]ø

DATADATADATADATADATADATADATA

or16Dr*-FlOrThc btecksmith hard at work.Dr*FlOrThe btàcksmith tn the

"tããtã.Pt9Nrblacksmithrsmfthr*!rEXr*-F1ørHe looks råther hot.SrEXr*FlørHe looks gtuck.

128

Page 138: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

OBJECT 17 - STOCKSThe stocks have no function other than as something for the player toexamine. The description given depends on flag 1Ø in the same wayas object 16.

tzaøø oArA o,tz1261ø DATA Dr*rsone ÉtockB.t2ó2ø DATA Fr412630 DATA Nrstockst+12ó4ø DATA ItExr*-pl6tThcrs ls ¡ br¡ss plrque wlth 'l'lade by

OXO' engraved on tt.1265ø DATA SrEXr*Fl0rThere ¡rême to be a blacksmith ln theml

EVENT Ø

The actions in this event are executed when counter number Ø reacheszero. These actions kill the player because he has been followed bythe cat for too long. The final score is printed and a quit actioned.

1266ø DATA ErøL267ø DATA A¡PR¡"^"t26Bø DATA ATPRtA crowd o+ villagers gather round you. The p

riest points at the cat and sayg "Look^hé^håã^å^black-clt^{amlliar!^That^proves^he-is-a^wltch. ". They draq you away end test your lnflammabillty.

1269ø DÂTA A,SCt27Oø DATA A,OU

EVENT 1

This event fires when counter number 1 reaches zero indicating thatthe player has had 1ØØ game turns. This is used to represent themidday deadline for the player clearing himself of being a witch. Theoptimal solution to the game requires nowhere near 1ØØ game turns.

l27lø DATA ElT272ø DATA A

I agersoccåsi

1

1273ø DATA A'SC1274ø DATA ArSU1275ø DATA F

FRrThe church bell rlngs. It ts midday. The vilIdrå9on ån

you åwåy ånd burn you. lt was å reålly Jollyd people came from miles around to see you.

129

Page 139: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

08t

Page 140: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

APPE]IDIX ATHE AKS ANDWITCH HUNTLISTING

This section contains the complete listing for the Adventure KernelSystem and the Witch Hunt example scenario. The program is over 3Øk

long, so it is a major typing task! ln order to get AKS into your machineand fully functioning as easily as possible, we recommend that youfollow a couple of guidelines. Firstly, leave in the comments and in-

dentation as you type in the program. They may mean a lot more typing'but you'll be grateful for them if you are trying to debug a.section ofcodó! Secondly, pay particular care to the punctuation and format ofthe DATA statements. lf you do find errors after you have typed in theprogram, this is a very likely place for them to occur.

After the program has been fully debugged, then you can removethe REM statements and the indentation to create more space forscenario data. This will also speed up the response time of AKS.

tø2ø5q¡41ò5ø6ø

6BI'0 6øPEKc- 429.lin MoD 256FoKE 43O.lin\25éRESTORE 1øRETURN 'fron *** restorelin ***REM That routine enåbles the program to RESTORÉ to å vårieble vålue'REt'l It does this bv pðkinq the line no' stored in "lin"

i nto I i ne 4Ct.REHREH >>>II'IPORTANT<<<REI4REI'I i) Do not chånqe lines l0l-40.REH ii) Do not use the nornal RENUI'I command'REt,l inste¡d - press the (ENTER) keY on the nunerickey pad.

Bø9øløøItoL21À13ø

131

Page 141: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

l4n15øt60

t7ø18øt9ø2øø2lû22ø23ø23524ø25ø2éø?7ø2732eø29øsøø3lø32ø33ø34035ø36ø37ø38ø39ø4ørÀ4tø42ø43ø44ø45ø4êø47ø486

REHRE},1REMRET4REI,IRE1,I¡

REt4 Iqnore the error messåqe.REMREI'I NB s the Froqrå.n ñust bê RUN to initialise the (ENTER) key...KEY ¡39r"poke 429,O : poke 4S0t.B : renum,,+trHR$(tS)!

REM ******i*t********REM *

REl'l *REI'I *AKS

REt'l*ADvENTURE KERNEL SySTE'RE|4* (AKS)REM *REFI *t*************r*****Ì**********************{.***

*****

was written and developed by : Simon price.I¡TITCH HUNT wes written Jointly by tl''likç Lewis & Simon Pric:.(C) l,li ke Lewis end Simon pricc lgBS.

* * ** * ** ****** *** ******* ** ******* * * ***i******** ***

HODE tPR INTPRINT

'set 4O column 3crcen nodc"!lelcome to AKS.,'! PR INT " Ini ti al i sl nq. , . pl ease wai ti,

49ø5øø5lø521às3054ø

55056ø

671Ð6eø69ø

57ø5BB59ø6øøé10â2øó3ø641Ðé50661ì

!REH declare allDEFINT a-z'

numeric variables as inteqers!REH initiål ise constantsRENlineinc=1O 'BASIC line no. incrementmaxloc=3Ql 'maxinum no. locåtiongmaxobi=28 'måxinum no, obiectsrnåx+låa-sct 'no. o.f s¡cenario defin€åblr f¡egsnaxcount=S 'no, scenårio de+ineåble countersrnåxBtåck=zø 'maxinum sizc o{ expression €våluetor stecktrue--l 'booleån valu¡¡ recoaniÉed by IF etatemcntfå¡ Ee=Qtlinlen=40 '!¡creen width for d?Bcription outputREI',| f i nd vål uÉ o{ the constant 'dåtastårt ,

REI'I ie. the line no. ol the +irst scênerio DATA ståtementflN ERROfì BOIO 57ø 'next but one llnaGi0T0 768ø 'ðn erronrou: llnc lmrnediatrly priccdlng tlrut DATA statementIF ERR(}z THEN ERROR ERR ELSE RESUFIE 59øREFI report tf not expected error typedatastart=ERL+l i nei ntr

ERROR BUTO O 'turn error trapping off

REll initial ise variablesREM

DII'I locline(maxloc) 'line no.s of start o+ obiect DATAdefinitionsGOSUB løBø s REH *initlocations*DII'I obiline(nexobi, 'line no.s of ritårt of locåtion DATA d€finl tions

ON

132

Page 142: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

7fìø71ø721ì7SO

74ø75,ø76ø77ø7Aø

DIll objloc(maxobi) 'initia¡ locetion o+ obiectsGOSUB f32ø ! REM *Ínitobjectg*

DII'l eventlin(mexcount) 'event ¡ction definition stårt Ii nes6OSUB fTlO : REH *initevênts*

DIt4 flag(maxflaq) 'scenårio de{ined +lagEDtl'l worn (noo{ob js) 'ob j€ct worn f I agsDlll vt!3it€d(noo{locs) 'locåtion viÉited by plaver flagsDIll counting(noofcnts) 'countdown ti¡ner on {lagBOSUB f 92O ! REl"l *réËetf lags*

DtM count(noofcnts) 'value of countdown tiner

Dtll stack(måxsteck)'êxpreesion evåluåtion EteckstacktoP=Cl

gcore=ø

REH main program bodyREMcL5eoqeÍre=f ål tset{HILE NOT (eogane)

BSSUE 2ø9ø : REI'I *de5crlbeloc*vi si ted (ob il oc (gl) ) =trueGOSUB 43Oø ! REl"l *qrtcomline*GOSUB 439ø ! REI¡| *processct'nline*GOSUB 479ø : REl"l *updåtëcountdown3*

WENDPRIN'IINPUT "Another gane ?"rres$IF LOtr¡ER$ (LEF"It (res$+"y" r I ) ) r'ryr THEN RUNGOTO lA3ø 'hang machine up

:RE¡l *** initlocations ***RET4I i n=datastartI oc=0ttype$="?r' 'dunmy våtue to force et least one iterationof l,lHILEWHILE lhlsrR 'tYpe$)=oGOSUB ?ø : RË14 *regtt'relin*

READ typeJlF tvpe3r"L" I'HEN 6oÊ¡UB t25ø r REI'I *lnltloc*I inEl in+l ineinc

},ENDnoof I ocs=l oc- IREl'URN

!REl"l *** Ínitloc ***REI,IREAD defloctF loc()defloc THEN PR¡NT"loc out o{ sequence AT LINE "¡lin : ENDlocl ine (l oc) =l in+l i neincI oc=l oc+ IRETURN

79rìBøøBløa2ø83øB4øB5øa6ø87øABøs909øø9lø92rì93ø94ø95øs6ø97ø9Aø99ø1øøøl0lløtø2øl03ølrò4ròlø5ølø6øtø7øIøBølø?øI lø0

ltlElt2øIt30t t4sI l5ølr60ttTrìI tsoI l9øt2øø12tøt22fìI 250t24ø

r 25grl2èøt27û12BO

133

Page 143: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

,29øl5øøl3l øI 52øI 33øI 34ø1 35øI 36etl37Ar,38øI 39øt4øÍò141Ct142øI 430144øI 450I 46øL47A

!REM *** initobjects ***REMob i=ølin=lin-lineinchlHILE INSTR ( "EF" . type$) =OIF type3="Q" THEN ciOSUB 1460

lin=lin+lineincGOSUB 2ø : REII *restt'relin*READ tvpe:l

t¡ENDnoo#ob is=ob i-lRETURN

REH *initobj*

!

REI'I *** initobi ***REMREAÞ defob iIF ob i< )def ob i THEN PRINT',ob i¡lin ! ENDob il i ne (ob j ) =l in+l ineinctyÞe:ü="?" 'drrmmy val rreWHILE INSTR ( "OEF" . type$) =Olin=lin+lineinc

6OSUB 2g' ! REl,l +restorellniREAD type$IF tvpe$="F,, THEN 6OSUB tóSø

t¡JEND

out of Eequence AT LINE

lin=lin-lineinc 'adjust to suitobj=obj+lRETURN

:REM **r+ initobjloc ***REMREAD locIF loc(-l OR loc)nooflocs THEN pRINT.'obJ loc out of renoe AT LINE ":lin : ENDobjloc(obj)=locRETURN!

REI'1 *** initevents ****REMnoof cntts=Ol{HILE type$( >"F "

GOSUB zet : REH *restorelin*READ type$IF type$=',E" THEN GOSUB tBSølin=lin+Iineinc

t¡IENDRETURN

REM *initeventlin*

:

REM *** initeventlin ***REMREAD cntIF cnt()noofcnts THEN pRINT"event out of sequence AT LtNE"¡lineventl in (cnt ) =l i n+l i neincnoof cnts=noof cnts+ IRETURN

I 4BOI 49øI 5øø151øt 520I 53øI 54ø1 55ø156øl57A'1 58øI 59øI 60816lOLé2øI 63øt640

I 65ø1ó6Atl67rì1 68øto9rìt7øøt7tø172øt73øt74øt 7søL76ø177ø1 7BøI79ø1Aøølel øl82rìlg3øls40

! REl,l *initobjloc*

+i ni tob ject e*

I gse)I 86øla7øI gaat

134

Page 144: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

rB9019øø19l øt92rìI 93ø194øI 958196øti7øI98ø19902øøø2øro2ø21'2ø3ø2ø4ø2ø5ø2râ6rb2ø7ø2TÃBø2ø9ø2tøø2l lø2tzÍr2r30214ø2râû

2t6rò2t7rò2TBø2tsø22øø221ø222ø223Íì224tÐ22314226ø227ø22tJø229ø23øø231ø232ø233ø

!REl"l *** reBetf laqs ***REI"IFUR i-ø TO maxflaq

{lag(i)-f¡lgeNEXTFOR i=ø TO noof ob-is

v¡orn ('i ) =f ¡l r¡eNEXTFOR i=8 TO nooflocs

visited (i )o{alseNEXTFOR i=O TO noofcnts

counting(i )-f¡lseNEXTRETURN

!REll *** descrlbeloc ***RE14pn¡¡¡f : FRINT : FRINT STRING*(4Or"-")lin=locline(obJloc(ø) ) ! 6OSUB 2220 r REl"l *dreecrlbeln*lof=66¡foc(ø) ! GOSUB 26Lø 2 REI'I *iEobjåtloc*IF NoT(res) THEN RETURN 'quitFRINT"There islare ¡ "FOR obj=l TO noo{objs--'¡f

oU¡toc(obj)=o¡jloc(Al) THÉN PRINT" "¡ ¡ lin-objline(obj) ¡ BOSUB 222Ø ¿ REll +drscribÊln*NEXTRETIJRN

REl,l *** describelnREI'II i nef eed=trueÊara 227øREtl *** describe ***REHlinefeed=fål5etype:ß="?"'dunrny valuet¡¡HILE TNSTR ( "L0EF'.tYPe:$) =ø

GoSUB 2ø ! REÍ"| *re5torê¡in*READ type$îF tñå;i>"D' IHEN 2340 'qo trv next DATA lineGoSUE 27øø ! REH *evelnext*iF-;;" THEN READ degcr* : EOSUB 241Ø t REI'{ *printdesc

r*lin=lin+lineinc

WENDRETURN

IREll *** printdcscr ***RET,Il¡¡HILE LEN(descr:3) ) linlen-Pog(*Ol+1

rlim=linlen-POS(*Qt)+1 'right hl¡nd tide of screen

2450 rhg-rl im+l '1 char bevond :¡crecn rl

2340233ø2S6ø237ø238ø235ÍÐ24ÍîrÀ24ÚÂ242ø

244ø243ø

shtt¡¡H¡LE l'lID$(descr$.rhs. l) ()" "

rhs=rhg-l 'skip backwårds over rightmolt ¡{ord online

t¡END24èø

135

Page 145: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

247ø24AîÀ2499,

25øø231ø

rhE=rhs-lPR¡NT LEFT$ (descr$,rhs) :IF POS(*ø)>t THEN PRINT .stårt nè¡{start of onedescr$=R ¡GHTf ( descr:ß. LEN (descrrt ) -rhs)!¡HILE LEFTS (descrf , 1)'" ,, .skip over

sdescr$-RIGi{T$ (descr$,LEN (descrt) -t )

h,ENDUIENDPR¡NT descrltIF linefeed THEN FRINTRETURN

Icåding spåc€

!REl.l *** isobjetloc ***REl'Ires=f al seFOR obj=l 'lO noofob-is

¡F obJloc(obJ)=loc ÍHEN rcs=trueNEXlRETURN

IREÍY{ *** evelnext ***REIfREAD expr:3GOSUF 277ø ! REI'I *evålthis*RETURN

!REI{ *** evålthi5 ***RET,Ich¡r$=LEFT$ (expr$. I )IF char$( PRINT"EXPR Êxpècted Al L¡NE ,,¡lin ¡ENDIF LEN(exprlË)=1 THEN res-true ! RETURN ,quitexpr$=RI6HT$ (expr$,LEN (exÞr$) -t )GOSUB 2BBø ¡ REH *converttoRp*GOSUB 379ø : REl"l *evaluateRp*FËTURN 'res is either true/false!REH *+t converttoRP ***REMrevpol:Ë=f rr

dât=ASC GUSUB 412ø ! REM *Btackctet*WHILE LEN (exprS).. )Ct

EìOSUB 3ø5ø : REt't *getlex*__IF INSTR(,,t+',.dåt$)<>ø THEN revpoli=revpotr+dstf ! GOfO 29AO 'next lex

REM dat:' is an operatordat=ASC (dåt$)IF dåt$=,,(,, THEN GOSUB 4lZø : REM *ståckdåt*lF dåt$=,,)" THEN 6OSUB S4Sø ; RÈH *closepar*

. IF. INSTR(,,(),'rdat$)=O THEN GBSUB SS4O I FiEH *66¡¡pE¡spriori ty*WENDGOSUF 343O ¡RETURN

REll *s ! 6ssp¿¡¡!

REH *** qettex ***REM

llne if not et

252ø253ø254ø255ø256ø2ã7ø25Aø2591r26rùø26tø262ø2ó5ø2ê4ø265ø266ø267ø26[Jg,269ø27øø27 tø272ø273ø2749t27gø276ø277ø27AÍÐ

279ø2Aøø2Alø2A2ø283ø2e4ø?85ø286îì2A7ø2BBø2e9ø29øø29tø292rÃ

293ø294ø295ø296ø2979

29êø295ø3Ctøø3øl ø3ø2øSø3O3Ct4ø

136

Page 146: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

3ø5ø3øêø3rò7ø3080

sgt90

3tø03l lø3t2ø3t3ø314ø315ø316ø3r7ø3IBø319ø32ø1ì

321ø322ø

dat$=LEFT$ (expr$. 1 )expr$=RIEHT$ (expr$

'LEN (expr$) -1 )

used=fal geIF INSTR("FVNECLO",dat$)(>0 THEN used=true ¡ 6OSUB 3l5O: REN *evel+lå9t

IF NOT(used) AND INSTR("(,/.-",dati)-O THEN PRINT"invalid expr AT LINE "¡lin: ENDRETURN

!REl4 *** evålfleq ***RE},Inum=01isdigit-true : qotnum=falseI¡IHILE i sdi qi t AND LEN (exprf) ( )O

cher$=LEFT$ (expr3' I )

chval=ASC(cher3)-ASC(ÙO")'convert to digitIF chval(O OR chval>9 THEN isdíqit={alse ELSE expr$=R

tGH'l$(expr3çLEN(expr$)-l) ! nun=num*1Cl+chvâ¡ I gotnum'trueþ¡ENDIF NOI(qotnuml THEN PRINT"Ílag no. nissing AT LINE ";Iin¡ENDGosUB 33Ct0 : REI'I *setbool *IF bool THEN dat:ß="t'r ELSE datf="f "RETURN

IREH **{ setbool +**REI,Ibool =fal geBN INSTR ( "FV[¡¡CLO" 'dat:t) GìOTO 3320r333C1'5348'3350l.53601.337rÐbool=flag(num) : RETURN 'F-{laqbool=visited(num) : RETURN'V-flågbool=worn(num) : RETURN 't'¡-+låqIF objloc(nr"rm)=O THEN boot=true ¡ RETURN ELSE RETURN

'C-f I eqIF objloc(Ql)=num THEN bool=true ! RETURN ELSE RETURN

'L-f I åqIF ob-iIoc(numi=objloc(Ø) THEN bool=tru€ ¡ RETURN ELSE R

ETURN 'O-f I agRETURN

2

REN *** closepär ***REHrel easi nq=truehIHILE rel easi ng

GOSUB 42øø : REM *Ltnståckdåt*op$=CHR$ (dat )

IÊ op$-"(" THEN relÇåslnqEfal¡e ELBE rrvpolt'ravpol!¡+oÞ$t¡IENDRETURN

:REM *** conpareprioritY ***REIInewop=dat 'save new operator codeEOSUB 372ø : REl'l *priortty*r't"rp¡ ¡ =9ppr irel eäsi nq=true

332ø333ø35403S50

3360

3379l

539ø3394t34øø3410342ø343ø344ø3459}34éø347rÐ

325ø324ø325ø3261¿327ràS2Bø329rì330ø331 0

348ø349ø3søo351ø552ø353ø354ø355ø356øs57ø

137

Page 147: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

358ø359ø36øø3é1ø

tdHILE releasing AND stacktop()OGOSUB 42etø 3 REH *unËtåckdåt*6OSUB 372ø : REl.l *priority*lF newpri(oppri THEN revpolr|=revpot'+CHR$(dat) : GOTO

5å5O'nextrel easi nq=f al seEOSUB 412ø ! REM *steckdåt*dåtÊner.rop

WENDGOSUB 4120 r REI'I *ståckdðt*RETURN

!REl,l *** priority ***REMoppri=INST ,CHRf(dat) )RETURN

REN *** evaluåt€RP ***REH¡THILE LEN (revÞol 3, >Ct

dat$=LEFÌ$ (revpot S i I )revpol $-R¡6HT:l (revpol $ r LEN (revÞoI +) -l,IF INSTR("t{",dåtf)<)ø THEN d¡t¡Ag[(drt1¡) ¡ 6OSUB 412

Íl ! REM *ståckdat*IF INSTR("tf"rdåt$)=O THEN GOSUB 3940 r REH *ËvåloÞ*

t¡ENDGOSUF 4lBø ¡ REH *unsteckdåt*IF dat=ASC("t") THEN dat=trueIF dat=ASC("f") THEN dat-falsereB=det 'dat may ålreådy have been booleån (01,-l)IF stacktop<)ø THEN PRINT'Invalid expr AT L¡NE u;lin :ENDRETURN

!REN *+* evalop ***REI,I6OSUB 4lBø ¡ REM *unsteckdåt*IF detËASC("t') THEN opl=tru€ ELSE opl-fàlseIF dat:X>"-'r THEN 4O0lQl 'not e unåry operatordat=NOT (opl )EOTO 4el5ø 'store resultREll binary operåtorEBBSUB 41EO ! REl,l *unståckdet*IF dat=ASC("t") THEN op2=true ELSE op2-falscIF dat:}=".', THEN dat=opl AND op2IF dat:t=',/" THEN detËopl OR op2REl4 store resultIF dat TIIEN dat=AS ELSE dat-AgC("{")GOSUB 412ø : REll *stackd¡t*RETURN

IREll **.* Eteckdat ***RET,Isteek (stðcktop)=datstecktop=etacktop+ tIF stacktoplmaxstack THEN PRINT"cxpr too 1årge AT LINE"¡lin ! ENDRETURN

3ê2Íl563ø364ø36503ó6ø367ø568ø3690s7øø37 tø372ø373ø374ø37eø376ø377ø5780379øSBøO3Stø

342ø3S3ø384ø385ø3S6ø3€J71ù3BAø

349ø39øø39tø5920595ø394ø395ø396ø397ø398ø399ø4ø1Ðø4IìTø41â2ø4ø3ø4Í04ø4ø504øéø4ø7ø4øBø4øqø4 tøø4l tø412ø4r3ø4t4ø

4t5ø4t6ø

138

Page 148: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

4t7ø418ø419ø421òtô42trô

422ø423ø424r¿425ø426ø427ø42Aø429ø43øø43tO432rì433ø4540435ø436ø437ø438O

439rì44øø441ø

!REN *** unståckdåt ***REHstacktop=stacktop- ItF Etacktop<ø THEN PRINT"Incomplete expr: ENDdet=steck (stacktop )

RETURN

:

AT LINE',;IiN

442r¿

REl,l *** qetcomlinGr ***RET4PRINT : INPUT "What now ? ".in*PRINlcoml i ne¡3=LONER$ ( i n$ )

RETURN

:REl,l *** procGlsscornline ***REI,IREI'I remember to ensure that Étrings come before subEtri;;= - eg. "take off" nust be de+íned beforc "take" or itwould never be reached.

tr i g={ al sclin=locline(objloc(O)) : GOSUB 448ø ! REI'I *trÍgS9l:*ir Noiitrig) THEN I inolocl inr(o) ! 6t¡sUB 44Bo : REl'il *trí ggers*IË'NOT(trig) THEN PRINT "sorrv I do not underst¿nd that. " ELSE C¡OSUB 543C1 ! RE1'l *actions*RETURN

!REM *** triggers ***RENtype*="!" 'dummy value¡¡Hit-E ruOr(triq) AND ¡NSTR 'tvpe!})=oEoSUB 2ø : REH *restorelin*

READ tYPe:tIF tvpåi="T" THEN GOSUB 46ø0 r RE¡'t *triggertest*lin=l¡n+lineinc

WENDRETURN

3

REI'I *** triggertest ì**REMnatch=fal setr i gsl eft=truecomíen=LEN(comline:È) : xcomline$=" "+comline$+" " 'constants v¡ithin loopWHILE NOT(match) AND trigsleft

READ trlg$ip terr*(trig$tl)="*" THEN trigsleft=false ! goTo 467

O 'quit looptÉ comlen )= LEN(trig:;) THEN IF INSTR(xcomline$!r (+t

ri g:i+t' " ) < >ø THEN metch=trueWENDhIHILE trigsleft

READ trlqs 'ccrn:¡ume remaining triggers upto exprIF LEFTititrig$, 1)=r'rx THEN trigsleftÉfålse

hIEND

4430444ø445044ârù447ø448ø44qø45øø451ø452ø4S304540455045604571Ð458ø459ø46ørà4âtø462ø

4ê38464rì4650

qé6ÍÃ

467rÐ4êBO469r¿47ørÀ47tø

139

Page 149: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

472ø ¡F NOT(måtch) THEN res={alse ELSE cxprtatrtg$ : BOSUB 2771ì ¡ REH *evalthis*tri q=¡s"RETURN

:REN *** uFdetecount¡16¡¡¡s ***RET,IFOR i=O TO noo+cnts

IF NOT(counting(i)) THEN 48óO 'test next onecount (i ) =count (i ) -1IF count(i)>ø THEN 48óO 'no event yetcount i ng ( i ) =fal selin=eventlin(i) : GOSUB 2ø ! REll *restorelin*GOSUB 5434 ! REl"l *àctitrns*

NEX'TRETURN

:

!REN *** åEsignobj ***RE]'Iobi=l '=¡-rt with first real object (ås obJO is player)

tr i q=¡ 6¡ ="]¡THILE NOT (trí g) AND ob l(¡noof obJ¡lin=obiline(obi)6OSUB 5løø : REll *nernese.rchtobj=65¡*t

WENDIF NOT(triq) THEN PRINT "You cån't do that.,' ! RETURNobj=obj-lGOSUB 52201 : REM *suitåbilitv*IF NOT(res) THEN tri9=ç6¡=" ! PRINT"Thet is npt possible. "RETURN

:REll *+* nemereårch i**REMtype$="?' 'dunny valueWH¡LE NOT(triq) AND INSTR("OEF",type$)-ø

GOSUB 20 ! REH *restorelin*READ type:}IF type$="N" THEN COSUB 46B0 ¡ REì.í *triggerte6t*¡in=lin+lineinc

WENDRETURN

:REIYI *** s'ui tåbi I i ty ***RE},Ilin=obiline(obi)res=f al setypsS="a" 'dummy valuetIHILE NOI (res) AND INSTR ( "gEF,, ,typet) *O

GUSUB 2ø ¡ RElf *restorelin*READ type:;IF type:F="S,, THEN GOSUB SSéO ! RE¡t *suittést*¡ in=¡ in+l íneinc

t¡rENDRETURN

473ø474ø475ø476ø477tÀ47eø4790J48øø48tø4A2ø4S3Cr444ø4e504Séø487ø4ABø489ø49øø4910492ø493ø494ø

49ser496ø497ø498ø499ø5øøø3øløãø2ø5ø305ø4ø

scr5E5øóO507ø5ø805ø9ø5l oEt511@5r2øs13ø5t 4ø5l5At5160317ø5IBø519øs2øo521ø522ø523s524ø52sø526ø327ø528ø529ø53øø531 ø

140

Page 150: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

5S20535ø534ø535ø536ø5370538ø539ø540ø541Oã421ì545ø544øs450346ø347ø54865490

55øø55tø5520553ø554ø555ø356ø557055SO55905óøø56tO36205é3ø5b4ø5ó5ø5ó6ø567ø568ø569ø57øø371ø37?ø5730374rô575ø576Íì3771Ð578ø379ø5Aøø5Stø582ø5S30

REI.IREI"IREI'IREFIREIIRE14REMRE1'IRE]IRE}4RElIREHREt,IREIIRET,IRET,IREHREI'IREM

REl.l **t Euittegt ***REI'lREAD l8ui t$IF suitf=åctsuit:i THEN GOSUB 271Ð6 t REM *evålnext*RETURN

!REl"l *** ections +**REI"Iåctline=lin 'meintåin e tÊperåtË lin for this routineacttype$="?"'dunmy valuet^¡HtLE ¡NSTR ( "TLOEF" recttype$) =O

I in=åctl ine : 6OSUB 28 ¡ REI'I *rêttor.!¡ inlREAD acttvpeSactl i ne=åct t i ne+l i nei nc

'no mc¡rc actfong forIF ecttypef(>¡4" THEN GOTO 57Oøthis trigqer

READ åct3IF act$="SC" THEN GOSUB 5760 t¡F åct:Ë-"IN" THEN G¡OSUB 582O :tF act$="QU" THEN GOSUB 596O s

IF actS="IS" THEN 6OSUB 6O2O ¡TF ECt:}="AF'' THEN BOSUB éO9ø !TF ACt:ù="FR' THEN GOSUB 616ø :IF act$="G0" THEN GIISUF 652O ¡IF âct3="¡4t1" THEN GOSUB 6256 ¡IF åctS="GE' THEN GOSUB 658ø !IF actS="DR" THEN GOSUB é660 !IF ectrß=,,Po', THEN 6BSUB 674ø rIF ¡ct$="TO" THEN GOSUB 682ø t¡F ectS="Ex" THEN EOSUB 69OO ¡IF act$="Ic" THEN 6gSUB ê99O !IF actl="H0" THEN GOSUB 707O :IF act$="zl" THEN GoSUB 7146 ¡IF act$="2o" THEN G0SUB 722O :IF act:t="L0" THEN 6OSUB 73Oø !IF act$="SA" THEN GOSUB 7440 t

I,¡ENDRETURN

!REll *** Score ***REIIPRIN'I "You have Ecored "¡scoreRETURN

*SCore**INventory**oui t** I ncE¡ct're**AsEi qnFl åg**PRi nt**GO**llõveobJ**GìEt**DRop*iPuton**TåkeO+ I **EXåni ne**Ini tcounter**Hel tcounter**Zåp In**ZepOut**LOåd**SAve*

584ø585ø586ø

587058805S9ø59øø591ø

!

REll *** INventory ***REMloc=O r BOSUB 261ø : REll *iBobjatloc*IF NOT(reB) THEN PRINT "You are not cärrying ånything.": l(L lUl(N 'qrrt t

PRINT"You ere cårryinq ¡ rl

FOR obi=l TO noo+obJsIF objloc(obj)(>ø THEN 60T0 59el0 'this obj not cårríe

dPRINT " '' ¡lin=objline(obj) : GBSUB 2261ì t REll *describe*IF worn(obj) THEN PR¡NT" (worn)' ELSE PRIN'I

NEXTRETURN

141

Page 151: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

392ø593ø594Ct595ø59óø3971Ð598ø599øéøøøêø106îÐ2ø603øaD4rÀê05ø6ø6ø6ø7146øAø61ì9øóløø

ållø6t2ø615ø6t 4ø6150ó16øè17ø6IBø679ø62øø62tø622ÍÐ62SO624rð625ø626øó27ø628ø629ø63Ate!ê31ø632øê33øó34ø635ø636ø637Øó38Ct639ø64tàø64tø642îô

!

REll *** QUi t ***.REI,Ie(Jgðme-trueRETURN

!REI'I *Ì* Incscore ***RÊ}4READ inctcore=gcore+i ncRETURN

:REM *** AssignFlag ***RET4READ +lågnurnrboolSIF bool*="T" THEN +leg(flågnum)=true ELSE flåg(flågnum)=f åI seRETURN

:REll *** PRint ***REI.tREAD descr:3I i ne+eed=true6OSUB 241ø ! REI''I *printdeBcr*PRTNTRETURN

:REN *** MOve ***REI,'IREAD obirlocobjloc(obj)=locworn (ob.i ) =f al seRETURN

RElvl *** GO ***REMREAD di r:üI i n=locl ine (oÞjloc (ø) )match=fal setyp€S=ft ?r" durnmy våIueWHILE NOT (metch) AND INSTR("LOEF" !type$)=e,

6OSUB 20 : REI'I *restorelin*READ type$IF tvpe$=r'C" THEN G¡OSUB 648ø r REh *GOz*I i n=¡ in+l ineinc

t¡rENDIF NOT(måtch) OR (nråtch AND NOT(res)) THEN PRINT"YoU can not go that way. "RETURN

:REl"l **r GO2 ***RET,I

r{EAD defdir$IF dir${}defdir$ THEN RETURN 'quitnetrh=trLreG¡BSUF 27øø : REM *evalnext*IF re6 THEN READ objloc(ø)

643ø644ø64506461ì647ø64FJøè49fò65øøê51ø6S2e

142

Page 152: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

é53ø634ø655ø656ø6â7ø65BCl659ø66rìÍò

é610à62ø6é3ø664øé65ø666rÀê67øó680

è69rÀ67ørtr67 Lø672rÐ673ø674tÐ675ø6761Ð

RETURN

:REl'l *** GiEt **+REI,Iåctsuit$É'rGìE" : 6OSUB 494Ø z REll *as:¡ignobJ*¡F NOT(triq) THEN RETUR¡ 'quitIF objloc(obj)=obJloc(ø) THEN objloc(obj)=6 ¡ PRINT "Taken." ELSE PRINT"You can not see it herc."RE]'URN

:REN *+* DRop ***REMactsuit$="DR" ! GOSUB 494Ø : REM *åssignobj*IF NOT(triq) THEN RETURN 'quittF ob!¡oc(obj)=g THEN objloc(obJ)=objtoc(O) : worn(obj)=+ålse ¡ PRINT"Dropped." ELSE PRINT"You do not have it."

RETURN

:REll *** Puton ***REI,Iactsuit'$="FO" ¡ 6oSUB 494ø . REI'I *å33ignobj*lF NOT(triq) THEN REÏURN 'quitIF ob i¡oc (ob-i)=gt THEN worn(obj)'true ¡ PRINT"I'lorn. " ELSE FRlNT"You do not h.vè it."RETURN

:RE¡4 *** Tåkeof+ ***REI"Iactsuit$="TO" : GOSUB 494fÐ t REI'I *rs6ignobj*IF NOT(triq) THEN RETURN 'quitIF vrorn(obj) THEN worn(obJ)ãfål5e I PRINT"RemovÇd." ELsE PRINT"You are not Heàrlng lt."RETURN

!REl.l *** EXeDine ***RElfactEuit$=,'EX', ! BOSUB 4941Ã z REI'I *å3signobj*IF NOT(triq) THEN RETURN 'quitIF NOT (ob-iloc (ob j ) =O OR ob jloc (ob j ) =obJloc (O) )

NT"You see nothinq speciål." ELS€ READ descrl :=true ¡ GOSUB 241ø r pg¡'¡ *printdescr*I i n=objl ine (obj )RETURN

:RElf r** Initcounter ***REI'IREAD cnum.cvåIcount (cnun) =cvalcounting (cnum) =trueRETURN

!REl,l *** HaltCounter *+*REI'IREAD cnumcounti ng (cnltm) ={ aI se

THEN PRII incfeed

ê77ø67ArD679ø6EøSê81ø6s21¿é€366840

6S5ø6eèø687',Íd6880ês9ø69'øø69rø692Íù

693ø6941ùé9566961òo971'è98ø69?ø7rÃÍÐfr7ølø7ø2rì7ø307râ4ø7ø5ø7û6rÀ7ø7ø7øeø

143

Page 153: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

71ã9ø7tøø7Ltø7 t21Ã7t31Ð714ø7t3ø

RETURN

!REH *** ZåpIn ***RE1.,IREAD objob jl oc (ob J ) sobJloc (O)nworn(objlgfelseRETURN

:REf,l **i Zäpout ***REMREAD objobjloc(obj)=-l

nove object to current locatio

'sêt object Ioc.tion to nowhere

worn (obj ) afal seRETURNI

REM i** LOåd ***RE}4BOSUB 757ø : REtl *getfnårnr*SPEED g¡RITE IOPENIN {ile:}INPUT lt9, score, noo{ I oca r noo.f ob Js, nex+ I åg, noof cntsFOR lÊgl TO nooflocs : INPUT lf9,visited(l) : NEXT IFOR l=O TO noofobJs: INPUT T9,obJloc(l).worn(¡) ¡ NEXT

IFOR l-Qt 10 nåx+Iåa ¡ INPUT {l9rfleg(l) ¡ NEXT IFOR l=ø TO noofcnts ¡ INPUT llgrcount(I)rcounting(l) : NEXT ICLOSE¡NRETURN

!REl,l I** SAve ***REI.I6OSUB 757ø ! REI'I *gÊtfnð|ne*OPENoUI +i lclt¡¡RI fE S9 r score r noof I ocs, noo{ ob jE t måx { I å9, noof cntsFOR ¡=Cl TO noo{locr ¡ I{RIIE llgrvlritrd(l ) ¡ NEXT IFOR l=91 TO noo{ob.is : I{R¡TE ll9robjloc (l ) .worn (l } I NEXT

t

7 t6ø7 t71Ã7TBø7 t9ø720rÐ721ø722ri723ø

724ø72=tà726ø7?71ò72SrA729ø73øø73rø732tÐ7350734rL7350

736rÐ7371â

73AO739tô74øtì74tÍÐ742rÐ743rà744ià743rÐ746ø747ø748ø

749ø FOR7Sfìø FOR

EXT7510732râ75307541Ã755073êø757ø

75AO

759ø761ârâ761ø

mexf låq : l¡¡RITE {19,f la9 (l ) ¡ NEXT Inoof cnts t t¡R¡TE ll9rcount (¡ ) ,countinq (l ) : N

CLOSEOUÏRETURN

iREl.l tt* getfneme ***REITIF LEN(comline$)(6 THEN +tle*-"' ¡ RETURN 'defeult naneconllne$=HID$(comlinêS+STRINGI(ló!" ") r6rl6r'l?xtråct

f i I enamefileS=""FOR l=f T0 LEN(comline$) 'remove eny quote marks

IF HtD$(coml inetS,l r l)<>CHR:¡(34) THEN +lIe$Ê+ile$+Þl¡D$ (cornl ine$rl. l) ELSE f ilè¡is+ilct+rr*r'

I =El ïOl=O TOt

7ê21À NEXT I

144

Page 154: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

763tì7641à7631à7ê6ø767ø76tJø7691à77øø77 lø772ø773ø774rÃ77ãø776ø777ø7781ã779ø7eøø7ALÍÐ7e?ø783ø7fJ41â785ø7s6ø7fJ7ø7BB67e9Íô79øø791ø792ø793ø794ø795ø796ø797ø79eø799øB0t6øB0røBø2øaø3øgø4øBel50leø60gø7øBC'BOBø9øBtøøBl toat2øB 1SAtB 14øBr5øBr6øaL7ø8 TBøB l9øa2øoa2løê22rìA2Sø824ø825ø

DAlADATADATADAlADATADâTADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATADA'I'ADAÏADATADATADATADATADATADATADA]'ADATADAIADATADATADATADATADATADATADATADATADATADATADATADATADATADATADATA

RETURN

THIS LINE GENERATES AN ERRORDATA LTø

Trnrnorthr*F4A,GOTNA.ZI,l2

Trntnorthr*A,GO,N'l ,ereðstr*F4AtGO.EAl¿l 'L2Trereastr*ArGìOrE

T r e. Bouth r *F4ATGOTSA.Z¡rl2

'I rãrsouthr*A.60.S'lr¡{rwestr*F4A'GO.t¡¡Ar2l ,12

T¡w,westr*A,

ftuA,

GO, t¡r up. *F4GOrU

A,Zl,l2'¡ ruruPr*

A. GO. UI,drdownr*F4

A.GOTDA,Zl ,12

Trd.down.*A, GO, D

l.wearrput ont*ArPO

T.removerteke of{ r*A, TO

T,get rtåke,pitrk uP rcetch r*A, GE

T. drop r put , throw, rel ea6e. +A, DR

T,ex,exemrexarni ner I ook at r*ArEX

Tri rinvrinventoryr+A, TN

T r score. *A, SC

T. l oad, *A, LOA.IS.-r

l,savet+A. SA

Treat breådreåt ¡oåf r*CSA.PR,yummy yummylArZOrS

Tréåt cheeser*e4A,PR'Får too mouldY!

T,eåt,*ArPRtNo thånk5.

145

Page 155: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

s26øfl271Ã

DATA Tr{eed cat,drop mouserreleåEe mouser*C6.Ol2DATA ArPRrThe cat takes both mouse ånd cheese ðnd then runs off.DATA A,IS,lClDAÍA A.AF.4.FDATA A, ZO,éDATA A.2O.12DATA ATHCTøDATA Trhitrkill,attackr*DATA ArPRrSorry. No violence is åIlowed in this game.

DATA Trshow.giveråccuserfeedr*DATA ArPRrNot interested.DAÍA Trqui t r*DATA ATSCDATA ATOUDA'f A L, IDATA D,*,In the middle o+ the village green.DATA Dr*-Vl.Beyond the north end o{ the green you cånsee your home - the mill. To east is the inn. The churchwhere all this trouble began is to the south. You cån h

ear the goåt5 mäking goaty nolseg to the west.T,innr*-F6

ArCìOrEïrereastrinnr*F6A,PR,The innkeeper re+uses to let you enter the

Trereastrinnr*-F11GiorEAF.ll,T¡c, I , lelgt, north r *-F I I

ArG¡OrNrAFrtlrTr ICr I, lcl0l¡{.r¡eBtr*-Fll,GOrl¡¡,AFrllrT, IC,1, lQlClË. south . *-F 1 I,GOrS

A,AF,11,TA, ¡C, ,lø€l

B2Bøe29øE5øøa3tøB32CÌB33Q'B34A

835øg3óøB37øB3Aø839øB4øøE}4tøF342ø

847ø€4eø8490B5ø0'a5l o852ø853ø854ø455øB56Ct857øasBqtB59qlB6øA)86IB862ø8630aê4øe65øaé6at467øBáBø9690t

443øB44At845Ar846ø

a7øø

87tøEJ72ø

DATADATADATADATAi nn.DAfADATADATADATADATADATADATADATADATADATADAÏADATADAÏAÐATADATADATADAlADATADATADATADATADATADATA

A,A.A,

Ttn

AA

T,AAA

T.A

CrNc,sc.ECrH

**tf*

I4625

L.2D.*.The bar in the I'lelbourne Inn.D,*FS,Some +ool håB belanced e pointed hat on

of the kitcheñ doorlDATA D,*-VzrThe inn is closed at the mornent due toLrnexpleined spoiling of the ale. The kitchen door

sliqhtly ajar at the east end of the room.DATA Trbalance hatrput hatrplace hatr*ç1DATA ArPR.You månåge to bålånce the het on top ofkitchen door.

DAÏA A,AF,5,TDATA Ar ZO, IDAïA T. e. eãst , k i tchrn . *FsDATA A,PRrThe håt fà¡ls to the floor.DAÏA A.ZI.IDATA A,AF !5,F

top

thegi ts

a73øe74øB75q)a7âø477øETArì

146

the

Page 156: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

a79ø€BøøaBlo882øBBSOB€4øBB5ø

886øBBTO

aBaø

sB9øa90øs91øa92øB9søs940s95ø896ø[J?7ø498ø899ø9rÀrüÐ

DATA A, C¡O r EDATA Trget hått*DATA Ar Z¡, IDATA A,AF,5,FDATA A,GEDATA 'l tcal I tshout r*-FsDATA ArPRr"The innkeeper comes into the roomr but seeinq you he crosses hißscl+ ånd däth€s back into the kitchen. "DATA T'cal I "shout '*F5DATA A,PRrfhe innkeeper pushes th€ kitchen door openand steps in the room.DATA A,PR,FLOP! The håt lends trn hls head. It ltrol.s Iike a thirnble on å giåntB hËàd. He throw¡ you end your hat out o+ the inn.DATA A, IS, løDATA A r BO.l,¡DATA A,ZI, IDATA A.AF,5,FDATA A,AF tå,7DATA T, leaverout '*DATA A'G¡Orl¡¡DATA CrEr*r5DATA Crl¡¡r*r IDATA LTsDATA Dr*rKitchen in the I'lelbourne.DATA Dr*-V3rtt seems surprisingly empty. Perhaps the innkeeper is a little short of money at the moment.DATA Trsteal cheesat*DATA A,6EDATA 1 rchee6èr*O4DATA A.FR,G}ET OFF llY CHEESE! hlhat do you neen openlytrying to take my food!DATA TrgivG,*Clø.OsDATA ArPR'The innkeeper says "Oh goody goody. I can beke soñe morc loaves now." and grabs your s.ck of flour.

"You can håve thl¡ loef."DATA A.MO.5.ODATA A, ZO. IøDATA T'loafibrcädr*OsDATA A.PR.6ET OFF NY BREAD! t'lhat do you méan trying to take my laEt loa{!DATA T. I eave.out ¡bår t*DATA Ar60,blDATA E!Wr*r2DATA L,4DATA Dr*rAt the north end of the village qreen-DATA Dr*-V4,You remenbËr coming here in the paet to throw rotten food (and the odd brick) at people in the stocks. This is where thèy älwåys burnt witchers. You rçnember throwing on wood... Those were good times.DATA l rput hatrplace håtrtry h¡t'*Cl.F10DATA A'PR'It {its!DATA ATPR,A crowd of ví11ågers gåther. "The blåcksmith i s the wi tch ! " screams the Pri est. "Burn hi m ! B¡-rrn hi m

! Burn hitnl". And they do. Everyone ha¡ e reål good time,.. roastinq chestnuts ånd potåtoeB in the fire. You have cleared yourself.DATA A, lS,2øDATA A,SCDATA A,OUDATA T.road,*DATA A,GOTE

eølqt9ø2rù9ø3ø9ø40

9ø509ø61Ð

91ì7ø9øBø9ø9ø910ø

9r to9t2ø9tsB914ø91509t6rì

9l7rì9IBø9190

921âø921ø922rì923ø9241ò

147

Page 157: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

925ø926ø927ø92€Jø929ø93øø931 ø9520933ø9340935ø936et937ø93BO

eedtbreåd!loef r*C5DATA T,fDATA A,DATA A.DATA C,E

DATA CrSr*i 1

DAïA CrEr*r l4DATA L,5DATA DrtrAn åreå of gråzing lånd.DATA T rfeedrcheeser*C4DATA A.PR.A goåt snåtches your cheese end eåts it.DATA AtZO,4

PR'A goat snâtches your breed änd eets it.zo.5rir l

DATA L.6DATA Dr*rAt the southern end of the village green.DATA Dr*-V6,4 foul odotrr drifts {rom the direction ofthe meadow at the west o+ th€ gre€n.DATA Trmeadowr*DAïA A. G¡O r t¡¡

DATA I,churchr*DATA A,BO.SDATA C,l,¡r*rBDATA C.N.*r tDATA CrSr*rlQtDATA L.7DATA Dr+.At the edqe o{ the vlllåqe pond.DATA Dr*-VTrThe pond is Etågnånt ånd smells foul.DATA I,put toadrdrop toadrthrow toadrreleåBe toed,*C2.-F3DATA A,DRDATA ArFRrSp¡ash... I The toåd turns into å €måll boy.

"lrlhere em I? t¡¡håt heppened?" he mutters åE he climbs olrt of the pond. "Last thing I rern?mbrr.I wåÉ Btrolling inthe woods ! "

DAÏA AtAF.STTDAïA A,IS¡t5DATA T'feed duckrfeed ducksr*CEDATA ArPR,The ducks gobble up the bread and leevë. There ¡rås sornething hldden in thllr n:Ét.DATA ArZOrSDATA A!20i5DATA A,ZI,l4DATA At IStSDATA T rfi I l rwaterrpondr*DATA A,PRrIt is impossible to get at the water.DATA CrSr*r8DATA Lt8DATA Dr*Vgrln the oeådow.DATA D!*-VB.In the middle of a meadoe¡. To the north thé qround becomes marshy. At the weBtern end ol the meadoþ¡ you cån gee a wooden building.

rNr*r7rl¡lr*r9,Er*ré9r*rAt the bIåckBmith's +orqe.,*-VgrYou remember corning here often in the pastIåcksmith always repairs €rveryones tools. He is agood al I round handyman.

.show goldrgive goldrshow coinsrgive coinsråccuser*Cl4DATA ArPR,The blåckEmith burstg into tears. "Alright.

I con+e5B - I Btole the woodcutter'B gold." he blurts out.DATA A,PR.A crowd o+ villagers rush up änd dråg the p

939ø94øtD94tø942ø943ø944ø945ø946ø947râg4eø949ø

95e!ø951 O

952ø9530954ø955ø

9Sôø9571ì95AO959ø96øø961O962ø9å3ø964ø965Qt

966ø967ø9óBAt969ø97rÐraçì7 ltÀ

972rì

973ø

DATADATADATADATADATADATA. fhepret

DATA

ccc

LrDDb

tyT

974ø

148

Page 158: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

973ø976ø977ø97Bøc79ø

9Aørì98tø942ø983ø

984ø9Els0t9A6ø9A7ø9Ër8ø989ø99øø991ø992Í!993ø?94ø995ø996ø997ø998ø999øtøtÐøøløøløtøø2tÀ1øøscttørò4ø1øø5ø

LøTD6øtøø7øIOøBøtøø9øtøloQt

DATADATADATADATADATA

leadinq blacksmith away.A.ISr2QtArAF,1C"TArl'lor 16,4

T r show, gi ve, accuserf orgerðnvi l r*A,PR.He Ehouts "Be of{ wíth you! Líttla Hitch.'r.

DATA CrËr*r€lDATA Lt IøDATA D.s,ln the church nave,DATA Dr*-VlQlrThe secret entrånce to tha crypt you found lieÊ open, High åbove you is the bel{ry balcony. fhe front door is to the north. In the lrouth rrall is a sn¡Ildoor.DATADATADATADATADATADATADATA,DATADATADATADATADATADATADATADATADATA L

hat , *F2. O9.PR.Tuq...rzl,l.AF.lrF,ZO r9rGE.PR.The priest storms off.Erypt r +rGOrDbel {ry, *rG0ruNr*réSr*r l3Dr*rl2Ur*,I II

T,AAAAAA

TrA

T,A

crc.ctcr,l

1ø11ø1ør2ø10r3ø1ø1401615øtøtéøløL7rÀIø18ølø190tø2ø1Àtø210lÍò22ø

DATA Drrrln the belfry.DATA Dr*-VllrFar below you crn sec the church nåvê.DATA T,ring bell,*-(FllF2)DATA A,PRrÏhe bell tolls ånd nËårly dråf€ns you!DATA A,ltor9.lQtDATA A.PR.You see the prirst run into thr church dirÉctly below you.DATA A. AF. I . TDATA 'ltring bellr*DATA A,FR,Ding dong... I

DATA "l ,drop hat , throw håt, *Cl . F IDATA ArPR.The hat drops fron thÉ bËl{ry ¡nd lrnds ovcr the priÊst's head.DATA A, IS, løDATA A,AF,2,7DATA Ar ZOr IDATA T'drop hat'throw hått*Cl.-FlDATA A.PR.t{eeee.... it .f allg f rom the b:l{rey.DATA ArÌlO,I,lclDATA T,nave. leave, *DATA A,GOTDDATA CtDr*r10DAÎA L, 12DATA D.*,In the secret crypt.DATA Dr*-VlzrThe air is icy cold. Thc floor ig intricately carved with strånge markings. On the wall ¡rc lit torchet.DATA Trtorches,torchrwal I,wel ls.*DATA ATPRTA couple of torches ere firmly ått¡tched tothe wåll bV brackets.

DA'ÌA T rbråcket,bråcketsr*DATA A,PR,Just plåin iron bracketg.DAl A 'l ,f loorrmarJ.inget*

l02sør1Ð24ø

1ø25øtø26øt1ù27fù

149

Page 159: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

IO28ø

tø29ø1ø3øøtø31ølø32ølø33øtø34øt0550

lg36øLîT37ø

1ø38ø1ø39ølø49øtø41øtø42ø1ø430tø44ør045ø1ø46øtø47ø1ø48øtø49ø

1ø5øøtoSlø10520105301ø54ølo55øtø56ølø57ørø58øtø59ølø6øcr

trÐ6tøtø62Íltø63øt1Ð64øI ø650tÍì66ø

t1à67øI068ø

I øé90trÃ7øøtø7 tÍÐtø72ø

rø73øLø74øLø7ãø

trà7610tø771âtø7aø

lrÐ79øtøsøø

DATA ArPRrYou cån måké no 6enBt of tht mrrkingi but you cån se€ they are well carved.DATA T'leavet*DATA A,GO,UDATA ErUr*, IODATA L,13DATA Dr+rIn the churchyård.DATA T rdiçrgråverheadstonertomb r*DATA, ATPRTCåreful.,. they bury qreve robberg åround here !

DATA Trn,northrchurchr*-F4DATA ArPRrYou trip over ð blåck cat which appears from behind a headstone!DATA A,Zl.12DATA A,AF.4.TDATA A,IC,0l,2ClDATA T rchurch,*DATA A,60,NDATA T,woodsr*DATA A'GOrl¡lDATA CrNr*r løDATA CrWr*r lgDAÎA L, 14DATA Dr*rThe roåd.DATA D,*-Vl4,You know this road well. To the north itpasses by the mill on its way to town.DAI-A T,r{.west.*FBDATA A,PR,I.THOOPS! You tripped ånd spilt the water.DATA A,AF,g,FDAïA Trfollow roadretong roðdr*DATA A,GO,NDATA C't¡rr*r4DATA CrNr*, l5ÞATA L. 15DATA Dr*.On å bridge ovÊr å Btreðo.DATA l rwater rstrean.rf ill rdownrdr*DATA ArFRrThe ¡trcåm t¡ tot¡lly fnrccarr.blr frorn hEre.DATA CrSr*, t4DATA CrNr*r 16DATA Lt T6DATA D,*,The mi I I .DATA 1.¡¡s¡p¡.**F7DATA A.PRrYou can hear e {aint scurrylng noise. You wonder if it is a rat.DAïA Trräftersr*-F7DATA A.PRrSo¡nething is måking noitse3. You wonder i{ it is å råt.DATA TrretrretBr*-F7DATA ArPRrRat! Pah! I'm a mouge you fool.DATA T.feed mouse.drop cheeser*C4DATA ArPR,The nouse scurries dov¡n ånd nfbbles the chce9€t.DATA A,AF ITTTDATA A.ZO.4ÞATA T,catch mousergrt mousertake mousÉipick up mouset*F7.Cl.-(Wt/FB)DATA A,GEDATA A,PR,You caught the mougc in the hat,DATA T,catch monserget nousettlkc ,nctu3rrpick up ,llouset*F7DATA ArPR,He slips through your fingËrs.DATA 1,cheeset*F7. (Oê/C6,

150

Page 160: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

roBløtøÊ2øtø83ølø84ø¡øasa

lø860

DATA A,PR.The mouse holds onto the cheese.DATA Trf lourrsackrgrainrbaetmill t*-p9DATA A,PR,The niller growls at you!DATA TrEive,*F8.-F9DATA ArPRr"The miller puts the såck downr tåkes the hat and drinks some water.DATA A'FR.He Eays "Tå Làd." ånd then pours the rest over hiÉ heäd. As he does this you notice that the hat istoo små11 for hin to r¡eår.

DAïA Ar IS, løDATA' A,AF,B,FDATA ArZ¡,letDATA A.AF,9.TDATA I rqivetiFE¡.F9DATA ArFRrHe s.niles ånd says "6o away creep."DA-ÌA Crg¡r*, t5DAïA C,l,¡,*,l7DA'IA L,17DAïA Dr*rBy the stréåm.DA'[A Dr*-Vl7,A loud sploshing sound comes {rom the water wheel. Ihe water looks es fregh and clear as ever.DAïA 1 ,f i ¡ I ,*Cl. - (l¡ltlC6)DATA A.PR,I+ you insist.DATA ArAF,8,1DATA Tt+ill hätr*l{lDATA A.PR,Gargle...gergle...bubblel You are unable tohold yor.rr breath åny longer and take your head out of t

he stream,DATA lrmillr*DATA ATGO'EDATA C,Er*r lóDATA L, IB

tøa7ørøABøtøtJgø109øølø91øIrÐ92ølø95øLø94øI ø954rlø96øtÍÀ971à

1094011899øI løøør rø1ør ro20

I tø3øI lø40I rø5ør røóøttø7øI tø40t lø9ø111øøI I l lctI I l2øI I lSAtI t 14øtllSø1l r601lt7ørr18ør r t9øttzøaL t2tøIt22øI r 25AtI t24øt 125øt12éøIt27øI I zBÍtI t29øI t30øI l3løI t32øI l33et

DATA D.DATA DTDATA C,DATA C,DATA L, IDAÏA ÞtDATA CTDATA C,DATA C,DATA LT2øÞATA Dr*r ln theDATA CrW, * t23DATA erNr*r 19DATA C rS, *,22DATA erEr*r2lDATA L,2IDATA Dr*, In theDATA CrWr*r20DAïA C.Er*r2lDATA CrSr*t23DATA L.22DAïA D.*r ¡n theDATA CrNr*r2QlDATA C.Er*,23DATA L,23DATA D.*. IN thEDATA Dr*-V23¡Ase rlln åwåy.

*rIn the deep dårk woods.*-VlErCareful ! You night get lost.Er*r l3l|¡r*tl9I*rln the deep dark woods.Ernr lSSr*r2øWr*r2l

I I54O DATAT I35ø DATA11360 DATA

deep dark v¡oods.

deep dårk woods.

deep dårk woods.

deep dårk Hood5.you arrived you thought y(]u Ea¡, soñeon

CrNr*t2øCrEr*r24CrWr* r22

151

Page 161: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

l t4loI t42ràI 143øI 1440I r456I r46øI t471ÐI r4Søt 149ø

t t37øI I38øI 139ø

r 14ø0

DA'I'ADAlADATA

5UnDATAth,DATADAfADATADATADAÏADâfADATADATADATA

had

DATADATADATA

hat !

DATA

L 124P.*.In e clGårlnq in thc l¡ood3.Dr*-!,llrlt is BhcltËrrd from thr ¡{lnd hrr..nd th.

iB.uncom+t)rtebly hot.Dr*-V24rYou hear ¡ loud chopplnq sound to the sou

T.5. south r*-V25. t'¡tA,lsr lgAr60.S

C tW rr' ,22crsitr25

L,2ãDr*,The wood cutter'5 hut.Tçhtttr*ArFR.The woodcutter bars your wey. "I've ålreådy

my gold stolen. I'm not going to lose anythinq elseF.eep out !"

Nr*r24

1

I l5øøI t5løI r 52AtI tSsoI 154øI l55qlI 1564!I 157øI r5Aø

I 159øI táøøt 1óløI l62tìI ló3øL 1641ìI l65Alr t 66altt67øt t 6Bcl1 16901t t7øøltTtØ1 172øt 173ørl74øIt7iøtt76øI 177øI I TBC}I t79øI lBBø1l81etI t82øI la3øI lB4qtI 145øI t86øI I BTAt1 lABør 189øI l9øA!I t9tcttt92ø

DAÎA O. IDATA D.*-FBra witch'E hat.DATA D,*Fgra witch's hat full o+ wåter.DATA P.25DATA N'håt

' *

DATA S.EXr*!It has a label on the inside ¡¡hichCÌ'lE Witch's Hat - SIZE 9', You wonder who wears

c,oro

Pr

0,DPNSs

geys'Aa size 9

ssc

so,

DDPe

sNSs

o,DPNs

DATADATADAIADAÏADATADATADATADATADATADATADATADATADATADATADATADATA

¡GEt*. DR, *- (FBlC6', PO, *- (FSIC6)

' f0'*2. *-F3. å smal I,*FSra wet and.E, GE r *-F3rDR,*

wart-covered toad.frightened goat hcrd.

. toed r boy ' herd r t

.EX'*-p3." very human looking toåd.,EXr*F3ra very toady Iooking hunan.3*rseveral duckg.7ducks'dt¡ckr*EXt*,They seem to be sitting on

4somethi ng.DATA

DATADATADATADATADATADAÏADATADATADATADATADATADATADATADATADATADATAdto

,*.a small piece o{ cheese..3, cheÊãe r *,GE.*.DR.*

S,EXr*rLooks a bit cheesy!o,5Dr*rä loef of Þreåd.P.3N.loaf¡breadt*S,GE.*S.DR'*

Ot6Dr*-F7'something moving around in the råfters'D:*F7.-C6,a pieèe of cheese with e mouse åttatche

it,

152

Page 162: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

r 1930I 194øI 195øI 196øt t97rôr I98øI 199ør2øîaøL2øtøt2tì2ø

DATA DrtFT.C6rthe mouse end thÊ cheese in the håt.DAIA P,1êDATA NrmougercheeBG!r*F7DATA 9,ÊEr*DATA S,DR,*DATA O,7DATA Dr*rå lårge brass bell.DATA P,1 1

DATA N.bell.*DATA S,EXr*,e large church b:ll inscribed with the letters 'ring mel'.

t2ø3øt2Íô41ùl2ø50t2øêÍìt2ø7ø

DADA

TA OTBTA Dr*re lot o{ go¡tÉ.

l2ø€lÍòl2ø9rù

L2LøTÐ

t2t trì

DATA P,5DATA Nrgoat,goåtE,*DATA SiEX.*,They are tethered to pogts. Strange! Theysee¡¡ to have eaten åll the good grass thcy cån rËech. PerhaFs they håve not beien moved for a while?DATA Or9OATA Dr*-(FllF2ltå vary smatl prlr5t blcssfng the secret crypt.DATA D,*Fl.-Fz.e very agitated prfest ¡ooking up ðt the belfrey.DAI'A D,*F2rå priest weering å blåck hat over hI¡ headand shoul ders I

DATA F, I2DATA Nrpriest,*DATA s,EXr*rHe looks vcry 5me¡l to you.DATA O,lQtDAIA Drt.å såck o+ flour,DATA P,_IDATA N,sack,båg, fl our,*DATA S,GET*DATA 5,DR.*DATA S,Ex,*, It is labellcd 'llegaHlIl Flour Co. 'DATA O, I IDATA D,*-V2s.an out of breeth woodcutter resting on hi5 exe.DATA Dr*-VzS,WlrSuddenly the woodcutter gnatches the håt ðnd trys it on. "¡ wonder if this will shield rne {romthe sun ?" he seys, "Pity... not my sizrå," he grumbles

åncl replåces the hat on your heed.DAI'A Dr*v25rthe woodcutter hård åt work.DA'f A P.25DATA N.woodcutter.*DATA SrEXr*rA rather hot É}reåty ¡¡oodcutter.ÞATA 0.12DATA D,*F7ra friendly black cat drooling around your ånk I es.DATA D,*-F7,a friendly black cåt.DAÎA P,-1DATA N.cat. *DATA SrEXr*rlt looks friendly.DATA O.13DATA Dr*rthe innkeeper.DAÏA F.3DATA N, i nnkeeper,*DATA SrEX,*rHe is råther large.DATA O.14DATA Dr*rEomë gold coinElDAÏA P,-IDATA Nrcoinstgold,*DAÎA S,GËr*DATA S.DR.*

t2t2øl2l3øt2l+rdr 215øt2t6¡at2t71àI2IBøt2t9rìtz?lÐrat22løt222ø1223tì

1225ø1226ø1227ø!22gøt229øt23øÍÐ

t224rô

125tøt232ø123s01234ûI 235øI 236ø1237ûI 2388t239ø124øøt24tø1242øI 245øt244øI 245ø

153

Page 163: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

r246rì DATArrstDAÏADATADAÏA

12471ût2 BtÐt249rÐ125,øøt25tot252rÐI 253øt234øI 255øI 256ø1237øI 258C1r 259øt26øøt26tør262ø1263ø\264ø

1265ø

1266tÐL267øt268ø

t269ø127øøt27tøt272ø

t273øt27 4øt273ø

DAÏADATADAIADATA ODATADATADATADATADATADATADAÏA ODATADATADATADATAoxo'DATA

S,EXr*rNo. They åre not sliced golden egg. They m

have come +rom somewhere else,l5r*.The mlller hunping ¡¡ck3.bout.r 16tmiller'*rEXr*-F9rHe looks hot önd thirsty.. EX , *F9, He I ooks v¡et.t6,*-Flø.The blackgmith herd at work,,*Fl€trThe blacksmith in the stocks.,9, bl acksmi th r smi th

' *

.EX.*-P16.¡e looks rather hot.rEXr*Flø'He looks gtuck.t7,*rsoße stocks.

o,DPNss

DDPNsS

DPNs

.4, stocks, *,EX.*-FlB'There

engraved on it.SrEXt*F1O'There

i¡ a bras¡ Flåqua with 'lhde bY

seemB to be a blackgnith in them!t!DATA E.øDATA A,PRr" "DATA A.FR.A crowd of villågers gather round you. l'he priest points at the cåt ånd sayE "Look he has a black cat familiar! That proveg he is a ¡'¡itch,". They drag you away and test your inflammability.DATA A,SCDATA A,AUDATA E, IDATA A.FR,The church bell rings. It is middåy. The vil¡agers drag you åwey ånd burn you. lt wes a really jol¡yoÊcåBion and people came {rom miles around to see you.

DATA A,SCDATA A t GIUDAÏA F

154

Page 164: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

GHEXSUM

The unique CHEXSUM program validation.

WHYWhen a listing, such as this is keyed in, everybody invariably makesreading and typing mistakes and then spends ages trying to sort outwhere and what is causing the error (errors!).'

Even experienced programmers often cannot identify an error justby listing the relevant line and need to do the tedious job of going backto the book, especially with DATA statements.

Realising that this is a major cause of frustration in keying the pro-grams, we decided to do something about it.

You should key in and save the following listings before you key inthe AKS listing.

Using the Chexsum routine you will be able to find out if you havemade any keying errors at all and in which lines, before you even runthe program.

This means that you need not waste time looking for keying errors,you simply run the routine and look at the display to identify linescontaining errors. lt's that easy.

The principle behind the routines is a unique chexsum which iscalculated on each individual line of the program as you have keyedit in. Compare this chexsum value with the value for that line in the listat the end of the program listing; if they are the same the line is correct,if not there is an error in that line.

WHENThe simplest method is to enter the CHEXSUM program in now andsave it to tape or disk.

You can type in the chexsum program at any time, even if you havestarted to type in a program. You cannot, of course LOAD in CHEXSUMfrom tape or disk because it will erase all you have typed so far.

The obvious solution is to MERGE the programs. The CHEXSUMprogram should be saved onto a separate cassette to allow easyaccess.

HOW CAN YOU TELL IF CHEXSUM HASBEEN ENTERED CORRECTLYAfter having keyed CHEXSUM the logical thing would be to chexsum

155

Page 165: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

the program to make sure it is correct. But is it possible to to this? lfyou follow the instructions you will be able to check CHEXSUM.

1. Type and save CHEXSUM.2. RUN Chexsum and it will check itself.3. Check output against the table of values at the end of the program.4. lf the program is incorrect, edit the incorrect lines and resave the

program.

Below is the listing of CHEXSUM and instructions on its use.

USING CHEXSUMThe greatest problem encountered when typing in programs from abook is errors made by the user. Most of these are picked up whenthe computer responds to the RUN command with the 'Syntax Error'message. The user then has only to LIST the line and compare it withthe line in the book. Unfortunately, some errors are more subtle andnot fatal to program operation. These types of errors will cause theprogram to run, but incorrectly, and the computer will not be able todetect them as such.

ChexSum is a special program which generates a unique sum foreach line in a program and a grand total of all line sums. After eachprogram listing is a table of check sums. You need only compare thenumbers in the ChexSum table for each program with those generatedby ChexSum. lf two numbers differ, check that particular line.

1. Type in AKS. Save it to tape or disk with the statement; SAVE.'AKS''

2. Reload the program if necessary, using the statement; LOAD"AKS".

3. To join ChexSum to the end of your program, enter the statement;MERGE "CHEXSUM''.

4. When merged, enter RUN 6ØØøØ to activate ChexSum. The pro-gram will prompt:

oUTPUT TO PRTNTER (P) OR SCREEN (S)

Entering a P will cause output to go to the printer, and entering Swill cause output to go to the screen,

5. ChexSum will now output the check-sum table for the program.To halt the program press the escape key once, and to restart theoutput press any key other than escape. When ChexSum hasfinished you may remove ChexSum from memory with the DELETEinstruction. For example:

DELETE 6ØØØØ - 6299Ø

156

Page 166: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

6. Check your grand total with that in the book. lf they differ a linehas been entered incorrectly. Compare line numbers until youlocate the bad ones and then edit them.

7. Repeat steps 4 to 6 until the program is debugged.9. When the program is running satisfactorily, delete the ChexSum

program as described above.1Ø. Finally save the debugged version onto a clean tape or disk, with:

SAVE ''AKS".

lO-7Ot3O-40-5O-éO-7O-BO-90=

10O =llO =t?Ø =l5O =l4lì -l3gl =160 =176 =lECl =19ø -2øû -2lg =221À -23ø -235 =24O =25O -26,ø =27îÐ -273 -2AB =2it =3BO =SlQl -32O -53O -34O -55Al -3óO -37O -3BO -39O -4øø -4lQl È421ì -43O -441ì -

2e2l25Bl2ø527r2273

4S9lc6ø47rà4Bø49ø50ø5tø521ì53ø54059ø5óø57ø5Aø59ø6$ø6r ct621463ø641Ð65ø6ê10ê7ø6gø69îÃ7ørÐ7tø72ø73ø74û75ø7Éø77ø7Bø79680øBløa2Íìa3øÉ4øBso86087rÀaaøB9øgøø

31 32441¡24ó225ó7552ô59154794rÐ

ø(à

249367262t1À4ø26942696øoøøø62242øø3øê4444695t762o5953rBt2ø4îò693755553247 4lt742o4578ø49391265ø932rîøo

9tO =i?rÀ =93O -94O '95O -1ó,û ti7ftr a9BQl =991À -

IOOØ -lOlO -lO2O -lO3@ -lø4O =lOsO -I øå9t Êlø7îÐ =lOgO -lØ96 -llOO =I I lcl -lr2Ø =tl30 =It4Ø =llSO =l16ø =1171à =l lSf¿ =l19ø =t 20tll -l2ltà =122Ø -l23O -1246 =125ø ¿126û ol27O =l2Bø -l29O *ISOO =13lO =l32O -153Íl =l34O -l35O *156O o

l38I 6621 342I 7362673rgla2løø24s62r3l9l2o262BAtrs57oøøøI BQIB

7l¡Ðs92øtBé2I asøBøA295522442r319622øtrò

øoø9çJ75255324 It4t22ølrù

øtÐ

ø7tÐ72283I 783293ø22F34

1570T38ø1390I4øQ¡l4 tø142øt 43øI 44øt45øt46øt47øI 48øI 49ør 5øøl5tøt.52ø¡ 53ø154ø155ø156ø157ølSao159øt6øøt6t ot62ø163ø164ø1650tÉ6fD167øI68øt69øt7øøt7 tø172øI 73øt74øt7âøt76ø177øL7Bøl79rÐlaoolstøta2ø

l6sQtaø82t3t95ó2c,1r¿

øøø984524632352273tB6222FJ4165C1aø631642135t 7rt 4ø62øLoø0(ù

68467542øø320rrìøøøt2éot2ø7165øBøB333422t342¡3?oløøøø

øøøøo0oøoøo3looBoøooøoo01â

6øøooø

BO

E

E

I

a

I

¡

t

-

2721à15673009ø1Ð

47øoøo3482337 I

157

Page 167: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

lg3gl ol84Ct =lgstl !186Ø -lB7ø -lgBO =lB9O =t9OO =l9to -l92O -l93O =l94O -195ø =1966 -197ø ál9BO -1996 =2OOO =2rì10j -2ø2tò -2ø3ø =2ø4ÍÐ -2O5E g21Ã61à =2rÀ7ø =2ø8O o2ø9ø -2tOO -2116 -212Ø =213ø -2141ì -2l5el o216ø -217ø =2l8O =219ø =221àØ =221ø =222ø -223ø =2?4Ø =22ãØ -226ø =227ø =22âû =229ø =25OO =23tø =?52Qr -235Ø =254O =235O -25691 =2371À2sBqt239ø24rìø

6915526337525242øtBøøo1862t773176199ølsl9t761 9932t25t762øørÐ2236t762ÍìtoøørìI 28S429732232L4tt464221ìt72øLt7r,2øtBøøoI 793452(â

oT 86822731958ré5ø8083565I 55ó35532294213201

24110 -242rì -2436 -244Ø =245,1à -246fù o2471â =248ri -2490â =256O =251Ø =232O =253O =2540j =2556 =256O =237ø =25BO -2590 -26pø n26le =262Ø -263O o264rÐ =2å5Cl =26Érà =267fÐ o26fJø =2êi1À =27OO =27lrÐ =2t2O =273ø -274O =27ãØ =276fÐ =277O =27eø I279ø =2AO0 =2B\rã -2B2O ¡2€3O -2fJ4Ø =2B5O =2tJ61ì a2[J7Ø a2€BO *2çJ9ø =29ûrì =291Ír =292ø =2930 =294Ø -295ø =296Ø =297tÐ =29AØ =

33t65rs44l 842ø7â577 I213I 443l9t r5ø8437874524333ø2132r394216502øtoøøI 37ø2.2øl379øt762rùt0øtô

Bsø5t6t92ø1

4øé438 l53ø84I 7ê8t7622699

2s59I 43øt429sa9øot47227ø3279142352r3

299fì =SEOO -3OlO =5o2O =3ø3O -5O4O *3O5O -3O66 =5ø7O -SOBO -309O -SlOQl -SllO -3l2el -3l3O =3l4O *315C1 -3160 =317Ø *3rAO -3l9O -32BO -321ø -3226 -323O -324Ø -3250 -3260 -327ø -328ø -3290 -33QtO -351ø -5329 =333O -334Q1 ¡53501 o3360t -337O =338O =339O r340tcl e34lO -342Ø -343ø -344O -345et =346O =347â =S4B0l ã349O =35ø0 =35lO =352Ø =353O o5540 -s55O =356ø =

156721Ãtøøoø17733084147351485B9l2øtøoøø7zEJ342126ø1ò1fJ7442å61r723213461 I1535296321Àtøoøøt 46427422BåS32292?244Bøø4tJt756652øIøoøø1919r s39t729I 38457992152rìtøoofù

372rá383t732

3570 -35801 -359Q1 -3óOO ¡561ø -362O -Så3O o5ó4Cl *3ó5Cl -366O -367fì -3éBO -3é9O o57øet -37lO -37211 -373ø -S74o -375C1 -57óø -377ø -STBB ¡379O -38OO eSBIO ¡3B2O -3B3O ¡S84O 'SBSQI É586O -3970t a588ø '3B9O -39OØ -391C1 -592O -393O -394ø E395O -396ø r397O =398O e3990l !4OOO =4ølO =4fÀ2ø -4O3ø -4Ø4rD -4O5ø r4ø6el =4ø7ø -

¡9r9292tt729l5a56ø331994t422t3B3213t4222râlø66o24652îltoø(À

øI 64319905735486952682t3r7ø929€J23043475o44262øtøøø6l7ø944373654t 437r90øo170944393r t7312øø35Cr6t4222øl

øø6oI 874

oøot t02

4øBø4ø9ø4tøø4t 1ø

-ør@=ø-øEø

rOrOÉO

24372522s5a9

158

412ø -413ø *4l4Q! Ë

Page 168: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

41504t6ø4t7ø4 r804t9042Aø42tø4?2rì423îD4249423rà426ø427Ír42grì429ø4SOg43tø432043304340435ø4360437ø434ø439044tìø44tø442ø4430444rÀ445ø4460

7ø4444BO449ri4ãøO45r ø452ø453ø4540455ø456ø4â7rD45AO459046tÀ1Ð461ø462îÐ4ô3046410465ø46ó'ø4ê7rì4680 -4691à n47øø -471ø -4721à -

2øtø0øø2523475424572ølotù

ooo1ì

t74tJl9lI Bl229jtøoriøøt47A4øa.246336l 252rLløG

o622753l å416sOs0B546422B42t52øLoøøîì1565194574t32ê7€J79653ó374t3213t565463939422136ø51

473ø474ø473rù476Íô477ø47Arì479ø48BO48lø4821ì4S5ø4fJ4ø4€5ø486ÍÐ4A7rò4Bgø4S9ø49øø491ø492ø493ø494ø495ø4961i497ø498ø4991050øøãølø502050385ø405ø5ø506øso70

I28ã2øtrìøîà

ø2ørÀrùs93ó2533342322363ó85r 3å3t7{'2tÐtooøøfÐ

6ã291t47Bst722tt4I 857t41Ð62t33461t4ø7t85S49992rÐløooø22733øSS1656aøs346222FJ42r32tÐt1Ð

ooø2tl4t 37ø227329ø1ìr650sosstã922e42t5

53tO532ø53SO53405550536ø537ø53Aø55905400s41054205430544ø545ø54605470544ø549ø55øø5510552ø553ø554A5s5ø55óø557ø558ø5590560ø5èlø5ê2ø563ø564ø5è3ø56óø367ø5égø5690570ø57 10572Íù

2øtøoooBll37332rôtøoat

o56282sss23343227Lt21ôst lø535767ø255sSOBø24232g7E3t28247222772733237€J233025492Arû22SB33162323ø26772637244423372t320tÍT

øoo2áø22îîtgøøo23723302l9ø522øt442344b3705

589059øO391ø392fì5930594ø595ø59610á9710598ø599øâøøtÐ6ø1ø6,ø2têo3ø6'rÐ4rÀ605ø6ø6tÐ6¡ì7ø6ø8,rìâø91À610øê11ø612ÍÐ613ø6L4ø6150êt606t7ø6taøât91062øøé21øÉ22ø6239ôé24øê25ø6261ì627ø62ÍJøé29ø63øøá3tøós2ø635Oó54ø635ø636râ637ø658øé59ø64øtÐ641ø642ø643ø644ø645e16461à

2g2tt762rùloooot5s72øløøoøóBO?29421Dt

638326tøøøøaa7r793t736l9t2tìt

2ørÐ32ø292ÍA\øøø67725SO1565227332511650BOB22e722e42136ø792øtoøø

61ù

øn17 l5

Íò

0øotlsz

5øBOã69ø5IBø5t 1ø5r205130514ø515ø51605t70

573ø

9ø5l5laø

á741Ðã750á761â:5771À!57B10á7qø58øøSBlO58205830584ø585ø596ø5A7øsSSO

520052lO522ø523øs24ø52305.26t5.27ø52BO -529O -53øø -

159

Page 169: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

647ø n6488 -649fI -65Qlø !ê5lO -652îì -è53O -ó54O -655Ø =ó560 -6ã7ø -658O =ê59O -éáûØ -661O =662rÐ =é63Ø -6ó4O =6å50 -6ó60 -6o78 =å68O =é6iØ -671Ðø -67lrÐ n67210 -673rù =674Ø =ê73ø =67éø =677rÐ -67tJ6 -ê79Ø =6A8@ -68lO -682Ø -óB3O -684O =685Ø =ó86ø =687ø -6A8ø -óB9O -69OAl =69lO =692ø =693O =694îÐ =695Ø -ê96?j -697Ø o698ø =6i91à n7fÐøø o7ØlØ o762îì =7O3ø =7ø4ø =

ø9Bø2739tI 49øt55621ù232øtøoøo293422497Bâ92tùtøo1à

ø294422499É422øtÎD

ra

ø629sS224968572øtrì(Ð

ora

29372249723fì2rùløøøat

29312249r22492t t42øtøøøøI 4ø62t4724912ÍÐtøø

7ø3ø -7o6Ø =70,71Ð -7øtJrD '7ÍÃ9Ø =7løø =7llø -7l2O -7l3O =714Ø *7t3Ø =716Ø =717ø -7tBø =7 l9Ql -72rÃØ -72lO -722ø -723ø o724rÐ =72ã0| -726Ø *727ø o72Efì -7290ô t731àO =731Q1 =732fÐ -733ø =734Ø -755Ql É73ÉØ =737Ø o738Ct È

739Ø -74OØ -741ø -742Ø =743O -744O -745e1 -746Ít -747Ø -74BA -749Íà -75,øfÐ á75lO =7s2ø =753O -754ø -7559 -7ââ1À -7576 =75BO =759Ø -76øø =TblO =7626 o

68l969l21ò29zrDtøøøøéBt49662ø2920¡1øøøot 5495ø176t5ø4939774Al2s4965t59r3a20tooøo15497625tø340314EJé,ê35Sø5213t372øtoøtìo4448513ø45446lA7ãéè455

763ø o764rÐ =763Ø -76610 -7671ì n76gÍÐ n769Ø -77ØO =771ÍÀ -772O =7731ì =774ø -7731ì ê776ø -777Íù =77f,ø -779Ø -7eOØ -7AlØ =742Íâ =743ø =7FJ4Ø =7âãØ =7âé'Ø -7t¡7ø =7880 =78iØ =79OØ =79tfì -7921ì =793îì -794O =7i5Íl -796ø =7976 ¿79FJø -7991b =BOO0 =AØ1O =Bfâ26 -EelSø -8O4O -8Ql5Cl ãAO6O -AØ7Ø -ACtACt EAø9ø =91O01 =BllO =A12O =B13O ¡81 401 -8156 -BléO -Bt7Ø =BTBø =Bt9O -82øø =

2øtooøøI 99634øl2t75535,A7tø95553tøB.25445S796ø544r 23øJJO

547I tøgs5Btt225â2587rooø56249856ø5877765éOtø925435A797ø543I 45944ør 8524442458421261ÐI431259 I438191g432926431aø2436575gjt74292t7rÀt7ø6

g2lø -8221ì oE231ò -824Ø -A25O -€J26Íò -e.27ø '828C1 -e29Ø =B3OO -BSIO -B32O =B33el -B34O *S3501 =836Q1 g437ø =838Q1 =B39O -B4Oø rB41E -842Ø =B43O -

341147?1 Bå97øø14ø3391 I54et95786265485935t21S5944172426194985745144734t353SrBóI1Bgø544I 453489513425446S67rÐ3l3ø€5556967ø3t2t33á2éaó7rÀ3t32t558é867ø3545550532553342294ròó5r 31 338ó32ø9ã6666415431 E¡å929?3537627

îÃ

aøl25662ørrò

øøø

844øa45ø846øtJ47øS4Bø849øs5øB851ø8520453ø4540855ø856O =A57O =g5Bet =B59O -869O -86lO =862O =8636 -B64gt ¡8è5ø =866ø -867ø -868Ø =869Ø =A7ØfÐ =ATle =fJ72Ø =875Ø =474ø =875Ø -476ø -477Ø =878ø =

160

Page 170: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

F]79øBBøøBBIø8A2rôaa30sB4øB856aB6g¡BB7øBBEøss9øB9øøB9l øag2ø893øfJ94øa?5ø€Jqéø eÊ97fò -B9B0 -899ø =9øOO -9O16 =i1û2O =9OSQI =9ø41Ð =9O56 =9O6O =9tà7Ø =9gBO =9ø91i E

91ØO =9ltø =912Ø n91301 -914ø Ê

9l5O -916Ø ail7Ø n91BO -9l9O Ê

92îòÍÐ o92tø n9221ù =923O -924ø -9231ù o926fÐ =9271Ð -92€Jîì ¿9291Ð -93øO ¡931O -932Ø =933ø =934O =935Ø -956ø -

544I ø5553762742tI 5731øø61I 52S63791ø71357El562537627ê42t29C5é2533549s43269:J9243157é42tI 1386Íì22I 155t r54ø626591r 49037 trÐtô525625503443gl IrBBSS3ø63Lt792Í¿96â379431447EøS544545sB334525tett5744t47546t92â4ø3Þ547s5l346

9550956er937Íì958ø959096ø0961ø9é21ì963ø964ø9å5ø9àbtD967ø96fJ0,969ø97ÍÀtÐ97 tli97zlj973697 4rD973ø976ø977rô97fJø979ø9eørÐ98lø9ê2ø985698409856996øga7ø9BBø9A9ø99¡Ðø

4t447726rø23s621ø23558556540ã9334732224rìø14734431t5'rÀ776395342383799t545ã47549534tg77sB7355234St7é3t233754ó55753634927571272A516296866724379ó85éBø3r5541955583€92ø7q1499åtocts929537å2355142t25,76948543I ø3ø56Cr

995C1 -996Ø -997ø o99gø =999Ø -

IO@BO -lOØr6 -lfìrìzfÛ -rOø3O =lCtEl40l EI Ct0t5ø ¡1OO6O =lrDrò7ø =1OBBO =IAO9O -IOIOO -lQll lO -lOl2O -rOl3O -lgll40' -lgllS0l -1el16Cl =lø1701 -r6tB¿l =lØ19û -lrâ21ârâ -lø2101 -tØ221â =1O23O -lO24O =lø25ø !lØ268 -lø27ø -1el280 =lØ296 -rø5øO =lOSlO ¡lO32O -1ø33ø -1O34O -1O356 -1036ø -lO37O -IOSAO -1ø39ø É1646ø -lO4rO -lO42Ø -1O43O -lO44O otO45O -lO46O -lrì47rì -lO48O ¡11À49ø -1O5OO -IOSIO -1O526 -

54ã9965Bø59639øL62B4tÀ4316774ø1Ð7679s962é37t263I 5øø2411ì62â557ÍJó3454324s53ó.2t67tlSst54337A39r22241øtå128øI65542ørò9297øta3673299tr56ø5953922053274gJ48øIt943ó383s[J7640655lø235539425É25AA605393t 1597794t t264ø4663ø

lolssct -los4Qt o1O55O =lø56ct !19t57ø =IOSBØ =1O596 =lQl6Qlgl Ë

1ø61Ø =lØâ21À -lCl63O -rO64O =1ø65ø -106åø -lrÃè71ù -10åBø ¡1O69O =lø7filÀ -1O716 -tØ72Ø *lfì73fÐ nlø741Ð -lØ751À -lØ7é,rà =tø7710 nlø78ø =lø79ÍÐ -IOBOØ -tOAt6 -1O82El r1ø83ø -IOB4O -lclgso -lø86ø *IOBTO =rOBAO =10189ø ElO9OØ -lQl9lø -1ø92O -lO93O -lØ94f0 -lO95O -tB?éct -LØ97Ø nlø9get -1ø990 -ll0øø Él lOlO -I 1020 =r lO36 =I lO4O -t IOSO =I 1O60 =lUã71ì =rrOBO =r tOgO -lllOO -

252ë5s35525?33942676272447645'97594395I t67l2t Iá243lSrs5393I 3å9301926294903é4354655é642134øs4923337 rlã6ø34å3296tzBt4tt376683r TSBB57963ø5S5645I1125517598ê1Ð4396t ó40925St 40It7g7644t294tøs27€t6544585397243ö31435S26ø6

937tÀ93BO9590r94ÍСì94trì942ø9430944ø945ø946ø947ø944ø949ø9508951ø932ø9530

4ø95

I

I

991ø992ø9930994ø

161

Page 171: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

tlllø -I lt20 -I I tso iI I l4O È

1115O -ll16ø -11170 -l l lBO -tll9O -l l2elø r11216 -lL22ø -ll23O -ll24fù -1125O -I 126O -L1271à nll2BO -ll?9ø -llSOø -1l3r0 -rr52ø =lr53O *1154O -I 135Q1 *1156O -I 1379 -I tsBø "1139ø -1l4OO -1141Ø -11420ô =I l43gl -1144O e1145ø -I l4óO -rt47ø -I l48O -I l49O -t 15O6 =l l5l0 -ll52O -1153ø !tl540 =t l55O -11569 -ll57O -ll58ø ûr t59O =I lôOO =1lél0 -1162Ø -1163ø -I lê4O -11ó5O -Ité66 -l167ø -t 1680 -

39S243658759459939ø24sbêøl59759658t391243659858l397392243ó5495S33932436554758958460ø39427ASé8954691lâ24578558êîôrì5993952356725rø4to59334334s344t7é230øBs9769791295259559ê45483452?7 t3359s52ó9t535

I 1ó9øLtTrirÛI 171øtt72øI 173øI L7 41Ð

Ll7ã1ùtL76øtt77ÍàI I78øtt7grtI rsoøI tBløI ts2øI la3øt ts40I 185øI tg6øI t87øI IBBøI r89øI t90øI t9løt L92rìI 193øI t94øt !95ø1 196øtt97lÀI l9BO1 199Q1

t2øørÂLzlrløt2ø2øt2ø3øt2ø4ør2ø56r2ø6rÐt2ø7øI2øBøt2ø9øt2tørÀl2l tøt2t2ø12t50tzr4ø1215øL2téràL2t7ø12180

164 1

3 193326i346t7 4îã351l3B54ø513472550347løø1ã235352257548t73fô34713525255353494321À497€¡39ø8s99t723525535s5ø2øFl6594793ss28351t699349I 393t34ø73525ls753145757395rø4330843921792s9øt 73å525ã3s3574393ãøslt7t923237399

L2271â -l22Bîà -t22i1ì nl23OO -L23lÍÐ o1232O -1233O -l234gl *1235O -1256O -12371à -l23BO -L239fô nl24lÃO -l24ttD -1242fì -1243ø -t2441À -1245,ø tl246Ql -1247Ø -t24Êlì -1249Ø -l25OO -1251ø -1232rÀ -1253O -1254Ø -12558 -l256el *L2376 -1258O -12590 È

126O1Ð -L2619| -t2621Ã -12ê31ì nl2ô4O -1265O =126ê1ù -12b7Ø a1268e' =I269Q -l27OØ -t27lØ -t272ø nL27sîù =1274ÍÃ -1275ÍÀ -

I 49435753945t56246t590â922299395I 750347r 341229ø596IBé539ør38652s535749939733lA599tÍì2330s6I BB439S314232573532øSt2b422t42599t 547344to43545243473535S717373431447334t 4å19431447242

TOTAL - 217519712191Ð -122ø9J n122t1À -t2221Ð nt223ø n12240, -1223Ø -1226Ø -

162

Page 172: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

6ø1TÍAø

60018

6øø2fìåøø3ø60040óøø50

6øø6ø6Írø7rò6ø0BO

å0ø90

åo1øø6011ø6rÀt20

é0150é8t40

6øl 5ø6Íò16rà

6øt7ø60r806løÍìrâ

FRINT *B.CHR$(27)¡"G"¡ ! CLS: LOCATE 11. I ¡ PRINT "CHEXSUH.PROGiRAT,I"LOCATE l. 5 : PRINT "OUTPUT-TB^PRINTER^(P)^OR-SCREEN.(S) .?t'¡X:8=INKEYIS: IIF X$ = "P" ORIF X$ = nsrr ORLOCATE I rL( X$ ) >TOTAL a Cl

l0!

NEXTFIEI'I - PEEK( l''lEt'|, + 25ó * PEEK( l'4814 + I ) + NEXTT4EFI

LN - PEEI¡:( l"lEl"l + 2, + 256 * PEEK( l*lEl'l + 5 ) ! IF LN >=LLIH¡T 1HEN 62øelø ELSE IF LN < LSTART THEN t'lEH = NExTHEl"l

¡ B0TO óøø8øHEtl = Ì,tEh + 4 : CHXSUII = O : QUOTE = øIF PEEK( llEtf ) = 52 THEN HEl.l = ÌlEl"l + I ! GOTO 6gtltQttF PEEK( F'lEt'l ) = I OR PEEK( MEI'I I - li7 THEN tlEt4 = NEXTI'IEH ¡ GOTO 6lgl¿!øþ,HILE I,IEH { NÉXI'}.IE},lrOr.EN ¡ PEEK( HEt'l ) ¡ IF TOKEN - 34 THEN OUOTE = BUOTExoR I¡F OUOTE = I OR IOKEN <> 32 THEN 6ø17øLASTOK - FEEk( l"lEM - I ) : NEXTOK - PEEK( llEl'l + I ) ! GOSUB 61500 r ¡F IGNORE - I THEN 6O18BCHXSUI'I = CHXSUI'I + IOkENHEI'I-MEH+ I: WENDPRINT *STREA''I, USING ''#*II*{T"r LN¡ : PRINT *STREAI"I.

"=^"¡ trHXSUMIOTAL - ÎOTAL + trHXSUl{ ! GìOTO 6OOBA

IGiN0RE - Cl

IF LASTOK = 44 OR LASTOK = 32 OR LASTOK ' 4Qt OR LASTOK= 1 OR ( LASTOR > 237 AND LASTOK < 25O , THEN IGNORE =t ! RETURNIF NEXTOK = 4l OR NEXTOK = I OR ( NEXTOR > 237 AND NEXTgK ( 25ø ) THEN IBNORE - I ¡ RETURNRETURN

PRINT llSTREAll ¡ PRINT *STREAI'|. "TOTAL-=^"¡ TOTALa

F X$ = "" THEN óeløzøX* - "Þ" THEN STREAH o g !X:3 = rrsr THEN STREAM = O : PRINT "S'INPUT 'STARTIN6.LINE-NUI1BER": X9 : lF VA

ø THEN LSTART - VAL( Xî ) ELSE 6ø05ø: LLI]'|IT - 6299Ø ! I'IEH - 368 : NEXTl'lEl'l - t1EM

6t ø106r49ø6150øót5lø

å152ø

ó153ø6t99øó.2ørôrì6299ø

6rìØØØ -600lø =61ìØ2fà a6OO3O -êøø4ø =óOO50 =6ø0êø =6îàØ7rD -éOØ€Ø =é€0?6 e6ØlOO =ÉrìllîD -6Íù12Ø =6O13O -6ø¡4ø =éOl5O æ

6O16O =

2Arì930592ø6t33r5329757t34243ø43679ãt r325634324964t687509228 l96l t3

éÍàl7rÙ =60lAø =6rO60 =ålølø =ó149O =é1501ø =6l5lO =ó152Ø -6153ø -o199Ø -é2O1ÐØ -

2585157658972èø40tø229964745ã2ølø2964

TOTAL = 97746

163

Page 173: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Þ9t

Page 174: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

APPE]IDIX BBIBLIOGRAPHY

The following is a short list of some useful and interesting books andarticles which will provide more information about areas we have cov-ered in this book. lf you have found some of the more advancedtechniques we have mentioned intriguing, then these sources will bewell worth looking at.

Blanc, M. S. and Galley, S. W., 1980: How to fit a large program intoa small machine. Creative Computing VOL 6 no 7, 80-87.

Daynes, R., 1982: The video disk interfacing primer. Byte, June,48-59.

Jackson, Principles of Program Design. Academic Press.Knuth, Donald. Fundamental Algorithms. Addison Wesley.Lebling, P. D., Blanc, M. S. and Anderson, T. 4., 1979: ZORK: A com-

puter fantasy simulation game. IEEE Computer, April, 51-59.Lister, A. M. Fundamentals of Operating Systems. Macmillan Publishers

Ltd.Reed, K., 1980: Adventure ll - an epic game for non-disc systems.

Practical Computing, August 68-75.Tolkein, J. R. R. The Lord of the Rings. Unwin Paperbacks.Winston, P. H. Artificial lntelligence. Adison Wesley.

165

Page 175: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

AKSCASSETTEA cassette containing the Adventure Kernel System is available oncassette from:

Bookpoint Ltd.,39 Milton Trading Estate,Abingdon,OXON, OX14 4TD.

Please send 80p (post & pack) plus € 3.95

166

Page 176: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Writing Adventure Games On The Amstrad

Customer Registration Card

Please fill out this page (or a photocopy of it) and return it so that wemay keep you informed of new books, software and special offers.Post to the appropriate address on the back.

Date. ....19Name

Street & No. .

City. . Postcode

Model of computer owned

Where did you learn of this book?:

fI FRIEND fI NETRII SHOP

tl MAcAztNE (give name)

rl OTHER (specify)

Age? E I o-l s |J l0-t g l)zo-zq ff 25 and over

How would you rate this book?

QUALITY: [] Excellent ff Good ff Poor

VALUE: fJ Óverprice fJ Good fJ Underpriced

What other books and software would you like to see produced foryour computer?

ED|T|ON7654321

167

Page 177: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new

Melbourne House addresses

Put this Registration Card (or photocopy) in an envelope and post it tothe appropriate address:

United KingdomMelbourne House (Publishers) LtdCastle Yard HouseCastle YardRichmond, TW10 6TF

Australia and New ZealandMelbourne House (Australia) Pty Ltd2nd Floor, 70 Park StreetSouth Melbourne, Victoria 3205

Page 178: WRITING - Bristol University | Department of Computer …ecsnp/games/Writing Adventure Games on... · Besides the enjoyment derived from writing an adventure game, you can learn new