Page 6 of 57

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

Posted: 12 Feb 2012, 21:22
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.

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

Posted: 13 Feb 2012, 02:33
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. :|

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

Posted: 13 Feb 2012, 02:47
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)

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

Posted: 13 Feb 2012, 03:39
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.

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

Posted: 13 Feb 2012, 11:02
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;

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

Posted: 13 Feb 2012, 11:21
by aubergine
on v0.14 nullbot doesn't seem to create laser satellite or research auto repair...

will test v0.15 later today

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

Posted: 13 Feb 2012, 11:48
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.

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

Posted: 13 Feb 2012, 13:10
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.

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

Posted: 13 Feb 2012, 13:15
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.

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

Posted: 13 Feb 2012, 13:41
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.

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

Posted: 13 Feb 2012, 13:56
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:

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

Posted: 13 Feb 2012, 14:37
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:

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

Posted: 13 Feb 2012, 15:40
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? :)

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

Posted: 13 Feb 2012, 16:25
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 (:

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

Posted: 13 Feb 2012, 16:27
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.