Player recognition

Posted by Dace K on Fri 07 Jan 2005 10:48 PM — 5 posts, 24,727 views.

Canada #0
Hey. Been toying with the idea of making player recognition - in other words, players would not see each other's names in room descs unless they had met and interacted with that player before.

For example, if Bob had met Sally, or seen a photograph of her, he would see:
(rdesc) Sally is here.
(say) Sally says 'blah'.

If not, he would see:
(rdesc) A blonde caucasian woman is here.
(say) A blonde caucasian woman says 'blah'.

Only problem is, the only way I can think of to do this would be to add a name to the bottom of the player's pfile every time they meet someone, then run a massive ifcheck every time a player's name is called, to see if substitution comes in or not. This'd be rather long, messy, and take up quite a bit of memory and CPU time =P.

So.. anyone out there have any ideas about how else this could be done? =)
USA #1
It's not that bad to store a name per person the player knows. You can be much more clever however about how to store the data in memory.

You can use a (non-compact for simplicity) 'trie' for instance:
http://www.cs.mcgill.ca/~cs251/OldCourses/1997/topic7/
That site is good because it has pictures that help show you how these things work. Tries are very good at storing space, and also very, very fast - instead of having lookup time grow with number of names, lookup time is a direct linear function of the length of the word being looked up. Compact trees can save even more time.

Tries are a little complex though. If you want something more traditional, you can use a binary search tree, or a hash table. Of course, since you're in C I think, you'll have to implement these yourself unless you find an implementation somewhere. :)

Come to think of it, if you store the names as a trie, then you could even store a serialized form of the trie in the player file which would be quite compact indeed - definitely more so that storing an entry for every player.

FYI, if I were to do this, I'd use a trie and store it in the player file in a serialized form of the trie.
USA #2
Hmm i've been planning on doing this type of thing for my mud, hehe think i'll check out that link and watch how this topic goes :-p I'd love to be of help rather than a leach.. but storing of info isn't exactly my strong suit *looks at his 300,000 byte act_wiz.c*
USA #3
Well, one option is to look at a codebase that already has such a feature and see how it's done there (DoT just happens to have this btw)
USA #4
If you don't want to forse it to save all the names, give each player a 3-digit code, then set it to run a search. It will help minimize the space needed for the pfile.

When running the search, have it check the target player's code, and instead of going through all the code, run a search over just the first digit to help narrow the search, and maybe speeding it up slightly. Sectioning the pfile off with something similar to:

#Startdigit
1
123
124

ect.

Just an idea, hope it helps.