Mr_Threepwood
Daemon Poster
- Messages
- 961
Im making a game and part of it is a text interpreter that takes a written sentence and trys to interpret what you want the program to do.
Heres a summary of what I do.
The whole sentence gets passed to a class that takes out the trailing and leading spaces, then makes an arraylist of all of the words.
The arraylist of words gets sent to the room object, which then looks for recognizable words that are universal, and recognizable words that are specifically for that room. These words are then stored in a new arrayList;
The arraylist of recognizable words is then passed to a method in the room object which trys to figure out what you want the recognizable words to do.
To do the checks I have an array of local and universal words, this means that I need embedded loops since for each word in the arraylist I have to loop through to see if it matches a recognizable word.
Can anyone think of a more efficient way to do this?
Im figuring out quickly that text interpreters are VERY hard to make. I'm completely ignoring verbs so far and its still very hard.
Because what happens if someone types in something like
"look in exit room"
Does the program look, or exit? So I've got to make ways for it to set priority and ignore certain action words if others are in the array.
UGH.
Heres a summary of what I do.
The whole sentence gets passed to a class that takes out the trailing and leading spaces, then makes an arraylist of all of the words.
The arraylist of words gets sent to the room object, which then looks for recognizable words that are universal, and recognizable words that are specifically for that room. These words are then stored in a new arrayList;
The arraylist of recognizable words is then passed to a method in the room object which trys to figure out what you want the recognizable words to do.
To do the checks I have an array of local and universal words, this means that I need embedded loops since for each word in the arraylist I have to loop through to see if it matches a recognizable word.
Can anyone think of a more efficient way to do this?
Im figuring out quickly that text interpreters are VERY hard to make. I'm completely ignoring verbs so far and its still very hard.
Because what happens if someone types in something like
"look in exit room"
Does the program look, or exit? So I've got to make ways for it to set priority and ignore certain action words if others are in the array.
UGH.