[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
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by Shadow Wolf TJC » 12 Jan 2013, 14:54

Nevermind. Looks like I'm online.

Edit: Since NoQ hasn't been present for a while, I've decided to copy-paste this here in case he missed it on IRC:
What would you like for us to cooperate on together exactly?

As mentioned before, NoQ, you're free to borrow from NullBotSW to improve upon the default NullBot if you'd like. After all, NullBotSW is a derivative work of NullBot. (By the way, what do you like about NullBotSW so far?)

While I do have the Rocket AI up and running, I have a few ideas that I'd like to experiment with in the near-future. NullBotSW is still in beta, so what I've done to it so far is just a sample of what I have planned for it.
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100

User avatar
NoQ
Special
Special
Posts: 6197
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by NoQ » 12 Jan 2013, 16:39

Ok i'm back.
There was no need to panic (: I was present, and thus i read what you say when i come back. There's no problem if you just leave the tab opened in the background until we accidentally meet.
I know i can theoretically borrow the code, i just wanted to make it 1000 times easier - both for me to borrow your code and for you to borrom my code (you seem to be two versions delayed already).
Right now borrowing your code doesn't seem any easier than writing the same code from scratch in most cases. And if i make a change you're interested in, you also have no other way but to merge it manually.
With the use of proper methods it can be simplified to mouse-clicking "oh, give me this change, give me that change, yeah, that change looks good to" and - click - you get it all. This way we can cooperate even if we're going in completely opposite directions.

User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by Shadow Wolf TJC » 12 Jan 2013, 18:28

Sorry. While I noticed earlier that you were afk, I was too impatient to wait.

Anyways, do you keep a repository for NullBot? I'm having trouble finding it on Git, and I should absolutely consider taking a look at what you've done to NullBot 2.0.2.
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100

User avatar
NoQ
Special
Special
Posts: 6197
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by NoQ » 12 Jan 2013, 18:34

You can see how my git looks at http://sourceforge.net/p/nullbot2100/code/ , also check out the history button.
Right now i'd really prefer github over sourceforge; you can use any and we can still communicate.

Btw i'm still talking in the chat (:

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by aubergine » 12 Jan 2013, 19:33

+1 for github - sooo much better for general stuff than sf. Also home to main WZ repo and lots of other mods like cartoon tileset, all felipe's ini work, etc.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by Shadow Wolf TJC » 12 Jan 2013, 21:19

Well NoQ, in case you were wondering what exact changes I've made to NullBot so far, here's the list:

- Updated Rocket AI's research and component lists to make use of what I believe to be more up-to-date information on Contingency material.
- Increased max size of harassGroup to 32 units.
- NullBotSW doesn't add units to the harassGroup when it has too few units (like, say, 10). On the other hand, its chances of adding units to harassGroup increase the fewer units are present in harassGroup, as well as the more units NullBotSW has in total.
- NullBotSW now builds artillery structures for more offensive purposes, as well as Radar Detector towers, and both Counter-Battery and Radar Detector tanks to make better use of them.
- NullBotSW now attempts to build a single Wind Farm each minute. The reason why it was programmed to build them so infrequently was because Wind Farms are not only costly to build, but they generate so little power per second, compared to an Oil Derrick, that building them too frequently could cause the player to not have enough power to repel enemy attacks.
- Added a new economical research branch for NullBotSW, so that it can choose to focus research on improving its economy if it finds itself low on power.
- Adaptation scripting now takes into account many of the relative differences between tanks and cyborgs in Contingency (where Cyborgs are both much cheaper and less durable than tanks).
- NullBotSW on HARD and INSANE difficulty will sometimes stop and redirect production of tanks, cyborgs, and/or vtols in an effort to make it harder for opponents to adapt to it. One minute, it could be producing all tanks, and the next minute, it could be producing all cyborgs.
- NullBotSW is a bit more efficient when it comes to power management. It'll sometimes choose NOT to put factories, research labs, or trucks to work if it sees that it's very low on power.
- NullBotSW now builds a research lab for every 4 derricks it possesses instead of every 3 derricks.
- NullBotSW now prioritizes building additional power generators every 4 derricks over building additional research labs every 4 derricks.
- NullBotSW now, by default, builds one VTOL rearming pad for every 4 VTOLs that it has, since it'll assume that not every VTOL that it sends to attack targets will make it back to base.
-- The only exception to this rule is if it has a lot of free power, in which case, NullBotSW will build one VTOL rearming pad for every VTOL that it has.
- NullBotSW now waits until it has a sizable number of VTOLs before it launches its 1st attack with them.
- NullBotSW now has support for producing AA and AB Cyborgs. While Contingency currently only features AA Cyborgs, the scripting's in place in case other mods feature AA or AB Cyborgs.
- NullBotSW now randomly builds different sizes of units for the same reasons why players in Contingency would want to build them: namely because some weapons in Contingency (such as the Proto-Railgun and Oblivion TBM) are far too powerful to use on lighter units. Thankfully, NullBotSW is programmed to use size-specific lists of turrets in order to avoid building units that are too heavy for their engines to support.
- NullBotSW will sometimes choose to build heavy and durable trucks instead of light and fast trucks. Reason being that, although more expensive, they tend to have a better chance of surviving (and may even mount heavier, more powerful truck turrets).
- While work has started on having NullBotSW produce dedicated harasser units that use their own independent component lists, NullBotSW doesn't yet make use of them.
- NullBotSW's starting build order is now much more modular, allowing it to support custom map-specific build orders.
- NullBotSW currently, by default, follows an FRRCFR build order for Contingency. While it does mean that it starts out disadvantaged in terms of research (compared to NullBot 2.0), it also means that it can get a few harassers out to take out enemy oil-hunters and derricks.
-- To complement this change, all tanks that NullBotSW produces are automatically assigned to harassGroup.
-- However, as it's quite possible for an enemy to repel this kind of early rush, especially with the help of some early tech research (as NullBot 2.0 does), NullBotSW's PEACE_TIME variable was also reduced from 10 to less than 3. Hopefully, the early harasser rush would give NullBotSW time to secure some extra Oil Derricks to supply enough power to allow it to amass a large enough attack force to not only repel the inevitable counterattack, but to also follow up the rush with a massed assault.
- NullBotSW's ability to decide whether or not to execute an All-In maneuver against opponents was changed. It will send its forces on the offensive when it's close to reaching its unit cap, as well as if it detects that the opponent's forces are below a certain strength. Depending on what the new PEACEFULNESS variable's value is, NullBotSW could opt to attack enemy bases only when it has a significant edge over the opponent (EASY), be reckless and attack even when somewhat outnumbered (NORMAL), or be cautious when attacking enemy forces (HARD and INSANE).
-- Also, when deciding whether or not to execute All-In maneuvers, in addition to factoring in the relative strengths and weaknesses of tanks, cyborgs, and vtols (as mentioned earlier), NullBotSW will ignore long-range artillery, and place less importance on how many defenses the opponent has (since defenses are immobile).
- NullBotSW will now attempt to hunt for enemy derricks, even if the player owning them has been neutralized. This is so that it can capture and secure oil that was previously held by now-vanquished enemy players.
- While the becomeHarder() function is still intact and usable, by default, NullBotSW doesn't make use of it. This was done in the hopes that NullBotSW would be more capable of performing pronged attacks.
- NullBotSW regroups less frequently, so that it can arrive at its intended target a bit sooner. While regroupRegularly has been set to fire every 5 seconds for HARD and INSANE difficulty, it's also been set to fire every 15 seconds for NORMAL difficulty, and to not fire at all for EASY difficulty in order to make them seem weaker.
- NullBotSW's ability to retreat damaged units is weakened on NORMAL difficulty, and disabled on EASY difficulty.
- distanceToNearestStructure() function given a player parameter, that defaults to "me" if unspecified. This would allow NullBotSW to find the closest specified structure that belongs not only to it, but also to enemy players.
- Small bug fixes:
-- Fixed a small glitch that caused NullBot 2.0 to occasionally build a Power Generator prematurely upon game startup.
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100

cue
Trained
Trained
Posts: 59
Joined: 06 Nov 2011, 00:12

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by cue » 12 Jan 2013, 21:20

Exciting stuff you guys.
Good to see you have able help NoQ

User avatar
NoQ
Special
Special
Posts: 6197
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by NoQ » 13 Jan 2013, 07:27

-- Fixed a small glitch that caused NullBot 2.0 to occasionally build a Power Generator prematurely upon game startup.
Well, if you show me where this bug was, that'd be great (:
case you were wondering what exact changes I've made
Well, that was ~5% of what i was wondering. Even with this list, it's still easier to re-implement these ideas from scratch than to try to figure out what part of your code changes was responsible for it.

Some of these i like (eg. AA and AB cyborgs do make some sense even in the base game; effective small-body-light-weapon support is even nicer), some of these i disagree with (eg., completely disabling regroup on EASY makes the AI completely dummy (much worse than Nexus in this sense), since NullBot runs attacks every few seconds rather than every few minutes, so units will be completely ungrouped; there are some other tweaks you made against some already very well-tested stuff, which may be good for contingency, but break the base game, eg. lab per power count), some of these i'd better have implemented some other way (eg., i won't ever put windmill code into -main, but rather make it part of the personality's build order; random switches from borgs to tanks i'd rather replace with direct adaptation to enemy weapons when it becomes available on the API side).

But it is pointless to discuss particular changes now. If you proceed doing things this way, our code will soon become completely incompatible, and no sharing will be possible at all. If it's ok for you, then i stop bothering you.

themac
Trained
Trained
Posts: 343
Joined: 17 Jul 2009, 19:14
Location: Germany

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by themac » 13 Jan 2013, 10:48

Oh my god, he has completely messed up NullBot. Maybe he should give it a new name after so many changes. xD

User avatar
NoQ
Special
Special
Posts: 6197
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by NoQ » 13 Jan 2013, 15:57

(: he couldn't make it worse than it already is (: Also, Contingency is worth having an AI, it'd be great if i don't need to think about it anymore :P

The code of NullBot is very dirty and hardly readable. It was originally a quick-and-dirty AI made by a man who, in his crazy rush of amazement, never want to listen about coding standards. Probably a rewrite from scratch can fix it ...

User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by Shadow Wolf TJC » 13 Jan 2013, 16:23

NoQ wrote:
-- Fixed a small glitch that caused NullBot 2.0 to occasionally build a Power Generator prematurely upon game startup.
Well, if you show me where this bug was, that'd be great (:
I added a simple check to the start of the keepBuildingThings() function, turning it from this:

Code: Select all

// expand the base by building more labs and factories
function keepBuildingThings() {
	var labCount = enumStruct(me, lab).length;
	var factoryCount = enumStruct(me, factory).length;
	var ccCount = enumStruct(me, command).length;
	var genCount = enumStruct(me, generator).length;
	var cbCount = enumStruct(me, cbtower).length;
	var detectorCount = enumStruct(me, detector).length;
	var derrickCount = enumStruct(me, derrick).length;
...
	
to this:

Code: Select all

// expand the base by building more labs and factories
function keepBuildingThings() {
	if (earlyGame(personality.PEACE_TIME) && difficulty != EASY) //Don't do this at the start of the game!
		return;
	var labCount = enumStruct(me, lab).length;
	var factoryCount = enumStruct(me, factory).length;
	var ccCount = enumStruct(me, command).length;
	var genCount = enumStruct(me, generator).length;
	var cbCount = enumStruct(me, cbtower).length;
	var detectorCount = enumStruct(me, detector).length;
	var derrickCount = enumStruct(me, derrick).length;
...
	
Since a build order wasn't defined for the EASY difficulty level, it should still use keepBuildingThings to build up its base. However, since you may wish to use a PEACE_TIME variable that's higher than 3 (minutes), you may want to use a different kind of check to accomplish this task.
Some of these i like (eg. AA and AB cyborgs do make some sense even in the base game; effective small-body-light-weapon support is even nicer),
Thanks. Glad you liked those. :D
some of these i disagree with (eg., completely disabling regroup on EASY makes the AI completely dummy (much worse than Nexus in this sense), since NullBot runs attacks every few seconds rather than every few minutes, so units will be completely ungrouped;
Yeah. I had a feeling that our ideas on how our AIs should behave would have some differences. Oh well, that's just the nature of a fork I guess.
there are some other tweaks you made against some already very well-tested stuff, which may be good for contingency, but break the base game, eg. lab per power count), some of these i'd better have implemented some other way
Understandable, since NullBotSW started off as a heavily modified NullBot 2.0 AI designed specifically for use in Contingency. We should probably consider adding, say, a DERRICKS_PER_LAB variable in the future.
(eg., i won't ever put windmill code into -main, but rather make it part of the personality's build order;
Other mods in the future could make use of alternate power sources (sometimes even more than 1 of them), so I'd personally want to keep the code in place, and maybe even expand upon it. Although, we could leave it blank for vanilla Warzone 2100.
random switches from borgs to tanks i'd rather replace with direct adaptation to enemy weapons when it becomes available on the API side).
I feel the same way. However, until that time comes, this seems the next best thing. :wink:
But it is pointless to discuss particular changes now. If you proceed doing things this way, our code will soon become completely incompatible, and no sharing will be possible at all. If it's ok for you, then i stop bothering you.
I may not have much experience with git, but the method that I recently used to identify what was causing NullBotSW to not send out harassers to attack enemy Oil Derricks was to create a copy of NullBotSW's code, revert it to NullBot 2.0's code, then gradually copy/paste the code from NullBotSW's that worked for other things back to the reverted code, leaving out the code that dealt specifically with producing dedicated harassers, and assigning units to different groups.

There is one last change that I forgot to mention earlier about NullBotSW: that all Cyborg templates now had a propulsion component defined in addition to a body and weapon/system component. This is in case mods (such as Contingency) feature more than 1 propulsion system for Cyborgs to use.
themac wrote:Oh my god, he has completely messed up NullBot. Maybe he should give it a new name after so many changes. xD
I wouldn't say "messed up". I'd rather say "heavily modified", since its code is organized mostly the same as NullBot 2.0's code (although some pieces of code, such as the SetTimers() function, were moved to different .inc files, which I personally felt were a better location for them).

Even then, there's still the possibility that code from NullBotSW would be incorporated into future versions of NullBot.
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100

User avatar
NoQ
Special
Special
Posts: 6197
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by NoQ » 15 Jan 2013, 07:10

Well, reading all this and seeing where this all is going, i think i know what i need.

User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by Shadow Wolf TJC » 15 Jan 2013, 16:26

Would you like for me to put all future builds of NullBotSW in a separate thread? I'm still in the process of fine-tuning it, adding new features in the process.
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100

User avatar
NoQ
Special
Special
Posts: 6197
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by NoQ » 15 Jan 2013, 16:42

Whatever you find convenient.
I'm interested in observing what you change (:

User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: [3.1+] NullBot: an adaptive skirmish AI

Post by aubergine » 16 Jan 2013, 01:01

@shadow: it would really help if you had your code in github or some similar system - that way people can keep track of changes, post comments on changes, etc. and also means you'd have a backup of all your code in case your computer breaks.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO

Post Reply