[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!
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: NullBot: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by NoQ »

Emm, no, the problem is not in your code.
Ok, don't have time now, will try to fix later.
User avatar
aubergine
Professional
Professional
Posts: 3462
Joined: 10 Oct 2010, 00:58

Re: NullBot: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by aubergine »

ah, nice. you might want to update slightly so it's reading:

global.scavengerPlayer=(scavengers) ? Math.max(7,maxPlayers) : -1;

What other stuff did you need to fix btw? I want to post these code segments to the wiki so others can use them.
"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: 3462
Joined: 10 Oct 2010, 00:58

Re: NullBot: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by aubergine »

Just noticed this in nullbot code (line 175 in nullbot-tail.inc):

Code: Select all

// checks if we can design tanks and research towers
 function iHaveCC() {
 	var list=enumStruct(me,command);
 	if (list.length == 0)
 		return false;
 	if (list[0].status == BEING_BUILT)
 		return false;
 	return true;
 }
How come it's using "command" custom constant instead of "HQ" js api constant?

Also, a nice trick for checking if a list is empty:

Code: Select all

if (!list.length) {
  // do stuff
}
0 type coerces to boolean false (any non-zero number will type coerce to boolean true)

So would the function be nicer as:

Code: Select all

// checks if we can design tanks and research towers
function iHaveCC() {
  var list=enumStruct(me,HQ);
  return (list.length && list[0].status == BUILT);
 }
Or maybe make more general function:

Code: Select all

// checks to see if we have at least one of the specified structure
function iHave(structure) {
  var list=enumStruct(me,structure);
  return (list.length && list[0].status == BUILT);
}

// do we have a CC?
if (iHave(HQ)) {
  // do stuff
}
"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: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by NoQ »

Sure you don't want an rw git account? :hmm:
User avatar
aubergine
Professional
Professional
Posts: 3462
Joined: 10 Oct 2010, 00:58

Re: NullBot: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by aubergine »

I need to get my OS upgraded so I can use some apps that make working with git and bitbucket a bit easier. So not just yet but maybe at a later date. My github userid is: aubergine10
"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: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by NoQ »

My github userid is: aubergine10
And yet again i regret i'm on sourceforge :lol2:
Anyway, yeah, good point about CC. There must be a lot of stupid stuff like that all around the code.
How come it's using "command" custom constant instead of "HQ" js api constant?
HQ is statType, command is an exact structure. We need to build "command" rather than "HQ", so we'd need that anyway.

P.S. You added iHave() function to your wiki, but it works only if there is a limit of only one structure of that type; otherwise list[0] may be incomplete, but we still have this structure.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: NullBot: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by Per »

If you use the qslint app, errors like that would show up. (It checks that arguments are of the right type.) Should I put error checks like that in the runtime as well?
User avatar
aubergine
Professional
Professional
Posts: 3462
Joined: 10 Oct 2010, 00:58

Re: NullBot: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by aubergine »

@NoQ - in regards to iHave, the function I added to wiki is really intended to see if there is at least one fully built structure of the given type, not to check that all structures of the type are built.

@Per - could it be made optional? Sometimes I do strange stuff that would confuse the lint tool.
"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: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by NoQ »

aubergine wrote:@NoQ - in regards to iHave, the function I added to wiki is really intended to see if there is at least one fully built structure of the given type, not to check that all structures of the type are built.
No, right now it checks if at least one was started and the first one of those that were started is fully built.
User avatar
dak180
Trained
Trained
Posts: 288
Joined: 01 Nov 2009, 23:58
Location: Keeper of the Mac Builds

Re: NullBot: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by dak180 »

aubergine wrote:I need to get my OS upgraded so I can use some apps that make working with git and bitbucket a bit easier. So not just yet but maybe at a later date. My github userid is: aubergine10
For working with git on a mac I would recommend GitX (L); if you can compile warzone then you should be able to use it without having to upgrade your OS.
User:dak180
Keeper of the Mac Builds
User avatar
aubergine
Professional
Professional
Posts: 3462
Joined: 10 Oct 2010, 00:58

Re: NullBot: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by aubergine »

NoQ wrote:
aubergine wrote:@NoQ - in regards to iHave, the function I added to wiki is really intended to see if there is at least one fully built structure of the given type, not to check that all structures of the type are built.
No, right now it checks if at least one was started and the first one of those that were started is fully built.
Fixed :) https://warzone.atlassian.net/wiki/page ... Id=4816939
"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: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by NoQ »

v1.16.

Changes:
  • CPU optimizations! Now NullBot slows down the game much less, thanks aubergine for the exact caching idea.
    • I still re-written it in the way i understand better ...
  • Fixed some strange bug that made NullBot fail to start on certain very rare maps
    • The initial trucks are still digged into the ground a little, and they don't seem to move out of the way properly when the structure is placed exactly on top of one of them.
    • Also, remove a 5-second delay before AI start.
  • Enable control of pre-placed combat units
    • Won't work in 3.1_beta7 yet, see #3359...
  • Fixed a little typo in scavenger AI
User avatar
aubergine
Professional
Professional
Posts: 3462
Joined: 10 Oct 2010, 00:58

Re: NullBot: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by aubergine »

What is the scav AI in nullbot? I noticed it on the downlaods page but wasn't sure if it was part of ultimate scav mod?
"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: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by NoQ »

Yeah, based on ultimate scav mod code, but with all the extra data removed. So it doesn't build towers and factories, capture oils or make VTOLs, but still produces more templates (made of existing models) and attacks you (at all / more intelligently). First mentioned in this changelog.
User avatar
Giani
Regular
Regular
Posts: 804
Joined: 23 Aug 2011, 22:42
Location: Argentina

Re: NullBot: an adaptive skirmish AI for Warzone 2100 v3.1+

Post by Giani »

In the map Mero_riverX whit advanced bases nullbot only takes 1 derrick from outside of his base.
My maps: http://forums.wz2100.net/viewtopic.php?f=10&t=9501