Well, I managed to finish my horror themed text adventure today and have posted the files to the repository so those of you who can't wait five days and know how to compile java can download and play episode 57 of the Ultimate Retro Project early (in the unlikely event that any exist). The development of this game was quite quick due to the fact that the two main parts of the engine, the room management and the parser, had already been written (at least partially) for other games in the ultimate retro series. Still, when adventures are concerned, the parser is very important. I opted for a simple two word parser which was used by a lot of adventure games.
A two word parser is actually one of the easier things to implement. This is because the format is very straight forward. You have a verb followed by a noun. Both the verbs and the nouns can be grouped into a list and you can then simply look up the command on the list and turn the command into a number representing the action and a number representing the object that the action is being applied to. My parser is slightly more sophisticated then this.
At the heart of my parser is the command class which holds a number that represents the verb and a number that represents the noun. The word, however, is not a single word for each command but a list of words that represent that command. The list of words are stored in a Word class that also holds other info about the word that I do not take full advantage of. A sentence class, which consists of a word class for the verb and a list of words that can be used for the noun (after all, some commands may have different nouns that can be used such as in the case of the move command) forms the basis of the command architecture. Finally, the parser class consists of a list of sentences that the game can understand.
After the parser command has processed the input string, you are left with a command. The ID of the verb is used to determine what to do and the ID of the noun is used to additionally quantify the action being performed.
While I was hoping to have a generic adventure creation engine by the end of this episode, puzzles tend to require a lot of condition processing. I was not about to spend far too much time writing a simple scripting language that could handle the condition processing so the final code is a bit too integrated with the data files than I would like. I think the time for text adventures is over and I have far better projects to work on so a general purpose text adventure game engine will not be coming from me any time soon, though there are already a number of them that already exist.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment