Re: names and searching.

From: Sean Butler (sbutler@DEVEAST.COM)
Date: 11/08/97

>Thus if a human saw another human character it would search through this
>list to see if he has been introduced if he has then show name if not
>show "human".
First of all you shouldn't use names, you should instead use the
character's ID number.  Names would definitely add an order of
magnitude to the search time.  Use the ID number of each character
and place it in an ordered list.  (This also takes up less memory
than strings)

>My question is will this lag the mud having to continually run through a
>for loop of up to say 200 names?
No probably not if you used the ID numbers and did a binary search
for each person the player saw. Let's see, log(200) = 8 iterations.
A simple binary search is of order O(log(n)).  It's hard to get more
efficient than that.

>a group of 5 humans walks in on a room of say 10 humans, would cause this
>loop to go of a very large number of times as each indervidual would have
>to check if he was introduced to each of the 10 people in the room.
>Can c do these loops fast and easily? or will this lag the game?
Actually yes, C can do these loops quickly, especially if you use the
gnu C compiler.  For searching loops like that you can probably get
something very close to assembly efficiency.


--Sean Butler

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/08/00 PST