The Hobbit : Exploring Wilderland in BASIC

development and releases of new/rewritten text adventures
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

The Hobbit : Exploring Wilderland in BASIC

Post by Tosk »

Image

My next BASIC coding project is to squeeze a very simplified version of the classic text adventure game "The Hobbit" by Veronika Megler, Philip Mitchell and David Johnston into a BBC Basic program. This would be for a 32K BBC Model B. I'll be using the Owlet editor in the main and cross checking the code on my own BBC Micro.

Like many of you, I enjoyed this landmark game and it stuck in memory. I coded some of my own text adventures at the time and was fascinated with the process....certainly nudging me towards a database programming career later on in life. Let me know some of your own memories, experiences with this game - I'd like to hear them.

This project is mostly for nostalgia, but also taking on the challenge of squeezing a very simplified form of this landmark game into a BBC Basic version. Like many retro coding projects you think .... "Why not?"

My objectives are:-

1. To represent every location in the game in BBC basic, using tokens for the common words to save space.
2. To navigate between all the locations using the original mappings (though I may exclude the random-like maddening mazes such as the Dark Stuffy Passage)
3. To emulate the split screen user interface that the Hobbit had, with input text in the bottom quarter of the screen and output text in the top.
4. To keep everything in one program, not reading other files.

If there's any memory left (I'll use MODE 7) then we'll see what else could be added. It would be fantastic to include NPCs wandering around the game map randomly, such as Thorin and/or Gandalf, so you could meet them as you wander.

My objectives are not:-

1. To have a clever parser. It's just to input directions, to allow an easy exploration of the Wilderland.

Resources


The book "The Guide to Playing the Hobbit" by David Elkan (which I used to own) which gives a great breakdown of the game (from the internet archive)
https://archive.org/download/guide-to-p ... Hobbit.pdf

Veronikia Megler's website (one of the original authors of the game) includes some really useful information:-
http://veronikamegler.com/WL/wl.htm

- A map
- Room Database dump of the locations
- Even a rudimentary Spectrum emulator, displaying the state of the elements in the game

Using ChatGPT (ver 4)

For this project I've been using ChatGPT to start to compile the word tokens and the locations converted into text with token indexes inserted. It's done quite well with this. I asked ChatGPT to look at this list of locations and pull out all common words that are greater than two characters:-

Beorn's house
The Bewitched gloomy place
A big cavern with torches along the walls
A bleak barren land that was once green
The cellar where the king keeps his barrels of wine.
A comfortable tunnel-like hall.
A dark dungeon in the elven king's halls.
The dark stuffy passage
The dark winding passage
The east bank of a black river
The elven king's great halls
An elvish clearing with levelled ground and logs
The empty place
The forest
A forest of tangled smothering trees
The forest road
The forest road
Forest river
The front gate of the Lonely Mountain
The gate to Mirkwood
A gloomy empty land with dreary hills ahead
The goblins' dungeon
The great river
The green forest
The halls where the dragon sleeps
A hard dangerous path in the Misty Mountains
A hidden path with trolls' footprints
Inside the goblins' gate
A large dry cave which is quite comfortable
A little steep bay, still and quiet, with an overhanging cliff.
The Lonely Mountain
Long Lake
The mountains
A narrow path
A narrow dangerous path
A narrow place with a dreadful drop into a dim valley
Outside goblins' gate
A place of black spiders
Rivendell
The ruins of the town of Dale
The running river
A smooth straight passage
A strong river
The treeless opening
The troll's cave
The troll's clearing
The waterfall
The west bank of a black river
The west side of Ravenhill
A wooden town in the middle of Long Lake

Common words (tokens) that ChatGPT found (here shown stored in DATA statements):-

800 DATA "the","with","river","forest","place","gate","path","dark","passage"
810 DATA "black","goblins'","narrow","gloomy","land","green","where","comfortable","dungeon"
820 DATA "elven","king's","bank","great","halls","clearing","and","empty","lonely"
830 DATA "mountain","dangerous","mountains","cave","long","lake","town","troll's","west"

...and the resulting location descriptions with indexes inserted representing the word token (this was also generated by ChatGPT):-

900 DATA Beorn's house,01 Bewitched 13 04,A big cavern 02 torches along 01 walls,A bleak barren 14 that was once 15,01 cellar 16 01 king keeps his barrels of wine.
910 DATA A 17 tunnel-like hall.,A 18 dungeon in 01 elven king's halls.,01 18 stuffy 09,01 18 winding 09,01 east 20 of a 10 03
920 DATA 01 elven king's 22 halls,An elvish 24 02 levelled ground 24 logs,01 25 04,01 05,A 05 of tangled smothering trees
930 DATA 01 05 road,01 05 road,05 03,01 front 20 of 01 Lonely Mountain,01 20 to Mirkwood
940 DATA A 13 25 14 02 dreary hills ahead,01 goblins' dungeon,01 22 03,01 15 05,01 halls 16 01 dragon sleeps
950 DATA A hard 18 20 in 01 Misty Mountains,A hidden 20 02 trolls' footprints,Inside 01 goblins' 20,A large dry 31 02 is quite 17,A little steep bay, still and quiet, 02 an overhanging cliff.
960 DATA 01 Lonely Mountain,Long Lake,01 mountains,A 12 20,A 12 18 20
970 DATA A 12 04 02 a dreadful drop into a dim valley,Outside goblins' 20,A 04 of 10 spiders,Rivendell,01 ruins of 01 34 of Dale
980 DATA 01 running 03,A smooth straight 09,A strong 03,01 treeless opening,01 troll's 31
990 DATA 01 troll's 24,01 waterfall,01 west 20 of a 10 03,01 west side of Ravenhill,A wooden 34 in 01 middle of Long Lake

Location Exit Data

Each location has data in this format:-

"01202807506605103"

The first two digits are the location, followed by at least one group of 3 digits.

Each 3-digit block represents an exit, with the first digit for the direction (1 for North, 2 for Northeast, etc., 0 for Down, and 9 for Up) and the next two digits for the destination location number

I had ChatGPT read "The Guide to Playing the Hobbit" and had a go at creating the exit data, but it's pretty bad - and this needs redoing by hand!

I need to:-

a) Resolve a bug with unpacking the room descriptions properly. It doesn't convert the token value that lies at the end of a location description string into the corresponding word.
b) Go through all the exit data to check and replace as required (done)
c) Allow the input of directions to include shorthand as well as longhand for the directions (North and N for example).
d) Cross check the common word token replacements. I think ChatGPT has made some mistakes.
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
shadow
Posts: 9
Joined: Sun Jan 21, 2024 10:08 pm
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by shadow »

Unfortunately I never got to play the hobbit text adventure growing up, although I played quite a few of them. I did read the book though, so I have a sort of second-hand nostalgia for the game, having seen various screenshots of it over the years. :)
Anyway, this is mostly just an encouraging post to continue the project. I'm fascinated by your use of ChatGPT. I'm hopeful that by the time GPT-5 rolls around it will have more extensive and helpful knowledge of these old systems, but I like the idea of you using it to do some of the busy work for you. (Even if you have to double-check it) :lol:
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by Lardo Boffin »

Excellent project!

I also didn’t play this BITD but have recently read The Hobbit with my son. I mentioned that there was a game of the book on one of my ‘old computers’ which we played but he found it hard going even knowing how the book goes.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC : 1st version

Post by Tosk »

Here's a first version that allows a player to move around Wilderland. You do need to use numbers instead of shorthand for directions at this point ( 0
= down, 1 = N, 2 = NE, 3 = E, 4 = SE, 5 = S, 6 = SW, 7 =W, 8 = NW, 9 = up) . There is no validation as you enter a number - so it's all very crude coding at this point.

Exit data and token data for locations were not so well conceived by ChatGPT, so I manually checked all of it and I think it's now pretty sound.

It was interesting to get ChatGPT to try and read and study "A Guide to Playing the Hobbit" and help me code bits of this, especially in generating at least a foundation of the needed data from the book. I do need to educate ChatGPT properly about the version of BBC Basic (version 1) I'm using, since it continually tries to use ENDIF and other anomalies creep in; I'm guessing it is referencing on later versions.

Here's my ChatGPT prompts so far:-

https://chat.openai.com/share/2a793de5- ... 63a80d8b91

But I can see that common token words that should have been replaced by an index remain in the location descriptions (ChatGPT seemed to skip some) - so that needs work.

But I'm pretty happy that you can now move around Wilderland and explore without having to do any puzzles!

The variable seeExitDesc when set to 1 allows you to get the exits and descriptions of the other locations around your current location - this was especially good for debugging the exit data for each location. If you set this to 0, then only the exits are listed.

What I'll work on next:-

1) Ensuring that any remaining common token words in the location descriptions are replaced by the required index
2) Justification of the text on the screen is messy, so a function to take care of that.
3) Allow the player to use the expected direction inputs (N,NE,U,D and the longhand versions), rather than numbers.

https://bbcmic.ro/#%7B%22v%22%3A1%2C%22 ... Cn%22%7D
Last edited by Tosk on Sun Mar 24, 2024 2:42 pm, edited 1 time in total.
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
dr_d_gee
Posts: 29
Joined: Thu Feb 01, 2024 6:53 pm
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by dr_d_gee »

Aren't you actually using version 2? ENDIF is from version 5 on RISC OS, which allows multi-line IF…THEN blocks.
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by Tosk »

dr_d_gee wrote: Tue Feb 27, 2024 3:06 pm Aren't you actually using version 2? ENDIF is from version 5 on RISC OS, which allows multi-line IF…THEN blocks.
Ah yes - thanks for the correction. I can see from here that only early version BBC Micros were shipped with version 1

https://en.wikipedia.org/wiki/BBC_BASIC
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
fuzzel
Posts: 1191
Joined: Sun Jan 02, 2005 1:16 pm
Location: Cullercoats, North Tyneside
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by fuzzel »

This is a great project Tosk, looking forward to see how far you get with it. I had the tape version without graphics and as I recall it used virtually all available ram so I'm curious to see how much you manage to squeeze in with your Basic program. I've written a few text adventures myself and one area I'd like to have explored further are the NPCs so I hope you have a bit of space for these. I've never actually played the Hobbit again since bitd; I never solved it and I think it boiled down to the unpredictability of the characters rather than any particular puzzles being difficult. I recall there being a barrel which you had to manipulate and needing the help of another character which proved challenging to say the least. You've certainly whetted my appetite for the game so I might have another look again at it. Also, using Beebem at x2 speed it'll be more playable, I also recall it being a bit slow.
Good luck!
EDIT: I wonder if there's any detailed info on the web about the NPCs and what their capabilities were? Eg, were they confined to certain parts of the game (unless you got them to follow you) and what their attributes were (hit points (stamina), damage they can inflict etc).
User avatar
ash73
Posts: 223
Joined: Wed Feb 03, 2016 10:51 pm
Location: Cheshire, UK
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by ash73 »

Loved this game when I was a kid, particularly the NPCs that roamed about and how you could influence their behaviour, and the database structure to all the objects, and the graphics, and the buggy humour/exploits. I wrote to Veronika about the game a while back and got a nice reply.

I've been meaning to write a new text adventure for a while with intelligent NPCs, must get around to it at some point.

Shame the Beeb didn't have a 80 column teletext mode, would have suited text adventures so well.
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by Tosk »

fuzzel wrote: Wed Feb 28, 2024 3:50 pm
EDIT: I wonder if there's any detailed info on the web about the NPCs and what their capabilities were? Eg, were they confined to certain parts of the game (unless you got them to follow you) and what their attributes were (hit points (stamina), damage they can inflict etc).
Thanks Fuzzel. On Veronika's website there is a program you can download and run the Hobbit in an emulator that also shows the state of the NPCs and objects. Note the read me file image that shows you how to install and run it on a PC.

http://veronikamegler.com/WL/wl.htm
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by Tosk »

ash73 wrote: Wed Feb 28, 2024 6:21 pm Loved this game when I was a kid, particularly the NPCs that roamed about and how you could influence their behaviour, and the database structure to all the objects, and the graphics, and the buggy humour/exploits. I wrote to Veronika about the game a while back and got a nice reply.

I've been meaning to write a new text adventure for a while with intelligent NPCs, must get around to it at some point.

Shame the Beeb didn't have a 80 column teletext mode, would have suited text adventures so well.
This was also my favourite retro game at the time; I also enjoyed the Lord of the Rings, but was miffed a bit when Melbourne House did not release Part 2 for the BBC Micro.

I'm reasonably hopeful to squeeze in code to have at least one of the original NPCs (Gandalf?) wandering around the locations randomly.
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
B3_B3_B3
Posts: 404
Joined: Sat Apr 08, 2017 10:42 pm
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by B3_B3_B3 »

Very Interesting. It occurred to me to try to make a minimalist hobbit using the Usbourne Write Your Own Adventure skeleton but not yet.....

My actual bbc of the Hobbit crashed a lot but at least I got to read the book :)
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by Tosk »

B3_B3_B3 wrote: Thu Feb 29, 2024 8:16 pm Very Interesting. It occurred to me to try to make a minimalist hobbit using the Usbourne Write Your Own Adventure skeleton but not yet.....

My actual bbc of the Hobbit crashed a lot but at least I got to read the book :)
That's a cool sounding book and I seemed to quickly find a PDF of this online; the publication certainly seems out of print. Looks interesting.

https://colorcomputerarchive.com/repo/D ... borne).pdf
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
dr_d_gee
Posts: 29
Joined: Thu Feb 01, 2024 6:53 pm
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by dr_d_gee »

Most of the old Usborne books have been reissued in PDF form, free of charge.
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC : The UI for the Hobbit: Learning VDU 28

Post by Tosk »

Here's just a short demo as I've learned about VDU 28 this evening (text windows).

This provides a demo of recreating the Hobbit user interface, with an output text window as well as the input window. This is one feature of the Hobbit I really liked, providing a little more organisation. You get a better sense of interacting with the story world and your effect upon it as you type in commands.

This includes

1) Procedures to call and set up either window (you can only have one text window at a time). I've turned off the cursor when the Output window is initialised.
2) A procedure to format text for the output window
3) A simple parser to check for single word valid commands

https://bbcmic.ro/#%7B%22v%22%3A1%2C%22 ... QUIT%22%7D


Image
Last edited by Tosk on Sun Mar 24, 2024 2:42 pm, edited 1 time in total.
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC : Progress in the Wilderland: UI, game loop and more

Post by Tosk »

I've now introduced the UI, a proper game loop, formatting of text in the output window and recognising the 10 command directions (abbreviations). The simple parser will let you know if it doesn't recognise a single word command.

Bugs include:-

1) Inability to recognise the long hand command directions or any other long hand word in the commandset$ variable. It's probably something simple - first I'll check if INSTR is case sensitive.
2) Formatting of text seems to be iffy sometimes. Example is if you go East initially to "a gloomy empty land", then the second exit and also last exit described from this location is cut off ("West to a comfortable").

I also want to optimise the code for the parser when it works out the direction input and assigns directionNum; this is quite crude at the moment.

It's nice to see a very rough approximation of the Hobbit taking place.

https://bbcmic.ro/#%7B%22v%22%3A1%2C%22 ... 5Cn%22%7D
Last edited by Tosk on Sun Mar 24, 2024 2:41 pm, edited 1 time in total.
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
dr_d_gee
Posts: 29
Joined: Thu Feb 01, 2024 6:53 pm
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by dr_d_gee »

Perhaps you're running up against the maximum string length of 255 characters?
User avatar
lovebug
Posts: 1739
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by lovebug »

Looks great :+1: :+1: :+1: :+1: :+1:
Image Image Image Image
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC : Format of output text fixed

Post by Tosk »

The format of text issue is solved. This was due to the way that the text line was being built up in the loop as it was gaining the description from each exit.

The SeeExitDesc variable can be set to 0 instead of 1 to just list the exit directions without the accompanying exit location descriptions.

Ideally I want to add doors to the coding and to have the code recognise if a door is shut, you can't go in that direction, but you can "see" the door as part of the list of exits.

https://bbcmic.ro/#%7B%22v%22%3A1%2C%22 ... %5Cn%22%7D

Image
Last edited by Tosk on Sun Mar 24, 2024 2:41 pm, edited 1 time in total.
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
fuzzel
Posts: 1191
Joined: Sun Jan 02, 2005 1:16 pm
Location: Cullercoats, North Tyneside
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by fuzzel »

Looking very good. I've never used Owlet but as it's a web-based BBC Basic program does that mean the program size can be unlimited?
I was also wondering about your colour scheme, you've gone for dark blue text on a white background for the input and output windows and I wondered whether you preferred these colours or whether it's based on a particular Hobbit version? My BBC version has dark blue text and a cyan background for output text and a white background for input text. I know these text windows can be a bit fiddly to program, as I recall when experimenting with them once upon a time I'd sometimes lose or gain a line of background colour, my eventual solution was to have four windows, the left two were very narrow containing the formatting for the foreground and background colours and the right two contained the text (obviously with fewer characters per line). This way the two formatting windows were set up at the start and I never had to worry about the formatting again. I also had to use VPOS to keep track of which row the text was on when toggling between the windows.
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by Tosk »

fuzzel wrote: Thu Mar 21, 2024 11:21 am Looking very good. I've never used Owlet but as it's a web-based BBC Basic program does that mean the program size can be unlimited?
I was also wondering about your colour scheme, you've gone for dark blue text on a white background for the input and output windows and I wondered whether you preferred these colours or whether it's based on a particular Hobbit version? My BBC version has dark blue text and a cyan background for output text and a white background for input text. I know these text windows can be a bit fiddly to program, as I recall when experimenting with them once upon a time I'd sometimes lose or gain a line of background colour, my eventual solution was to have four windows, the left two were very narrow containing the formatting for the foreground and background colours and the right two contained the text (obviously with fewer characters per line). This way the two formatting windows were set up at the start and I never had to worry about the formatting again. I also had to use VPOS to keep track of which row the text was on when toggling between the windows.
Owlet emulates the BBC Micro B memory exactly as far as I can see, so you are limited in memory, depending on which MODE you are working in.

The colour scheme is just my preference at the moment, it's not matched to any particular version of the Hobbit.

I force a new line at the bottom of the input and ouput text windows and this seems to generally work, but I'm slightly unhappy with the bottom line appearing unformatted and flashing a bit as the text is forced into it. I may look into your approach to see if this gets rid of that problem - thanks for the suggestion.
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Colour schemes and text windows

Post by Tosk »

fuzzel wrote: Thu Mar 21, 2024 11:21 am Looking very good. I've never used Owlet but as it's a web-based BBC Basic program does that mean the program size can be unlimited?
I was also wondering about your colour scheme, you've gone for dark blue text on a white background for the input and output windows and I wondered whether you preferred these colours or whether it's based on a particular Hobbit version? My BBC version has dark blue text and a cyan background for output text and a white background for input text. I know these text windows can be a bit fiddly to program, as I recall when experimenting with them once upon a time I'd sometimes lose or gain a line of background colour, my eventual solution was to have four windows, the left two were very narrow containing the formatting for the foreground and background colours and the right two contained the text (obviously with fewer characters per line). This way the two formatting windows were set up at the start and I never had to worry about the formatting again. I also had to use VPOS to keep track of which row the text was on when toggling between the windows.
Owlet emulates the BBC Micro B memory exactly as far as I can see, so you are limited in memory, depending on which MODE you are working in.

The colour scheme is just my preference at the moment, it's not matched to any particular version of the Hobbit.

I force a new line at the bottom of the input and ouput text windows and this seems to generally work, but I'm slightly unhappy with the bottom line appearing unformatted and flashing a bit as the text is forced into it. I may look into your approach to see if this gets rid of that problem - thanks for the suggestion.
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC : Longhand/shorthand commands now recognised

Post by Tosk »

I've now streamlined the simple parser to recognise shorthand and longhand commands (eg N and NORTH).

https://bbcmic.ro/#%7B%22v%22%3A1%2C%22 ... %5Cn%22%7D
Last edited by Tosk on Mon Mar 25, 2024 4:39 pm, edited 5 times in total.
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
User avatar
BeebMaster
Posts: 7379
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by BeebMaster »

Looks like good progress!

Although I don't think it's necessarily a good idea to be updating the topic title with new developments, as it loses the context of the subject matter when it shows up in the thread listing.

(My reply automatically reverts to the original title, as I think only the original poster can change it.)
Image
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by Tosk »

BeebMaster wrote: Sat Mar 23, 2024 2:04 pm Looks like good progress!

Although I don't think it's necessarily a good idea to be updating the topic title with new developments, as it loses the context of the subject matter when it shows up in the thread listing.

(My reply automatically reverts to the original title, as I think only the original poster can change it.)
Have included the topic title with a subtitle on my post replies.
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC - now with an NPC (Thorin)

Post by Tosk »

Here's a review of the current code including definitions of the variables, procedures and functions. The latest code is at the bottom of this post.

The latest version now includes an NPC (Thorin) moving around the map randomly. He starts off with you in the "Comfortable tunnel-like hall" and will wander off by himself.

Unfortunately there's a bug! which I'm having difficulty in solving. I am open to forum members trying to solve this particular bug.


As Thorin moves around the map, the player inevitably picks up the current location exit data of Thorin. You can't necessarily exit your current location since the available exits are mirroring where Thorin is.

I suspect playerExits$ or currentLoc somehow picks up Thorin's data. I've tried to track this down....but to no avail just yet.

Variables

- `words$`: An array holding word tokens used in the game, possibly for item names or actions.
- `locDesc$`: Stores descriptions of various locations in the game world.
- `exits$`: Contains information on the exits from each location, detailing where each exit leads.
- `commandset$`: An array defining game commands, each with a short and long form, facilitating player interactions.
- `npc$`: Represents non-player characters (NPCs) in the game. Each NPC has a name, a location, and potentially exits or actions they can perform.
- `currentLoc`: The player's current location in the game world.
- `seeExitDesc`: A flag to determine if the game should describe visible exits in the current location.
- `COMMAND$`: A string variable that stores the player's current command input.
- `K$`: Used to capture individual key presses from the player.
- `valid%`: Indicates whether the player's command input is valid (recognized by the game).
- `npcmoves`: Determines the movement behavior of an NPC during the game loop.
- `npcLoc`: Stores the location of an NPC, specifically used for comparison and output purposes in `PROC_NPC`.
- `rndexit`: Used within NPC movement logic to select a random exit for an NPC to take.
- `npcdirNum`: The direction number corresponding to the `rndexit` chosen for the NPC movement.
- `directionNum`: Stores the numeric representation of the direction in which either the player or an NPC is attempting to move.
- `allowedToExit`: A flag used to check if the movement in the attempted direction is possible from the current location.
- `playerExits$`: Stores the exits available to the player from their current location.
- `exitblock$`: A substring of `exits$` that contains the exit data for a specific direction from the current location.

### Procedures

- `PROC_SetWinOutput`:
- Sets up the output window for the game's main text display by defining its viewport. This is where game descriptions and narratives are shown.

- `PROC_SetWinInput`:
- Configures the input window where the player can type commands. This area is separate from the main game text to keep commands and narrative distinct.

- `PROC_Look(currentLoc, npc)`:
- Displays the description of the current location (`currentLoc`) and the visible exits. If `npc` is 0 (player), it shows information relevant to the player. If `npc` is greater than 0, it's used to handle NPC-specific views, mainly affecting their known exits.

- `PROC_NPC`:
- Manages NPC movements and interactions. It randomly decides if NPCs stay or move and updates their locations accordingly. Also handles the display of NPC movements and actions.

- `PROC_MoveCheck(valid%)`:
- Validates and executes movement commands based on the direction (`valid%`). It checks if the direction is allowed from the current location and updates the location accordingly.

- `PROC_MovePlayer(directionNum, npc)`:
- Moves the player or an NPC (`npc` parameter) in a specified direction (`directionNum`). Updates the current location or the NPC's location based on the movement.

- `PROC_OutputText(text$)`:
- Outputs text to the game window, handling formatting for different lengths of text. It decides whether to use `PROC_FormatText` or `PROC_FormatShortText` based on text length.

- `PROC_FormatText(text$)`:
- Formats and outputs longer text passages to the game window, ensuring text wraps correctly and adheres to display constraints.

- `PROC_FormatShortText(text$)`:
- Handles the output of shorter text strings to the game window, applying necessary formatting.

### Functions

- `FN_GetLocDesc(currentLoc)`:
- Returns a formatted description of the current location (`currentLoc`), replacing tokens with words for dynamic description generation.

- `FN_IdentCommand(COMMAND$)`:
- Identifies and returns the index of a recognized game command from `COMMAND$`, allowing the game to process player inputs based on command set definitions.

- `FN_lowercaseWord(word$)`:
- Converts and returns the given `word$` to lowercase. Useful for text formatting and ensuring case-insensitive command processing.

Current code
(includes a few debug PRINT statements showing some current state of variables in the output window)

https://bbcmic.ro/#%7B%22v%22%3A1%2C%22 ... 5Cn%22%7D
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
shadow
Posts: 9
Joined: Sun Jan 21, 2024 10:08 pm
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by shadow »

Hey, I had a look at the code to see if I could spot anything going awry.
When Thorin moves, it calls PROC_NPC which calls PROC_LOOK at his location. This changes the value of e$ to reflect his exits. After he moves, the player moves, but it's accessing this now changed e$ value.
I have no idea if this is the cause of your bug, but it's the only thing I could spot after a while staring at it all.
fuzzel
Posts: 1191
Joined: Sun Jan 02, 2005 1:16 pm
Location: Cullercoats, North Tyneside
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC - now with an NPC (Thorin)

Post by fuzzel »

Tosk wrote: Wed Apr 10, 2024 8:44 pm The latest version now includes an NPC (Thorin) moving around the map randomly. He starts off with you in the "Comfortable tunnel-like hall" and will wander off by himself.
It might be worth you trying to implement the Thorin movement rules from the game. He never seems to take the initiative unlike Gandalf who's always wandering off but is happy to follow you around. I'd say when you move he'll follow you 90%-95% of the time and if you're within one location of him he'll catch you up the next move. Get two locations away though and he'll either stay there until you go back to him or he'll start randomly wandering (I haven't checked yet which of these holds true). However, just to complicate things I've just tried testing my theory on the east-west road as to how often he immediately catches you up and he seems to do it all the time!
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by Tosk »

shadow wrote: Fri Apr 12, 2024 2:41 am Hey, I had a look at the code to see if I could spot anything going awry.
When Thorin moves, it calls PROC_NPC which calls PROC_LOOK at his location. This changes the value of e$ to reflect his exits. After he moves, the player moves, but it's accessing this now changed e$ value.
I have no idea if this is the cause of your bug, but it's the only thing I could spot after a while staring at it all.
Thank you so much shadow! This was exactly the cause of the bug. e$ was picking up the last location of the player as well as the NPC (Thorin) - it was a typical error introduced by copying and pasting code from elsewhere.

I've changed the lines to:-

3516 IF npc > 0 THEN MovePlayerExits$ = exits$(VAL(npc$(npc,2))) ELSE MovePlayerExits$ = exits$(currentLoc)
3520 exitblock$ = MID$(MovePlayerExits$, 3+((allowedToExit-1)*3), 3)

A new variable MovePlayerExits$ is set to the available exits of either the player or the NPC depending on the npc parameter passed to PROC_MovePlayer(directionNum,npc) - if the npc = 0 it means we are moving the player, if it is above 0 - then it is one of the NPCs.

The corrected code is now this:-

https://bbcmic.ro/#%7B%22v%22%3A1%2C%22 ... %5Cn%22%7D
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC - now with an NPC (Thorin)

Post by Tosk »

fuzzel wrote: Sun Apr 14, 2024 4:23 pm
Tosk wrote: Wed Apr 10, 2024 8:44 pm The latest version now includes an NPC (Thorin) moving around the map randomly. He starts off with you in the "Comfortable tunnel-like hall" and will wander off by himself.
It might be worth you trying to implement the Thorin movement rules from the game. He never seems to take the initiative unlike Gandalf who's always wandering off but is happy to follow you around. I'd say when you move he'll follow you 90%-95% of the time and if you're within one location of him he'll catch you up the next move. Get two locations away though and he'll either stay there until you go back to him or he'll start randomly wandering (I haven't checked yet which of these holds true). However, just to complicate things I've just tried testing my theory on the east-west road as to how often he immediately catches you up and he seems to do it all the time!
Thanks for the idea fuzzel and it's interesting to try and figure out the inner workings of Thorin and Gandalf!

I had inklings of trying out some kind of simple different behaviours for the NPCs. At the moment I've coded the general rule that an NPC will stay in a location 1/3 of the time and 2/3 of the time they will move. It would be fairly easy to have a different ratio of "stay or go" for each character so they behaved a bit differently - so may implement just that.
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
User avatar
Tosk
Posts: 150
Joined: Mon Sep 25, 2023 10:52 am
Location: Falkirk, Scotland
Contact:

Re: The Hobbit : Exploring Wilderland in BASIC

Post by Tosk »

Latest version.

Now with NPCs wandering around the map randomly.
You can see where the NPCs are with the command "NPC"
Objects are included which you can take and drop and invent. At the moment you can only DROP everything or TAKE everything in a location.
NPCs almost have the ability to take and drop things randomly....this aspect needs finishing off.

Still need to work on doors, opening and closing.

Enjoy!

https://bbcmic.ro/#%7B%22v%22%3A1%2C%22 ... %5Cn%22%7D
Acorn BBC Micro Model B 32K - O.S. 1.2 - Basic v2 - Issue 7 motherboard - Opus DDOS DFS, MMFS Solid State Drive, Graphics Extension ROM and Gotek https://retrorendezvous.org/
Post Reply

Return to “new projects and releases: text and graphic adventures”