View Single Post
agrif
Junior Member
Join Date: Jan 2010
Old 01-22-2010 , 16:39   Re: Automatic Bot Names
Reply With Quote #15

Quote:
Originally Posted by shustas View Post
Giving names random from file takes into account what names already taken...?
Basically, yes. If you don't want the technical answer, then you can skip the rest of this post!

Technically, no, but for all but the pathological cases the effect is the same. I didn't want to have to check a string against all the players in the server every time a bot was added.

Instead, every time the name list is loaded (on map change, or manually) it shuffles the list, then uses the names in order from the shuffled list. This gives an effectively random name distribution without repeats.

The only problem is with weird cases. Say you have 32 names. You add one bot, then proceed to add then remove 31 bots. The next bot will have the same name as the first (with a number), because now it made it back to the front of the list.

This really shouldn't happen normally, and if you have more names, it's even less likely. If this ever becomes a problem, I'll happily change it but for now it was easier to do and very nearly equivalent.

Of course, if you turn off the random names, the list is never shuffled and names are read in order.
agrif is offline