[3.1+] NullBot: an adaptive skirmish AI

Did you create a mod, map, music, or a tool? Present them here and earn feedback!
Note: addon requests do not belong here.
Note, everything uploaded to this forum, MUST have a license!
Post Reply
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: NullBot: yet another AI for v3.1+

Post by NoQ »

effigy wrote:IIRC the DyDo Ai had personalities that were chosen by random. Maybe you could look at it for ideas?
Iluvalar wrote:the stock AI do in 2.3.9.
True, and same applies to Nexus and Semperfi AI in 3.1+.

But i am still looking for an elegant way to keep both specific AIs and random AI without extra duplicating the code ... at least on my machine (: I think i'll work on it now, cause i'm getting satisfied with the base already.
User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: NullBot: yet another AI for v3.1+

Post by Shadow Wolf TJC »

NoQ wrote:P.S. I wish i could do a random AI that picks one of the personalities randomly, but i didn't find any elegant way to do it yet.
You may have to create a new AI that contains code from all your other AIs in order to get the job done. :|
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100
User avatar
vexed
Inactive
Inactive
Posts: 2538
Joined: 27 Jul 2010, 02:07

Re: NullBot: yet another AI for v3.1+

Post by vexed »

NoQ wrote:
effigy wrote:IIRC the DyDo Ai had personalities that were chosen by random. Maybe you could look at it for ideas?
Iluvalar wrote:the stock AI do in 2.3.9.
True, and same applies to Nexus and Semperfi AI in 3.1+.

But i am still looking for an elegant way to keep both specific AIs and random AI without extra duplicating the code ... at least on my machine (: I think i'll work on it now, cause i'm getting satisfied with the base already.
This might work out for you, then do different behavior based on a switch ?

Code: Select all

//-- \subsection{include(file)}
//-- Includes another source code file at this point. This is experimental, and breaks the
//-- lint tool, so use with care.
static QScriptValue js_include(QScriptContext *context, QScriptEngine *engine)
/facepalm ...Grinch stole Warzone🙈🙉🙊 contra principia negantem non est disputandum
Super busy, don't expect a timely reply back.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: NullBot: yet another AI for v3.1+

Post by aubergine »

A lot of the code will be the same between AIs, from my understanding what will differ is:

* base build order
* research paths
* droid components
* attack targets

There's probably a few other bits that I've not thought of.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: NullBot: yet another AI for v3.1+

Post by NoQ »

Well, i didn't really look for any way to do that, but for a way that doesn't make me change two or more files every time i make changes to some personalities.
vexed wrote:

Code: Select all

//-- \subsection{include(file)}
//-- Includes another source code file at this point. This is experimental, and breaks the
//-- lint tool, so use with care.
static QScriptValue js_include(QScriptContext *context, QScriptEngine *engine)
Unfortunately, this function is nothing like #include in C or include in PHP. It can't be called in global scape, but only inside other functions, so it's not very useful to include my personality definitions that are mostly a bunch of global constants.
aubergine wrote:A lot of the code will be the same between AIs, from my understanding what will differ is:

* base build order
* research paths
* droid components
* attack targets

There's probably a few other bits that I've not thought of.
In fact, attack targets are the same. They are just things to destroy to make the enemy officially dead, in a particular order.

Anyway, here is some code, but it's pretty ugly, and it takes a lot of work to add more personalities. As you couldn't have noticed yet, every .js file is made of three parts: head that is equal for all personalities, tail that is equal for all personalities, and personality-specific code in between. In fact, i merge them with "cat" command before packing the mod. Now i can just place several personality code blocks in between and it will make the AI randomly choose one of them. But the list of all possible personalities ever existed needs to be known in advance, and it's duplicated in many places; see the beginning of the tail for all the ugliness. I'm still looking for an elegant way of getting rid of it.

Fortunately, due to #3147, we won't have too many new personalities in the nearest future. Unfortunately, we already have too many.

v0.15:

Changes:
  • Random AI available, that picks randomly one of the personalities. Currently, it doesn't pick hover or generic personalities, cause they're too weak in normal games. It is packed into a separate mod, though it's ok to load two mods simultaneously (but you won't be able to use Semperfi AI in that case due to lack of widget space);
  • No longer accidentally flashlight for tanks (usually too weak compared to TAG or plasmite, bad idea to switch)
  • Delay other work when need to build anti-air defenses;
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: NullBot: yet another AI for v3.1+

Post by aubergine »

on v0.14 nullbot doesn't seem to create laser satellite or research auto repair...

will test v0.15 later today
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: NullBot: yet another AI for v3.1+

Post by NoQ »

Yeah ... doesn't research autorepair, i know (or at least not until the whole research path is finished). Not the most useful tech around, especially when units are in constant motion ... Will think about it (:

But if it doesn't build satellite uplink or laser satellite command post, it's a bug. keepBuildingThings() function is responsible for that. Will have a look (: Upd: Laser satellite seems to work, tried with using "give all" cheat on AIs. The only issue is that it is sometimes used for shooting lonely oil derricks; need to fix that.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: NullBot: yet another AI for v3.1+

Post by aubergine »

I played a game last night that lasted about 2 hours (from wz perspective, i was on max speed setting) and no lassat built.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: NullBot: yet another AI for v3.1+

Post by aubergine »

In the eventStartLevel() would it be worth using slightly more random numbers for the setTimer() calls to reduce the chances of multiple timers being triggered at the same time? On a 4 player map with 3 nullbots, the game will start to stutter after an hour or so due to lots of enumeration churning at the same time.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: NullBot: yet another AI for v3.1+

Post by Per »

NoQ wrote:Unfortunately, this function is nothing like #include in C or include in PHP. It can't be called in global scape, but only inside other functions
Oh? It was supposed to work from global, just like #include in C. Now, I haven't tested it in a while, but I remember having tested that working when I first made it.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: NullBot: yet another AI for v3.1+

Post by NoQ »

Oh? I checked it once some day and it didn't work. But now i just tried it and it worked :D :D :D :oops:
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: NullBot: yet another AI for v3.1+

Post by NoQ »

v0.16.

Changes:
  • Now using include(). No more code duplication in the final package (:
It doesn't yet solve the ugliness at the beginning of tail.inc.js ... could use some ideas :? :oops: probably gonna use something like eval() :hmm:
User avatar
effigy
Regular
Regular
Posts: 1217
Joined: 22 Jan 2010, 03:21
Contact:

Re: NullBot: yet another AI for v3.1+

Post by effigy »

Lots of nice sounding updates to this bot since I last played it (0.3).

I was having a thought (and maybe I missed it having just read the whole thread) does NullBot recycle obsolete units? Could he? :)
This is why some features aren't implemented: http://forums.wz2100.net/viewtopic.php?f=30&t=7490&view=unread#p87241
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: NullBot: yet another AI for v3.1+

Post by NoQ »

v0.17

Changes:
  • Now aims laser satellite at the biggest enemy unit/building cluster (clusterisation procedure used again!);
  • Added the missing laser satellite tech to the research path some :oops: personalities;
  • Increase group sizes;
  • Get rid of some ugly code at the beginning of the tail.inc.php (well, it's still ugly, but ... shorter :roll: )
effigy wrote:I was having a thought (and maybe I missed it having just read the whole thread) does NullBot recycle obsolete units? Could he? :)
That's one single nice idea, but i have no idea when or why exactly should the AI recycle units. In fact, i don't even know when i should do it as a human (: I mean, just too uncertain (:
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: NullBot: yet another AI for v3.1+

Post by aubergine »

Per wrote:
NoQ wrote:Unfortunately, this function is nothing like #include in C or include in PHP. It can't be called in global scape, but only inside other functions
Oh? It was supposed to work from global, just like #include in C. Now, I haven't tested it in a while, but I remember having tested that working when I first made it.
It works from global for me - it's how I include my util.js and vault.js. Never had a problem with it. I wasn't aware that it could be wrapped in if..then statements, might have to give that a try as that opens up some interesting possibilities.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Post Reply