Bug in Savage Island 1 by Scott Adams..?

discuss classic text/graphic adventures for the bbc micro & electron
Post Reply
User avatar
lurkio
Posts: 4351
Joined: Wed Apr 10, 2013 12:30 am
Location: Doomawangara
Contact:

Bug in Savage Island 1 by Scott Adams..?

Post by lurkio »

A user of bbcmicro.co.uk contacted us to report a possible bug in the BBC Micro version of Scott Adams's 1984 text adventure game Savage Island 1 from the bbcmicro.co.uk games archive:
In an email, Fr Grant Gorddard wrote:i am wondering if anyone has completed Savage Island Part 1 on your archive? When on the raft, there should be four possible random locations: tidepool, ocean, atoll and beach. Only the first three locations seem to come up when I play it. Unless there is a game condition that needs to be met first? Otherwise it is a possible bug in the software? Please let me know either way.
I naively suggested he try using the solution at CASA. He replied:
In an email, Fr Grant Gorddard wrote:I have tried Savage Island 1 on another emulator [presumably emulating a different machine]. On this emulator, the game does work where paddling on the raft randomly takes you to all four locations: Tidepool, Ocean, Atoll, and Beach. I have just returned to this BBCMicro version of the game, and using a saved game as a starting point, and have just tried paddling until the raft falls to pieces (12 paddles) approximately 20 times. After 240 random events (plus many other opportunities when playing in the past), the Beach location has not once appeared, but the remaining three have all appeared many times. I’m sorry, but I’m thinking that this is indeed a bug on the BBCMicro version.
I investigated, and I discovered that Fr Grant Gorddard appeared to be correct. Here's the walkthrough I constructed to get you to the point in the game where you build the raft and sail it. (Note that the walkthrough can't be typed in verbatim because the game has loads of randomness in it and you are constantly at risk of having to start again from square one because you've randomly been killed by the weather or the bear!):

Code: Select all

EXAM HEAD
DIG
WITH HANDS
EXAM SAND
EXAM HOLE
GET BOTT
S
CLIMB VOLC
ENTER VOLC if not already in
ENTER CAVE
EMPTY BOTT
E
DROP BOTT
DROP WATCH
ENTER LAKE
SWIM WEST
WAIT till hurricane hits if it hasn't already
ENTER CREV
JUMP
E
E
GET LOG
W
S
CLIMB VOLC
ENTER VOLC if not already in
GET BOTT
ENTER LAKE
SWIM WEST
DROP BOTT
E
DROP LOG
HOLD BREATH
SWIM DOWN
SWIM NORTH
GET KNIFE
SWIM EAST
GET BLOCK
SWIM UP
GET LOG
SWIM WEST
DROP BLOCK
DROP KNIFE
DROP LOG
GET BOTT
ENTER CREV
JUMP
E
D
GET WATER
S
S
CLIMB VOLC
ENTER VOLC if not already in
ENTER CAVE
ENTER CREV
EMPTY BOTT
enter and re-enter CREV and do INVE or something till puddle turns into salt
GET SALT
ENTER CREV
DROP SALT
GET RUM
E
DROP BOTT
ENTER LAKE
SWIM WEST
GET LOG
E
SWIM EAST
GET BOTT
ENTER LAKE
SWIM WEST
DROP BOTT
E
SWIM EAST
U
ENTER LAKE
SWIM WEST
SLEEP
GET KNIFE
GET BLOCK
GET BOTT
GO CREV
JUMP
E
E
GET LOG
W
D
DROP LOG
S
S
GET LOG
N
CUT VINES
GET VINES
D
MAKE RAFT
ENTER RAFT
SAIL in random direction till you reach atoll
GO ATOLL
I informed Fr Gorddard that the best I could do, given the apparent bug (and not having the time or the skills to disassemble/debug the original Beeb version of the game) -- the best I could do was to create an aesthetically and performantly inferior version of the game by running the game data file adv10.dat through my BeebScott utility/terp. The resultant game is slow, but at least it seems to be bug-free up to the point where the raft gets you to the beach (and anyway you can increase the emulation-speed of BeebEm to 50 fps, and it fair rattles along!). See attached disc-image.

  • adv10.ssd
    BeebScottified version of adv10.dat (Savage Island 1)
    (200 KiB) Downloaded 39 times

Screenshot proving you can sail to the beach on the raft in my BeebScottified version of adv10.dat (Savage Island 1)
Screenshot proving you can sail to the beach on the raft in my BeebScottified version of adv10.dat (Savage Island 1)

Stardotter fuzzel then chimed in and pointed out an article (attached) in the May 1990 issue of the magazine Electron User, which discusses the raft/beach problem in the original version of Savage Island 1 for the Electron or the Beeb. (If there was a separate Acorn Electron version of the game, it probably used the same codebase as the BBC Micro version.) The article is from the regular text adventure column in Electron User, written by "Pendragon":
Pendragon wrote:Making the raft isn't such a chore, providing you are patient and scrupulous in your search for building materials ... However, sailing it is another matter entirely. Four ocean locations are randomly accessible by paddling the raft. An atoll, a tidepool and a beach may all also be reached. But the random factor operating for the latter [presumably he means the beach] is so high that it makes success almost impossible.
So, it looks like the original Electron/Beeb version of Savage Island 1 made it very difficult to reach the beach via the raft. This probably still counts as a bug -- or at least as a "sub-optimal" port of the game to the Beeb/Elk.

Anyone have any thoughts on any of this? Anyone able to debug the original Beeb version of the game and fix the randomness to make it easier to reach the beach..?!

:?: [-o<

image.png
Last edited by lurkio on Wed May 10, 2023 2:14 pm, edited 4 times in total.
User avatar
BeebMaster
Posts: 7379
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Bug in Savage Island 1 by Scott Adams..?

Post by BeebMaster »

Well, I did try. I did "LOAD "ADVENT1"" fully expecting Bad program, but I didn't get that, so I thought, "Aha, I have outgeneralled them here, it is BASIC after all, they've just changed the load and exec addresses to befuddle us! All I need to do is find the RND in the listing and add 1 on and that will fix it" but LIST didn't list anything. It is machine code, it loads at &1900 and executes at &1902 but the first two bytes are &0D, &FF which is an end of program marker, so it can be LOADed in BASIC without generating an error. Cunning!
Image
iamaran
Posts: 586
Joined: Tue Mar 14, 2006 8:08 pm
Contact:

Re: Bug in Savage Island 1 by Scott Adams..?

Post by iamaran »

Dave says this in his solution on EUG#59:
http://www.8bs.com/pool/eug/eug59.zip

"ADVENTURE Number 10 bills itself as of very high difficulty. In fact, it contains two of the most infuriating random event generators in the history of text adventuring. On its first release, magazines were bombarded with angry letters from purchasers convinced there was a bug in the code preventing the adventurer from progressing to the "beach" location. This is because, during the part of the game where you must sail a raft randomly east and west, the equivalent of something like only if RND(100)=1 will it appear. It usually takes HOURS before you get lucky; whenever you don't you get eaten by sharks."
User avatar
lurkio
Posts: 4351
Joined: Wed Apr 10, 2013 12:30 am
Location: Doomawangara
Contact:

Re: Bug in Savage Island 1 by Scott Adams..?

Post by lurkio »

iamaran wrote: Sun May 07, 2023 6:46 pm Dave says this in his solution on EUG#59: http://www.8bs.com/pool/eug/eug59.zip ...
Aha! Thanks! I've compiled a disc-image (attached) that contains the Beeb version of the game, together with the two saved positions (savegames) that Dave mentions in his two solution textfiles, which are also included on the disc-image: the textfiles are named SOL1 and SOL2, and to read the first one you can press Break (f12 (or File->Reset) in BeebEm) and then type the following (remembering to press the Shift key to scroll the text whenever it pauses on screen):

Code: Select all

MODE 3
VDU 14
*TYPE SOL1
When you've made the raft and want to sail it to the beach you can reboot the game and type Y when you're asked if you want to restore a previously saved game. The game will automatically load the first savegame, and you'll find yourself on the elusive beach!

When you've made further progress and want to reboot and load the second savegame, you must first press Break (f12 (or File->Reset) in BeebEm) and then type in the following, making sure that drive zero isn't write-protected (check the File menu in BeebEm):

Code: Select all

*RENAME ADV10 1.ADV10
*RENAME 2.ADV10 ADV10
That will "swap" the first and second savegames so that when you next boot the game and answer Y to the restore-question, the game will load the second savegame rather than the first.

The details of the differences between the two savegames are given in the aforementioned textfiles, SOL1 and SOL2.


:idea:
atsampson
Posts: 67
Joined: Fri Dec 16, 2022 4:54 pm
Location: Dundee, Scotland
Contact:

Re: Bug in Savage Island 1 by Scott Adams..?

Post by atsampson »

This sounded like a good excuse to play with py8dis! I've attached a file that partially disassembles the interpreter, including the game data (which has a more compact representation of actions than the basic Scott Adams format).

SAIL when in the boat is handled by actions 135, which continues into 136 and 137. If the player's in the raft location, it prints "Hard to steer this thing!", sets flag 10 and moves the four Ocean/Beach/Tidepool/Atoll objects back to room 0.

Those objects are made visible again by actions 47-50. Action 47 is an auto action which happens 15% of the time: if flag 10 is set, it clears it, moves Atoll back to the current room, and updates the room display. Action 48 is the same, but 40% and Tidepool; 49 is 30% and Beach, and finally 50 is 100% and Ocean. So in theory Beach should come up about 15% of the time when you SAIL. (Edited because I'd got the object numbers and percentages wrong here. Again.)

One place where I don't think it's quite behaving as intended is the interpreter's code to decide whether to run a randomised action, which starts around &29df...

Code: Select all

    jsr read_clock
.get_percentage
    cmp #100
    bcc check_random_action
    clc
    adc #75
    jmp get_percentage

.check_random_action
    sta temp1
    inc temp1
    lda current_action_noun
    sec
    sbc temp1
    bcc no_random_action
    ... continue into action ...
read_clock does OSWORD 1 and returns the least-significant byte in A. So it generates a "random" byte between 0-255, then repeatedly adds 75 until it's less than 100. This is a pretty biased RNG - the only way it can return 76-99 is if that was the original value. It would be interesting to stick a breakpoint in here and see what numbers it's actually coming up with in practice...
Attachments
savageisland1.py.txt
(5.69 KiB) Downloaded 36 times
Last edited by atsampson on Tue May 09, 2023 5:57 pm, edited 3 times in total.
User avatar
lurkio
Posts: 4351
Joined: Wed Apr 10, 2013 12:30 am
Location: Doomawangara
Contact:

Re: Bug in Savage Island 1 by Scott Adams..?

Post by lurkio »

atsampson wrote: Tue May 09, 2023 2:05 am This sounded like a good excuse to play with py8dis! I've attached a file that partially disassembles the interpreter, including the game data
Brilliant! Thanks for that! =D> =D> =D>

atsampson wrote: Tue May 09, 2023 2:05 am(which has a more compact representation of actions than the basic Scott Adams format)
What exactly is the format of that representation of the game data? Also, any chance you could write an outline of the structure of the game executable -- not necessarily a full disassembly (although that would be great!), but e.g. the start- and end-addresses of the various sections inside the exec (e.g. automatic actions, non-automatic actions, room-exits, etc.), sort of along the lines of this Apple II disassembly of Golden Voyage..?: [-o<

https://6502disassembly.com/a2-scott-ad ... oyage.html

(I'm hopeless at understanding the format/content of your py8dis output -- I just don't have the knowledge, and py8dis itself seems like sheer sorcery to me!) #-o

But presumably the existing biased RNG in the Beeb version of the game could be replaced with a fairer one, something like the following, perhaps (not that I fully understand it!)..?:

https:// codebase64.org/doku.php?id=base:small_fast_8-bit_prng EDIT: Just realised that only generates numbers from 0 to 255, and what we need is 0 to 99 !! (Told you I didn't understand it!)

Ultimately, as a stretch goal :wink:, you'd fix Stardotter tautology's beeb2sf utility, which is meant to analyse and "decompile" a Scott Adams or Brian Howarth adventure executable (Beeb version) and convert it to ScottFree format. I tried it but it didn't even seem to work on one of the games that its Readme claimed it should..!:

https://www.ifarchive.org/indexes/if-ar ... ams/tools/

(Not asking for much, am I..?!)

:wink: [-o<
atsampson
Posts: 67
Joined: Fri Dec 16, 2022 4:54 pm
Location: Dundee, Scotland
Contact:

Re: Bug in Savage Island 1 by Scott Adams..?

Post by atsampson »

atsampson wrote: Tue May 09, 2023 2:05 am It would be interesting to stick a breakpoint in here and see what numbers it's actually coming up with in practice...
Having tried this with b-em's debugger, the other shoe dropped. It's not just that it's a biased RNG, it's that the RNG's results aren't independent!

Because it's based on the time, unless the clock happens to tick in the middle of the four actions, the same number will be used for all four random choices. And since the probability for Beach (30%) is less than that for Tidepool (40%), there's no way for it to choose Beach unless the clock happens to tick between those two actions - which is very unlikely.

So replacing the RNG with a better one should fix it. It should be possible to swap out the routine I've called read_clock at &3370-&3381 - it just needs to return a random number from 0-99 (or 0-255 if you don't mind the bias).
atsampson
Posts: 67
Joined: Fri Dec 16, 2022 4:54 pm
Location: Dundee, Scotland
Contact:

Re: Bug in Savage Island 1 by Scott Adams..?

Post by atsampson »

lurkio wrote: Tue May 09, 2023 2:45 pmWhat exactly is the format of that representation of the game data? Also, any chance you could write an outline of the structure of the game executable
Here's what I was able to work out in terms of the game data by comparing it with ScottFree's adv10.dat:
  • The header fields start at &34ab - max_object, max_action, max_word, max_room, carry_capacity, starting_room, unknown (maybe num_treasures?), word_length.
  • Actions start at &34c3. Normally Scott Adams actions are 8 integers, most of which are 0 in a typical action. In this format, there's a word for the verb/noun as usual (verb*150+noun), then a byte &xy - x is the number of commands (2 or 4), y is the number of conditions (0 to 5). There's then a word for each condition (arg*20+cond) and a word for each pair of commands (cmd1*150+cmd2) as usual.
  • Verbs start at &3fa3 - each is 5 bytes, padded with zeroes.
  • Nouns start at &414c - as verbs.
  • Room names start at &42f5 - each is a 0-terminated string.
  • Room exits start at &45ef - each is 6 bytes, with the room number for N, S, E, W, U, D (I think) - room 0 means no exit.
  • Messages start at &46c1 - each is a 0-terminated string.
  • Object names start at &4d99 - each is a 0-terminated string with the usual * and /XYZ/ stuff.
  • Object initial locations (I think) start at &50fd - one byte for each object.
  • What looks like the action names start at &5138 - I didn't bother digging into these.
The startup code at &226a initialises a bunch of variables from the header fields. When it's iterating through actions, &82/&83 are a pointer to the current action.

There's a print routine at &21d0 that expects the word address of a message to follow the JSR, and adjusts its return address accordingly - I had to use a hook to get py8dis to disassemble this correctly.
atsampson
Posts: 67
Joined: Fri Dec 16, 2022 4:54 pm
Location: Dundee, Scotland
Contact:

Re: Bug in Savage Island 1 by Scott Adams..?

Post by atsampson »

Here's a very simple fix: change the probability of Action 49 in the game data from 30 to 55. Given the wonky RNG, this means there's about a 17% chance of the Beach being chosen when sailing, which is about the same as other platforms. I've attached a modified disk image with the appropriate byte changed, and checked that it does now come up:
beach.png
Attachments
Disc095-SavageIslandPart1-Adventure10-probfix.ssd
(200 KiB) Downloaded 36 times
User avatar
lurkio
Posts: 4351
Joined: Wed Apr 10, 2013 12:30 am
Location: Doomawangara
Contact:

Re: Bug in Savage Island 1 by Scott Adams..?

Post by lurkio »

atsampson wrote: Tue May 09, 2023 6:32 pm Here's a very simple fix: change the probability of Action 49 in the game data from 30 to 55. Given the wonky RNG, this means there's about a 17% chance of the Beach being chosen when sailing, which is about the same as other platforms.
Well, that's brilliant! I was hoping a simple good-enough fix would be possible, and, sure enough, you swooped in and saved the day by providing one! Thank you!

Here's your disc-image with the modified game executable, plus a savegame added by me. You can boot the game, answer Y to the "Restore" question, and then GO RAFT and SAIL repeatedly till you reach the beach -- which is actually possible in your modded version of the game!:


Thanks again!

=D> =D> =D>
Last edited by lurkio on Wed May 10, 2023 4:28 pm, edited 4 times in total.
Kweepa
Posts: 73
Joined: Mon Dec 16, 2013 11:45 pm
Contact:

Re: Bug in Savage Island 1 by Scott Adams..?

Post by Kweepa »

atsampson wrote: Tue May 09, 2023 3:21 pm
  • The header fields start at &34ab - max_object, max_action, max_word, max_room, carry_capacity, starting_room, unknown (maybe num_treasures?), word_length.
You are right, the number after starting_room is num_treasures.
I wrote a Scott Adams interpreter (for the VIC-20 - boo) and here is the header data format:
https://github.com/Kweepa/Yoho/blob/master/yoho.h
User avatar
lurkio
Posts: 4351
Joined: Wed Apr 10, 2013 12:30 am
Location: Doomawangara
Contact:

Re: Bug in Savage Island 1 by Scott Adams..?

Post by lurkio »

atsampson wrote: Tue May 09, 2023 6:32 pm Here's a very simple fix …
atsampson’s bugfixed version of Savage Island 1 is now available at bbcmicro.co.uk, the Complete BBC Micro Games Archive:

http://bbcmicro.co.uk/game.php?id=1708

:idea:
Post Reply

Return to “8-bit acorn software: classic adventure games”