Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Super Bots

#1
Hello,
I've been thinking about creating some kind of OP bots 4 fun and training. They should be as good as possible, allowed to cheat, e.g. have complete game information, 100% hitscan shoot accuracy etc.
So far I've managed to give them an almost 100% accuracy with this:

Code:
index 21506d075..dec170d9c 100644
--- a/qcsrc/server/bot/default/aim.qc
+++ b/qcsrc/server/bot/default/aim.qc
@@ -203,6 +203,21 @@ void bot_aimdir(entity this, vector v, float maxfiredeviation)
       if (this.bot_prevaimtime == time)
               return;

+this.v_angle = vectoangles(normalize(v));
+
+this.v_angle.x *= -1;
+
+makevectors(this.v_angle);
+shotorg = this.origin + this.view_ofs;
+shotdir = v_forward;
+
+this.bot_firetimer = time + 0.001;
+
+int aaa = 0;
+
+if (!aaa)
+  return;
+
       // invalid aim dir (can happen when bot overlaps target)
       if(!v) return;

@@ -432,3 +447,4 @@ bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeed
       this.dphitcontentsmask = hf;
       return true;
}

Try it out! (Put the changes above into said file and recompile.)

Bots still sometimes miss hitscans for some reason -- if you know why, please let me know.

Let's discuss and please suggest me ideas or code snippets about further bot improvements.
Reply

#2
Hmm one great addition of the bots would be the ability for them to randomly roam around even without waypoints.
There's an unfinished feature which lets bots do that and create waypoints as they go. But this process still needs some optimization as it's creating way too much waypoints without deleting them, iirc.
Reply

#3
(07-26-2020, 04:10 AM)drummyfish Wrote:
Code:
index 21506d075..dec170d9c 100644
--- a/qcsrc/server/bot/default/aim.qc
+++ b/qcsrc/server/bot/default/aim.qc
@@ -203,6 +203,21 @@ void bot_aimdir(entity this, vector v, float maxfiredeviation)
       if (this.bot_prevaimtime == time)
               return;

+this.v_angle = vectoangles(normalize(v));
+
+this.v_angle.x *= -1;
+
+makevectors(this.v_angle);
+shotorg = this.origin + this.view_ofs;
+shotdir = v_forward;
+
+this.bot_firetimer = time + 0.001;
+
+int aaa = 0;
+
+if (!aaa)
+  return;
+
       // invalid aim dir (can happen when bot overlaps target)
       if(!v) return;

@@ -432,3 +447,4 @@ bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeed
       this.dphitcontentsmask = hf;
       return true;
}

If you don't mind, could you rewrite the code? Someone is trying to test, but maybe it doesn't work, and if you put things copied from the written history of git, it could be a mess for which I tried to know what the code is doing. Like +, @@ things...
Please rewrite it but without having these things, put the entire code, if you take it from a file, say the name of the file and from which lines they come.
Believing is power
Reply

#4
Bots often miss the very first shot because they start to fire when they aren't aiming at the enemy yet. I fixed this misbehaviour in 
https://gitlab.com/xonotic/xonotic-data....c40c677dd2
but I had to revert it in
https://gitlab.com/xonotic/xonotic-data....3e171d0d76
because it caused other issues, see commit description.
Reply

#5
OK, now I've made them ridiculously good, even though could still be better. It depends on the mode, but sometimes I can barely frag them:

https://streamable.com/bolarb

Code:
diff --git a/qcsrc/server/bot/default/aim.qc b/qcsrc/server/bot/default/aim.qc
index 21506d075..204cedf52 100644
--- a/qcsrc/server/bot/default/aim.qc
+++ b/qcsrc/server/bot/default/aim.qc
@@ -168,6 +168,9 @@ void bot_lagfunc(entity this, float t, float f1, float f2, entity e1, vector v1,
this.bot_canfire = (random() < 0.95);
else
this.bot_canfire = 1;
+
+this.bot_canfire = 1;
+
}

// this function should be called after bot_aim so the aim is reset the next frame
@@ -203,6 +206,21 @@ void bot_aimdir(entity this, vector v, float maxfiredeviation)
if (this.bot_prevaimtime == time)
return;

+this.v_angle = vectoangles(normalize(v));
+
+this.v_angle.x *= -1;
+
+makevectors(this.v_angle);
+shotorg = this.origin + this.view_ofs;
+shotdir = v_forward;
+
+this.bot_firetimer = time + 0.001;
+
+int aaa = 1;
+
+if (aaa)
+  return;
+
// invalid aim dir (can happen when bot overlaps target)
if(!v) return;

@@ -432,3 +450,4 @@ bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeed
this.dphitcontentsmask = hf;
return true;
}
+
diff --git a/qcsrc/server/bot/default/bot.qc b/qcsrc/server/bot/default/bot.qc
index 7b30b62df..c5b5015f0 100644
--- a/qcsrc/server/bot/default/bot.qc
+++ b/qcsrc/server/bot/default/bot.qc
@@ -76,6 +76,8 @@ void bot_think(entity this)

this.bot_nextthink = max(time, this.bot_nextthink) + max(0.01, autocvar_bot_ai_thinkinterval * (0.5 ** this.bot_aiskill) * min(14 / (skill + 14), 1));

+this.bot_nextthink = max(time, this.bot_nextthink) + 0.005;
+
if (!IS_PLAYER(this) || (autocvar_g_campaign && !campaign_bots_may_start))
{
CS(this).movement = '0 0 0';
@@ -102,6 +104,8 @@ void bot_think(entity this)
// skill 10 = ping 0.2 (adrenaline)
// skill 0 = ping 0.7 (slightly drunk)

+CS(this).ping = 0;
+
// clear buttons
PHYS_INPUT_BUTTON_ATCK(this) = false;
// keep jump button pressed for a short while, useful with ramp jumps
@@ -268,6 +272,19 @@ void bot_setnameandstuff(entity this)
READSKILL(bot_thinkskill, 1, 0.5); // think skill
READSKILL(bot_aiskill, 2, 0); // "ai" skill

+this.havocbot_keyboardskill = 10;
+this.bot_moveskill = 10;
+this.bot_dodgeskill = 10;
+this.bot_pingskill = 10;
+this.bot_weaponskill = 10;
+this.bot_aggresskill = 10;
+this.bot_rangepreference = 10;
+this.bot_aimskill = 10;
+this.bot_offsetskill = 10;
+this.bot_mouseskill = 10;
+this.bot_thinkskill = 10;
+this.bot_aiskill = 10;
+
if (file >= 0 && argv(prio) != "")
LOG_INFOF("^1Warning^7: too many parameters for bot %s, please check format of %s", bot_name, autocvar_bot_config_file);

@@ -325,6 +342,10 @@ void bot_custom_weapon_priority_setup()
)
return;

+autocvar_bot_ai_custom_weapon_priority_far = "vortex devastator machinegun blaster hagar mortar";
+autocvar_bot_ai_custom_weapon_priority_mid = "devastator mortar vortex hagar electro machinegun crylink blaster";
+autocvar_bot_ai_custom_weapon_priority_close = "shotgun hagar mortar vortex crylink electro blaster";
+
if (bot_priority_distances_prev != autocvar_bot_ai_custom_weapon_priority_distances)
{
strcpy(bot_priority_distances_prev, autocvar_bot_ai_custom_weapon_priority_distances);
diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc
index 6515cc44e..061e9b194 100644
--- a/qcsrc/server/bot/default/havocbot/havocbot.qc
+++ b/qcsrc/server/bot/default/havocbot/havocbot.qc
@@ -1272,7 +1272,7 @@ entity havocbot_gettarget(entity this, bool secondary)
IL_EACH(g_bot_targets, boolean((secondary) ? it.classname == "misc_breakablemodel" : it.classname != "misc_breakablemodel"),
{
vector v = CENTER_OR_VIEWOFS(it);
- if(vdist(v - eye, <, autocvar_bot_ai_enemydetectionradius))
+// if(vdist(v - eye, <, autocvar_bot_ai_enemydetectionradius))
if(!best || vlen2(CENTER_OR_VIEWOFS(best) - eye) > vlen2(v - eye))
if(bot_shouldattack(this, it))
{
@@ -1320,7 +1320,11 @@ void havocbot_chooseenemy(entity this)
}
if (time < this.havocbot_chooseenemy_finished)
return;
+
this.havocbot_chooseenemy_finished = time + autocvar_bot_ai_enemydetectioninterval;
+
+this.havocbot_chooseenemy_finished = time + 0.1;
+
vector eye = this.origin + this.view_ofs;
entity best = NULL;
float bestrating = autocvar_bot_ai_enemydetectionradius ** 2;
@@ -1354,6 +1358,8 @@ LABEL(scan_targets)

vector v = (it.absmin + it.absmax) * 0.5;
float rating = vlen2(v - eye);
+rating = 0;
+
if (rating < bestrating && bot_shouldattack(this, it))
{
traceline(eye, v, true, this);
@@ -1370,6 +1376,7 @@ LABEL(scan_targets)
scan_secondary_targets = true;
// restart the loop
bestrating = autocvar_bot_ai_enemydetectionradius ** 2;
+
goto scan_targets;
}

@@ -1459,6 +1466,8 @@ void havocbot_chooseweapon(entity this, .entity weaponentity)
// Ideally this 4 should be calculated as longest_weapon_refire / bot_ai_weapon_combo_threshold
combo_time = time + ct + (ct * ((-0.3*(skill+this.bot_weaponskill))+3));

+combo_time = time + ct;
+
combo = false;

if(autocvar_bot_ai_weapon_combo)


(07-27-2020, 09:39 AM)LegendGuard Wrote: If you don't mind, could you rewrite the code?

This is output of diff, it just shows what changes I've made and allows you to automatically apply the changes with patch.
Reply

#6
as in UT, bots must be too cunning, be able to dodge and use other weapons. Sorry, I can't help you
exec XonoticMod.cfg - my  Cool  mod;
MyStats:
[Image: 151702]
Reply

#7
That's why I'm trying to give them superhuman aim and reactions, to compensate for their dumb brains.
Reply

#8
Your latest patch is broken, indentation is missing.
Reply

#9
Works on my machine even without indentation.
Reply

#10
Guys I know I'm not the best at duels, but I literally can't beat him in a duel.
https://streamable.com/ihlbsl
I dare you to beat this bot in a duel.
Reply

#11
Have you tried absolutely all weapons? If not --- g_new_toys 1; g_overkill_weapons 1; g_weaponarena all; try it
exec XonoticMod.cfg - my  Cool  mod;
MyStats:
[Image: 151702]
Reply

#12
For easier testing here are the complete files, just unzip them and replace (in xonotic source tree):

xonotic/data/xonotic-data.pk3dir/qcsrc/server/bot/default/aim.qc
xonotic/data/xonotic-data.pk3dir/qcsrc/server/bot/default/bot.qc
xonotic/data/xonotic-data.pk3dir/qcsrc/server/bot/havocbot/havocbot.qc

And recompile xonotic. Then simply play singleplayer vs bot (set to godlike just to be sure).


Attached Files
.zip   files.zip (Size: 23.83 KB / Downloads: 2)
Reply

#13
(08-03-2020, 07:48 AM)drummyfish Wrote: And recompile xonotic. Then simply play singleplayer vs bot (set to godlike just to be sure)
how to recompile?
exec XonoticMod.cfg - my  Cool  mod;
MyStats:
[Image: 151702]
Reply

#14
(08-03-2020, 11:19 AM)Kotangens Wrote:
(08-03-2020, 07:48 AM)drummyfish Wrote: And recompile xonotic. Then simply play singleplayer vs bot (set to godlike just to be sure)
how to recompile?

If you don't know something like programming, you'll have to study how computer works, C programming, how compiler does, ...

To compile:
https://gitlab.com/xonotic/xonotic/-/wik...-compiling
If you can't help someone, don't need to say you can't, just don't say anything and that's it. Everybody does. There is no need to overstrain if someone asks for help of what you don't know. The community recommends you use IRC chat or Discord if you have little questions like that, they can help you. Smile Here the chat:

IRC Quakenet channel: #xonotic
(you can go in IRC Webchat too: https://www.xonotic.org/chat, I recommend you a IRC client called Hexchat to connect to this if you like IRC)
Discord: https://discordapp.com/invite/0uxcsw1XMkaOB936 (most recommended)
Believing is power
Reply

#15
Quote:To compile:

https://gitlab.com/xonotic/xonotic/-/wik...-compiling

Thank you, but I'm on vacation.
exec XonoticMod.cfg - my  Cool  mod;
MyStats:
[Image: 151702]
Reply

#16
I've duelled the bot literally 130 times so far and no win lol, I'm fkn frustrated. I came pretty close at some 12:12 but then he got the vort and that's game over. I'm not gonna play online till I beat this bot.

Could anyone perhaps put these on a server so that others can try? The setup should be this: 10 minute dm vs 1 bot, infinite frag limit, g_powerups 0 (no strength) = like duel, finalrage (no electro, no space, ...).
Reply

#17
I DID IT, after three days I've beaten the bot 15:13! The strat was mainly don't give him the vort. Here is a very emotional recording of the match:
https://peertube.mastodon.host/videos/wa...ace96fc59a
Reply



Possibly Related Threads...
Thread Author Replies Views Last Post
  Playing offline against bots with proper duel settings? Cynical 5 1,077 06-24-2019, 04:47 PM
Last Post: Aguaumreal

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-