Sign in to follow this  

Text-based RPG

Recommended Posts

MSalley    109
Most text-based RPG's I've seen have taken any variety of commands, such as "go north," or just "north". How do I make the gameplay like that? I don't want it to be like, North=press 1 south=press 2 But You can go north or south. >go north you have gone north...

Share this post

Link to post
Share on other sites
supercoder74    154
either go through the possible choices using std::string:


or make some kind of interpreter thing(recommended), so if you do something like "use well" then you would first tokenize it into "use" and "well", then your program would recognise "use" so then it would then do whatever action with the word "well".

Share this post

Link to post
Share on other sites
dalep    331
You may or may not care about this history of these games, but they are among the oldest computer games in the world and originated in AI research at MIT in the early 1960s. This input model was, they thought, going to mature in short order into natural language interfaces. Well, we're still waiting for that. ;)

Anyhow, since you're not trying to write HAL2000, you can just look at incoming strings for keywords and branch to the function that handles the command.

In pseudo code:

if (token == "north") then call move_player(north);
if (token == "south") then call move_player(south);

Or however. You only care about the north part. So any string they user types that includes "north" will move them north. If they type "banana mopar popot north" the same thing will happen. That's the simplest approach.

Share this post

Link to post
Share on other sites
Trapper Zoid    1370
This is the method used in the old text-based adventure games, so if you search for buzzwords like "text parser" with "interactive ficition", "adventure game", "Infocom" or "Zork" etc., you might be able to find something. I've tried looking for a helpful tutorial for you with a few quick searches but didn't find anything that seemed appropriate, maybe you'll have better luck.

There's also a few languages written to help people write these types of games quickly; I forget their names since it's been a while, but you might want to look into this too.

The whole area is in the A.I. domain of Natural Language Processing, so it depends a lot on how far you want to go as to the amount of work you need to put in. Don't go overboard! From memory, most old text parser games only had a very simple vocabulary, and sometimes only allowed sentences of up to one verb and one noun (i.e. "get apple", "eat apple", but not "get the red apple to the left of the kettle")

I would definitely use some sort of tokenised or symbolic system though, as that will make it easier to allow synonymns in your game, such as making "get","take","pick up" etc. have the same affect.

Hope that's of some help! I used to love those old adventure games...

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this