Ubot: Bots for all the ET Mods.


(Alan) #1

That isn’t yet an other mod with bots.
Ubot runs over the existing Mods and provides a Bot base for everyone.

A template library (which will be released soon) allows you to add your own AI, and gives you the opportunity to use bots on all the ET Mods.

It works on Windows and Linux but it isn’t finished, particularly the template lib.
Be patient, i will release that in some weeks.

Alan.
contact: header at tiscali dot fr


(Alan) #2

Ubot on etmain.


(Alan) #3

Ubot on tcetest


(Alan) #4

Ubot on etf


(Chruker) #5

How does it work? Does it need something compiled into the server code, or is it a modified client?


(Alan) #6

It works in the server side, and nothing is compiled into the game (qagame lib).
Ubot is named qagame.dll/.so, and the true game is renamed.
All the AI is on a third library, named bot.dll/.so

The bots can be added in etpro, etf, tcetest, …


(bani) #7

sounds like it’s a shim dll which runs between et.exe and qagame.dll, intercepts vm calls and makes its own vm calls as well.


(Alan) #8

Yes, it is.

Ubot sends some calls to the game (GAME_CLIENT_CONNECT, GAME_CLIENT_BEGIN, GAME_CLIENT_THINK, GAME_CLIENT_COMMAND, …), and also to the server (trap_BotAllocateClient, trap_SetUserinfo, trap_Printf, trap_SendConsoleCommand, …),
and intercepts some others (GAME_RUN_FRAME, trap_GetUsercmd, trap_SendServerCommand, …).

But that is not enough, i have some problems :

[ul]- the server wants to disconnect the bots after 4 mins because of “time out”.
I think i should modify something on the bot gEnt, but r.svFlags |= SVF_BOT doesn’t solve it.

  • in etf, the game thinks that the human who create the bots is a ‘ghost’ client and wants to kick him.[/ul]
    I don’t send the GAME_CLIENT_DISCONNECT or G_DROP_CLIENT signals to avoid that, but i am looking for a better solution.

(tjw) #9

If you set the server cvars:


g_inactivity 0
g_spectatorInactivity 0

does that still happen?


(Jaquboss) #10

It will be a lot of AI coding , for example True Combat is very diffirent game , there is no big motivation to make ETF bots since there are already one , and other mods mostly works like stock ET but with some changes that bots dont have to worry about…
For example bots will be happy under ETPro ( if ETPro anticheats things will allow it ) , but he will work limited under FalckonET ( he will not be able to handle TDM and diffirent gameplay) or other gametype changing mods…
Price of Peace is not released and it will have its own bot…
so Good Luck and i hope that you will allow AI customization…


(bani) #11

you have to generate usercmd_t every frame and populate serverTime/buttons/angles/forwardmove/etc or the engine/qagame will think the player is idle and kick them.

its also very likely etpro wont like these bots unless you disable anticheat.


(Alan) #12

Thanks for the encouragements.

tjw:
g_inactivity and g_spectatorInactivity are disabled. This “inactivity” timer is not handeled by qagame but by the server (et.exe) :frowning:
It is not a G_DROP_CLIENT (qagame) but a GAME_CLIENT_DISCONNECT (server). And the error msg is “<playername> ^7 timed out”.
Perhaps because he is waiting for a response from the client side of the bot player, which doesn’t exist.
Unfortunately, r.svFlags |= SVF_BOT seems to don’t be enough, i think the server still try to contact the bot client.

bani:
I send one GAME_CLIENT_THINK per GAME_RUN_FRAME for each bot. There is one trap_GetUsercmd for each GAME_CLIENT_THINK.
When qagame ask for my GetUsercmd (client 0) i copy the usercmd_t and that is what i put into the usercmd_t of the bots.
It is just to debug. I can easily control the bots with that.

I thinked i would have some problems with etpro, due to his anticheat code. But at this time i am not disturbed by that, neither by punkbuster. I hope that will continue. :notworthy:

Jaquboss:
I want Ubot be a base for some other Bots, it is why the AI is on an other DLL (bot.dll).
I am working on a template and i will give the sources of this “AI base”.


(bani) #13

actually it looks like if you’re going to try to simulate bots by making fake clients, you won’t be able to get around the engine inactivity timer. the engine wants real network packets from the clients.

you need to make your shim do most of what g_bot.c would do (in terms of allocating bots, making vm calls, and managing the bots) and then fake out qagame into thinking the bot clients are real clients.

remember to set ip “localhost” in the userinfo.


(Alan) #14

Yes i try to do that. That isn’t easy to sort out what is absolutely needed into this Quake3 & RTCW Bot code.

Most of the things that are handled are inherited from the Q3 bot system and i don’t want to be dependant of this mechanics.
Because the developer who want to build an original AI will do it his own way.
example of what i don’t want to use : i think that is not vital.

//g_bot.c
	// get the botinfo from bots.txt
	botinfo = G_GetBotInfoByName( "wolfbot" );
//bots.txt
{
name		WolfBot
model		wolfbot
aifile	bots/default_c.c
}
//===========================================================================
//
// Name:			default_c.c
// Programmer:		Ryan Feltrin (ryan@gmistudios.com)
// version:			1
// Tab Size:		4 (real tabs)
//===========================================================================

#include "botfiles/chars.h"

skill 1
{
	CHARACTERISTIC_NAME							"WolfBot"
	CHARACTERISTIC_GENDER						"male"
	CHARACTERISTIC_ATTACK_SKILL					0.15
	CHARACTERISTIC_WEAPONWEIGHTS				"bots/default_w.c"
	CHARACTERISTIC_AIM_SKILL					0.5
	CHARACTERISTIC_AIM_ACCURACY					0.5
	CHARACTERISTIC_VIEW_FACTOR					0.25
	CHARACTERISTIC_VIEW_MAXCHANGE				100
	CHARACTERISTIC_REACTIONTIME					0.6
	CHARACTERISTIC_FIRETHROTTLE					0.4

	CHARACTERISTIC_AIM_ACCURACY_ROCKETLAUNCHER	0.7
	CHARACTERISTIC_AIM_SKILL_ROCKETLAUNCHER		1.0
	CHARACTERISTIC_AIM_ACCURACY_SNIPERRIFLE		0.7
	CHARACTERISTIC_AIM_SKILL_SNIPERRIFLE		0.4
	CHARACTERISTIC_AIM_ACCURACY_FLAMETHROWER	0.2
	CHARACTERISTIC_AIM_ACCURACY_GRENADELAUNCHER	0.7
	CHARACTERISTIC_AIM_SKILL_GRENADELAUNCHER	0.7


Alll what i use in the Q3 BOTLIB at this time is trap_BotAllocateClient (0);

When the game creates his own bots he knows he must not ask the client for something. As the game thinks they are human players i have to stop all these calls.
I don’t send the trap_SendServerCommand and trap_GetTag that have bots clientNum (the clientNum -1 is a problem).
But something is missing because the server isn’t still pleased.

Perhaps something need to be done into the bot g_entity.
That is a problem because it is shared. If i put r.svFlags |= SVF_BOT the game could execute a part of bot code and crash.
example :

//g_active.c
void ClientThink_real( gentity_t *ent ) {
	int			msec, oldEventSequence, monsterslick = 0;
	pmove_t		pm;
	usercmd_t	*ucmd;
	gclient_t	*client = ent->client;
[...]
	// server cursor hints
	// TAT 1/10/2003 - bots don't need to check for cursor hints
	if ( !(ent->r.svFlags & SVF_BOT) && ent->lastHintCheckTime < level.time )
	{
		G_CheckForCursorHints(ent);

		ent->lastHintCheckTime = level.time + FRAMETIME;
	}

I wonder if i really can say to the game they are humans AND to the server they are bots.


(bani) #15

because you’re intercepting calls both ways, you can simply stomp r.svFlags before calling engine, and before calling qagame. both engine and qagame will see exactly what they expect :slight_smile:

the problem with engine dropping your bots is probably because qagame is fiddling with the clients, making them look like normal players. if you are getting “timed out” disconnects, it means the engine thinks that client is a regular player and is dropping them because it hasn’t received any network packets from them.

like i said, you need to make sure the userinfo for the client is set with an ip of localhost, or it definitely won’t work.


(Alan) #16

Yes, the server thinks the bot has a client side.
After 4 minutes :

^3Ubot-0.4: vmMain (GAME_CLIENT_DISCONNECT, BOT=1)
ubotname^7 timed out
^3Ubot-0.4: vmMain (GAME_CLIENT_DISCONNECT, BOT=2)
ubotname^7 timed out
^3Ubot-0.4: vmMain (GAME_CLIENT_DISCONNECT, BOT=3)
ubotname^7 timed out
^3Ubot-0.4: vmMain (GAME_CLIENT_DISCONNECT, BOT=4)
ubotname^7 timed out
[...]

And if i play with a lot of bots :

WARNING: msg overflowed for ubotname
^3Ubot-0.4: vmMain (GAME_CLIENT_DISCONNECT, BOT=1)
ubotname^7 Msg overflowed
WARNING: msg overflowed for ubotname
^3Ubot-0.4: vmMain (GAME_CLIENT_DISCONNECT, BOT=2)
ubotname^7 Msg overflowed
WARNING: msg overflowed for ubotname
^3Ubot-0.4: vmMain (GAME_CLIENT_DISCONNECT, BOT=3)
ubotname^7 Msg overflowed
[...]

And i sometimes have a “pending server commands” overflow.

To solve that, i have checked if ent->r.svFlags isn’t crushed. That is all right (=SVF_BOT).
The userinfo ip value is localhost :

// bot.c
// AddBot ( )
[...]
ubotuserinfo = "\\cg_etVersion\\Enemy Territory, ET 2.56\\cg_uinfo\\13 0 30\\g_password\
one\\cl_guid\\2CF49DB75739144100DC3B8D6E0BC160\\cl_punkbuster\\1
\\cl_anonymous\\0\\snaps\\20\\rate\\25000\
ame\\ubotname\\cl_wwwDownload\\1\\ip\\localhost\0";

	trap_SetUserinfo( clientNum, ubotuserinfo );
[...]

I am looking for a solution to say to the server “this player hasn’t a client side”.


(bani) #17

your bots need to read snapshots and servercommands, so that their message queues don’t overflow (“Msg overflowed”).
you dont necessarily have to do anything with the snapshots and commands, but you do need to make sure you dont get overflows.

look at CG_ReadNextSnapshot() and CG_ExecuteNewServerCommands()

this is also why your clients never transition to CS_CONNECTED. they need to read snapshots in order to do so.


(Alan) #18

Here is an example of server command overflow :

===== pending server commands =====
cmd     1: cs 690 "n\ubotname	\3\skill\\c\0\r\0\m\0000000\s\0000000\dn\\dr\0\w\3\lw\3\sw\0\mu\0"

cmd     2: sc0 0 0 2 0 0 0 0 0 0 -1 1 0 0 0 0 0 -1
cmd     3: portalcampos -1 2877 1573 -419 -359 137 0 -1
cmd     4: aftc -1
cmd     5: cs 690 "n\ubotname	\1\skill\\c\0\r\0\m\0000000\s\0000000\dn\\dr\0\w\3\lw\3\sw\2\mu\0"
[...]
cmd   216: entnfo 16 0 0 28 56 36 9 0 26 57 -53 8 1 29 58 -125 7 1 29 58 -35 6 0 28 57 36 5 1 29 56 -110 4 1 28 57 -75 3 1 29 57 -125 2 0 28 57 36 1 1 28 56 54 0 9 10 5 301 5 299 5 290 3 288 3 237
cmd   217: tinfo 10 0 3613 7262 -1 0 1 3667 7366 8^7 Server command overflow

(bani) #19

this means the server engine still doesn’t think your clients are really bots.

make sure client->gentity and client->gentity->r.svFlags & SVF_BOT


(Fusen) #20

yeah I agree, nice work btw alan