How to implement predictive text?

m4u
19 Jun 2014, 14:58
Is it possible to implement this in Quest like en Frotz? When typing the first letters of a verb or noun the system fills the rest or show or if there is more than one word matching show the options.

Not sure if there is another post about this. I guess first we have to create a dictionary with all of the words of the game and then a function in the parser to do this.

jaynabonne
20 Jun 2014, 11:41
I have contemplated this myself. :)

It's not so much a parser issue as a user interface one. It has to happen right at input, before the player hits enter and sends it off to the parser. (The parser code remains unaffected as such.)

The current text input is just a standard HTML text input field. Depending on how you want to do it (from a visual point of view - extra text grayed or not?), that would need to be replaced or extended to handle, on a per-key basis, showing additional text in the input field and having it change depending on what comes before.

You are correct that you would need to know what words are relevant. You might need even more if you wish it to be truly smart - e.g. though "apple" is in the dictionary as a word, "appl(e)" as the first part of a command would be invalid whereas "x app(le)" would be ok. You also don't mention if you wish it to only show commands that are *currently* valid (e.g. "x apple" might not be allowed if the apple is not in the room). And there is also how the words are accepted. All details to work out.

It would be fun to try. Some challenges, but the hard part might be deciding exactly how it should behave!