[SOLVED] Verb-Noun Parser
Posted: Mon Jul 30, 2012 8:41 pm
I want to make a verb-noun parser for my visual novel game engine. A verb-noun parser is used to recognize input made as strings by the player. For example you could type in "open door", then the computer will use the verb-noun parser to recognize the word open as a verb, you are telling the computer that you want to open something but what? then it looks for a noun to attach this verb to, door is a noun, it is an object, then using the computers programmed logic it will link the two, open + door, it then recognizes this as a valid action and performs the task.
I know how this works in my mind but I have no idea how to code this from scratch in Lua, I have a hint that it involves something to do with converting variables into strings and vice versa, could be wrong though.
Any ideas for an algorithm or some sample code that could help me flesh this out? How would you even input text in Love during gameplay? Is it possible to have a sort of built in console or something just for this. Hope it wont get too complicated to do, I'm thinking of keeping it very simple, like you can only use commands with one verb and one noun,
Verbs would be:
Use
Open
Examine (Look)
Search
Move + Front, Back, Left, Right, (noun)
Take
Drop
Talk
Ask
Nouns would be general items and stuff like keys, doors, chairs, stairs, walls e,t,c ( the list is almost endless ) but will be in the following categories:
Pick-up ( stuff you can take and carry in your inventory like keys and small items )
Portals ( like doors and stairs, you interact with them to go somewhere )
Action ( these cant be picked up, nor do they take you somewhere but perform actions like sitting on a chair or interacting with someone )
Idle ( these don't do anything and are there in rare cases as obstacles such as walls and barriers )
Then I'm thinking we make a table for e.g pickups with
and add all the pick ups in that as variables then somehow we program a function to compare e.g key.pickup with e.g door.portal or something if we
need the key to open the door...
Hope this is all do-able, it doesn't have to be easy just possible.
I just really miss those old school adventure type games for their verb-noun parser, some retro VN's use the same mechanic in their game-play...
I know how this works in my mind but I have no idea how to code this from scratch in Lua, I have a hint that it involves something to do with converting variables into strings and vice versa, could be wrong though.
Any ideas for an algorithm or some sample code that could help me flesh this out? How would you even input text in Love during gameplay? Is it possible to have a sort of built in console or something just for this. Hope it wont get too complicated to do, I'm thinking of keeping it very simple, like you can only use commands with one verb and one noun,
Verbs would be:
Use
Open
Examine (Look)
Search
Move + Front, Back, Left, Right, (noun)
Take
Drop
Talk
Ask
Nouns would be general items and stuff like keys, doors, chairs, stairs, walls e,t,c ( the list is almost endless ) but will be in the following categories:
Pick-up ( stuff you can take and carry in your inventory like keys and small items )
Portals ( like doors and stairs, you interact with them to go somewhere )
Action ( these cant be picked up, nor do they take you somewhere but perform actions like sitting on a chair or interacting with someone )
Idle ( these don't do anything and are there in rare cases as obstacles such as walls and barriers )
Then I'm thinking we make a table for e.g pickups with
Code: Select all
pickup = {}
need the key to open the door...
Hope this is all do-able, it doesn't have to be easy just possible.
I just really miss those old school adventure type games for their verb-noun parser, some retro VN's use the same mechanic in their game-play...