Bots-United / jk_botti

Bot (Computer AI) for Half-Life 1 Deathmatch
http://forums.bots-united.com/forumdisplay.php?f=83
Other
43 stars 19 forks source link

Bot names random collision 🤔 #5

Open artkirienko opened 4 years ago

artkirienko commented 4 years ago

Hi @jkivilin @Bots-United! Thanks for your great work! 🎉

I have a HLDS HLDM server set up for 8 bots. Sometimes two bots get the same random name.

Example

example

There are plenty of names

$ cat jk_botti_names.txt | wc -l
32

How I suppose it should work

I guess you just call something like BOT_NAMES.random() on every bot creation event, where BOT_NAMES represent all the bot names from jk_botti_names.txt as an array. If it's true, you could fix it by adding some singleton state, like BOT_NAMES_CURRENTLY_IN_USE, so you could pick a random name from (BOT_NAMES - BOT_NAMES_CURRENTLY_IN_USE).random().

Also, you need to take into account the size of jk_botti_names.txt and the number of bots requested: jk_botti_names.txt could have 2 names only, and the config could request 8 bots to be created when bot names should collide instead of creating just 2 bots.

These are my thoughts and ideas on this problem, I didn't read the source code.

Versions and configs

jk_botti version 1.43

Available as a Docker Image here: https://github.com/artkirienko/hlds-docker-dproto

artkirienko commented 4 years ago

https://github.com/Bots-United/jk_botti/blob/master/bot.cpp#L326

🤔 💭 Uniqueness check is implemented already. There is a bug there probably.

josemam commented 4 years ago

I never found out this until actually testing for #6, so this is certainly caused by #6. In particular, this is probably common among HPB-bot-based bots, and fixing #6 should fix this as well.