So I never really fully read your first post.
Here is my opinion:
Quote:
I need to access any given room by its element name (instead of iterating the entire Map looking for a property matching a search term)..
You can do this with maps.
Iterating through a Linked List of 10.000 rooms will probably still be fast enough.
Also it can be done while still in the room. For example you have 3 exits then you search the roomlist for the three rooms behind each door upon entering the room.
If you use the mainloop for this instead of a dedicated ForEach-Loop you won't experience any lag. It's just background stuff.
I wouldn't store the objects in a room in a string but in a LinkedList.
You'd have to parse the string two times, if you want to add, delete or change an object.
Code:
Structure room
description.s
List objects.objectProperty()
List exits.exitProperty()
EndStructure
NewMap rooms.room()
With rooms("1x1")
\description = "You're standing in a small room with no windows. "
AddElement(\objects())
\objects()\name = "candle"
AddElement(\exits())
exits()\direction = "south"
EndWith
Parser, again: All commands are imperative and follow the following structure:
VERB (((adjective) SUBJECT) (adjective) SUBJECT)
You have to know your verbs. You have to know what the player could possible type.
You need a list of those verbs. (I never played a game like this, but maybe you have list of commands in the manual. So someting like "polish the mirror" would never occur, but only "clean" for example...)
It can't work when you only have "walk" on the list and the player types "Go north!"
Then you have a list of everything in the inventory and everything in the room (that's why those objects need to be stored in a list rather than a string).
Now you create a command-chain for every command.
PUT What? Where?
You'll need to check the list for of objects for nouns.
Again: The player can't use "backpack" when you use "bag". Except if they have the same ID.
"put my sword in my green pack"
We get: "PUT SWORD PACK"
Now it could be that there are two swords. Either in the room. Or one is in the room and one is already in the inventory/pack or you're holding it.
If there are two swords in the room you'll move one of them to the pack -> "You took 1 sword (One remains on the wall over the fireplace)"
If there's one in the room and you are holding one we have to look for an adjective. In this case "My". It's not an adjective but a pronomen, but it has the same purpose. It further describes our object.
So my put the sword, we're holding in our hand into our pack.
If there's no adjective we do nothing and just say: "I'm confused..."
Same goes for "my sword" and we don't have a sword. Then the player is confused.
So we put a sword determined by the adjectives into our pack. "My" and "Green" are ignored unless there are more than one.
Polish:
POLISH What? Using_What?/How?
There are two possibilities.
Polish the mirror with the rag (obviuos command, if you have a rag. If not, simply: "I don't have a rag")
Polish the mirror thouroughly (may result in: "I don't have a cloth" or "You polished the mirror with a rag that lay on th floor/that you had in your inventory".)
As for the attack. Why would anyone write "attack the third monster" unless you imply it in the room description "A third monster appears".
The command-chain for attack would be:
ATTACK Who?/What?
In this case: Attack Monster. "third" is ignored.
Or you could add a list of cardinal numbers if it makes sense. In this case it doesn't, imho. But you're the one who played games like these, not me.
>>"put my sword in the green sheath that is on the stool, on the red table"... lol? (probably two or three ways to interpret that)
No only one way. PUT what? where?
Put my Sword in the sheath. Everything else is ignored.
You ignore everything but the basic command-chain (I'm sorry, I keep saying this word. It's not really a command-chain. I mean the very basics needed to form an understandable command. Verb + Object (+Object......))
Only if the basics are not enough (that's only the case if you have more than one object) you go looking for additional information.
>>I think I read somewhere one idea for a parser was to assign keywords numerical values
That's called bytecode.
>>and somehow when tokenized and parsed out they would add up to the proper value to trigger the correct command...
That's possible but if you have 20 commands like put, go, attack and 100 objects like sword, pack, that's commands * objects^2 = 200.000 unique command IDs.
Take 200 objects and 30 commands and you're facing 1.2 millions.
And now imagine you need to refer to the sword, by "sword", weapon", "double handed sword", "master sword"... Suddenly you're on the billions.
I don't think that's the way to go for your game.
>>I was wondering about using a LinkedList in the process somehow...or should I just stick with an IF / ENDIF or perhaps CASE / SELECT ??
You need to store the verbs, objects and descripting words like "my", "red", "on the floor" in a list or an array. You can't get those from the string everytime. It's too complicated and messy.
The comparison still needs to use If or Select.
Imho
Select is cleaner in code, but it really makes no difference speed-wise.
Afaik it's the same in ASM.