Tuesday, June 18, 2013

Dev Log: Horror Game Part 10

I figured out some interesting things this weekend, mostly about how to make a text parser. I discovered I already knew how to make a text parser, but tutorials I found online were misleading. Combining a little of what they said with a much more basic and flexible way to read text, I got it so it takes the full command when the player hits enter. Text parsers online wanted to do it on a character basis, which is kind of overkill.

After that, I divide the text into words, putting each into an array slot (or vector slot, as the case may be). Currently the parser can take an infinite number of words, which may be necessary for the chat portion. Basically if the player is talking to the game ("Open door") I imagine at most four words ("Tie rope to tree"), but if the player is chatting with (what will be) a chat command, they should be able to type as much as they want (I suppose within reason).

But anyway, now that I've got the text split into words, my next step (in the text parsing area, that is) will be to create a dictionary. I expect that the average player will use the sentence structure verb-subject, or at most verb-subject-preposition-direct object, so hopefully I'll just have to identify the position of the word to note its type. That may be the best way to do it, but I suppose that might not even be necessary, on thinking about it. We'll see.

Of course, such a thing as a text parser requires testing by nature, especially testing by a player who's imaginative. That way I can create a dictionary of things that a player can do, useless and useful. Start useful, of course; turn useless only when I run out of ideas.

But combining a dictionary to what's actually in the world will be the tricky bit. My first thought is to have a series of booleans that determine what objects are in the room, and therefore what the player can effect, but I don't like that very much. I'm positive there's a better way to do it.

I'm thinking if I visualized the world as a map in the way I drew the school earlier, and programmed the dictionary to interact with those objects accordingly, things may work out well. I'm used to thinking in abstractions like booleans, but I think visualizing the world more concretely will be a better way to do it.

So I'll switch gears out of the text parser for a little bit, but keep it in the back of my mind while I work on making room objects and such.

No comments:

Post a Comment