Skip to main content
gamedev.net
🔒 Locked

AutoComplete

Started by _John_Galt_ 3 replies 1k views
Original Post
_John_Galt_
_John_Galt_
Could anyone give some suggestions to design the kind of Auto Complete system that is employed in linux and most drop down consoles in games like Quake3 Someone Please
Neex
Neex
I don't know how anyone else does it, but I think using the trie data structure would make this a lot easier.

When the user presses tab, go through a trie (of all known strings) for the current input, and if there is only one leaf in the subtree, that's your string.
Mercury
Mercury
Look into strncmp, it'll compare a string up to a point, letting you do autocompletely pretty easily. I remember reading this from one of the Quake's sources.
ToohrVyk
ToohrVyk
Neex is right, a trie is the best thing to use here. What you do is distinguish :

- nodes with one child (simple)
- nodes with more than one child (branches)
- nodes without children (leaves)

Pressing tab on a simple node moves to the next branch, by completing the word.

Pressing tab on a branch adds a message "complete, but not unique".

Pressing tab on a leaf does nothing.

Pressing tab outside of the trie adds a message "no matching command".
_John_Galt_
_John_Galt_
I had thought of TRIES ,, but i did not know thats what they are called ..;) Anyways thanks a lot to all of u!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.