[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

[3.1+] NullBot: an adaptive skirmish AI

Post by NoQ »

Recent master snapshots provide us with the new javascript engine that is flexible enough to create full-featured AIs for the game in pure javascript. Semperfi-JS is an AI for master/v3.1+ that is written in javascript that is already included with the game, but it still lacks some features. So i just wanted to make a simple AI in javascript, and here's what it turned out to be.
Usage:
NullBot is included into the game since 3.1, so you may use it without installing. If you want to try a different version or a different personality, use the standard procedure: Installing a mod. Detailed explanation below:
Spoiler:
When you want to practice something similar to a real multiplayer experience, try the normal AI on Hard difficulty. If you want to make sure your enemies pick exact strategies, try the extra personality pack instead; you can also use the personality pack for making single-player challenges. [/list]


Features:
  • NullBot is a non-cheating AI. Well, actually, it deity-cheats on hard difficulty and above (assumes full visibility; much like DyDo AI used to do; it doesn't share this full visibility with his teammates though), but it doesn't make him actually do anything impossible or violate game rules. Well, at least it doesn't give itself unlimited oil and fast research, and it doesn't build things that were not researched yet.
  • NullBot multitasks with several groups. The whole army of NullBot is split into a varying number of groups (from 1 to 6, depending on the game situation), and droids of each group try to act together and help each other. Every group is responsible for a particular enemy player, even though multiple groups may fight against a single enemy. The average size of groups gets bigger as the game progresses.
  • NullBot adapts to the enemy choices by changing its weapon choice and even research path based on the opponent's prefered way of playing. For instance, if you overuse cyborgs, you will be dealt with by NullBot's machineguns or flamers, and his research of anti-tank weapons will be cut, and if you make too many defensive structures, he will research and send mortars or bunker busters on you.
  • NullBot has multiple personalities:
    • Default
    • MG/Rockets
    • MG/Cannons
    • Flamer spamer
    • Rocket hover techer
    • Turtle (defensive)
    The default NullBot picks one of the following five weapon branches: MG/Cannons, MG/Rockets, Flamers/Cannons, Flamers/Rockets or MG/Flamers, and can pick different initial base build orders for different personalities. It always uses lasers as a late-game AP weapons. The extra package contains AIs with fixed personalities: MG/Cannons AI, MG/Rockets AI, Flamer AI, Rocket Hover AI and VTOL Turtle AI. These extra AIs don't feature adaptive research path though.
  • NullBot works correctly on sea maps. Even though Hover AI is still stronger on sea-only maps, all other personalities have this adaptation enabled as well on all difficulty levels. It attacks ground-reachable enemies first, then tries to research hovers as soon as possible. It also doesn't use ground tanks against sea enemies. Note: it doesn't yet work correctly on VTOL-only maps.
Supported in-game chat commands (for warzone2100 v3.2+ only!):
Spoiler:
Difficulty levels:
  • EASY: Research specialization and all adaptation mechanisms are disabled. The AI researches all technologies in a particular order and spams units without considering the opponent's choices, which makes him pretty weak. Note that lack of research specialization has less effect in team matches, where a team of 4 actually has a chance of researching most of the technologies.
  • MEDIUM: Research specialization is enabled, but research and production adaptation is still disabled. The AI picks one of the five pre-defined narrow research paths and researches its sub-branches uniformly, regardless of the game situation.
  • HARD: This is the best non-cheating AI i could make. It rapidly adapts its research path and unit designs to the enemy choices. Note that it doesn't necessarily defeat the Medium AI, because adaptation is not really effective against anybody who makes the same choices all the time. But this AI is designed to have as little amount of clear flaws exploitable by humans as possible; ideally, the only chance of defeating Hard AI is actually playing better than him.
  • INSANE: This AI differs from Hard AI only due to the hard-coded cheats it is bound to use, like preserving all defenses in no-bases mode. On 3.2+, it will have double power (you can already see that in the current master).
Note that not all of these difficulty levels make sense for the extra personalities. They usually don't discriminate between Easy and Medium, because they were designed with a specific research path in mind. The difference between Medium and Hard is also less, because most of the personalities don't support research adaptation yet. For ~Turtle~ AI, Medium and Hard difficulties are completely equal, for it doesn't really produce tanks.

Known bugs:
  • Some of this code is highly ineffective and CPU-intensive. It may cause the game to slow down or stutter when you have a lot of units on the map and many AI instances are running simultaneously.
  • AI units may sometimes get stuck. Even though some workarounds for it exist in the AI code, it should rather be fixed on the game/c++ side by creating a more effective pathfinder.
  • This AI doesn't make proper use of map gateways. In v3.1, gateways are not supported at all by the JS engine, while in 3.2/master there is still no easy way to find out wether some tile of the gateway is already blocked.
  • There is some strange error message about some "missing template 140" that i don't really understand, see also #3161. A certain workaround applied in v1.0, that makes this bug very rare, but it can still be reproduced artificially.
  • Machinegun and cannon VTOLs may behave weirdly on 3.1, see also #3178
  • NullBot doesn't use commanders. This won't be fixed until commanders are actually useful in multiplayer.
Challenges:
  • The extra mod includes a remake of "Back to Basics" challenge (with NullBot ~MC~ as your enemy) and "Hide Behind Me" challenge (with NullBot ~MR~ controlling your allies). Note that NullBot is a non-cheating AI, so the challenges will not necessarily be more difficult or more easy.
  • It also includes two more challenges: the "Startup" challenge (Startup T1 no bases, with NullBot ~MC~ as your enemy showing how the standard MG rush works), and the "Flame Wars" challenge, where you fight on Mountain map against NullBot ~Flame~ and two turtles.
  • Here is a single-player challenge called "Anchor". It is based on NullBot v0.11 and features all four personalities this AI had.
  • Here is a single-player challenge called "The Paradigm". It is based on NullBot v1.29 (~MC~ and ~Hover~ personalities), and you enjoy having a NullBot Scavenger AI as your ally.
AI vs. AI matches

Please read this howto carefully before trying to make AI vs. AI matches, to avoid many common mistakes.
Spoiler:
Note: there is no "autogame on"-like cheat that you can use to make NullBot control your units. The "autogame on" cheat makes Nexus AI on Easy difficulty control your units.
Last edited by Staff on 29 Sep 2014, 03:21, edited 113 times in total.
Reason: fix CC0 image
User avatar
Berg
Regular
Regular
Posts: 2204
Joined: 02 Sep 2007, 23:25
Location: Australia

Re: NullBot: yet another AI for master

Post by Berg »

Its good you have made this AI ..
I had this idea of having multi player warzone where you have observer mode and you AI making folks could pit your AI"S agains each other ..this would need a fix for the diff data and the multi player screaming cheat but think robot warzone


anyway just a idea
regards berg

AI wars ! make your AI and attack your fellow AI maker
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: NullBot: yet another AI for master

Post by NoQ »

AI wars !
There's no problem in making AI wars on a single computer in skirmish mode, i did a lot of it while testing both MCRbot and NullBot.

If many AIs appear, we could make an AI tournament by posting a few AIs and recording their matches on videos.
User avatar
Terminator
Regular
Regular
Posts: 1077
Joined: 05 Aug 2006, 13:46
Location: Ukraine
Contact:

Re: NullBot: yet another AI for master

Post by Terminator »

AI wars. I like this idea ! It would make a challenge for AI makers & will bring a better AI for warzone & community
Death is the only way out... sh*t Happens !

Russian-speaking Social network Group http://vk.com/warzone2100
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: NullBot: yet another AI for master

Post by NoQ »

For this, we need to define what exactly a non-cheating AI is (in such a way that there are at least two non-cheating AIs available).
User avatar
Berg
Regular
Regular
Posts: 2204
Joined: 02 Sep 2007, 23:25
Location: Australia

Re: NullBot: yet another AI for master

Post by Berg »

make it a honesty system AI has to be published after each win that way giving the apposing AI creator Food for thought.
In the end the AI's will evolve to be the best in the land ...
Hopefully
User avatar
Arreon
Trained
Trained
Posts: 324
Joined: 15 Feb 2009, 05:57
Contact:

Re: NullBot: yet another AI for master

Post by Arreon »

Keep up the good work, I like this AI. :)

First off, it uses templates that none of the other AIs use. Perhaps you can find a way to "import" stored templates (new master feature) into the ai scripts.
OS: Windows 7 Home Premium 64-bit
Processor: AMD Phenom II X6 1045T (6 CPUs), ~2.7GHz
Memory: 8192MB RAM
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: NullBot: yet another AI for master

Post by Per »

I like it :-) It seems to defeat the AI opposition most of the time.

One question. Why do you call doResearch() all the time? Is there a bug with research events? It should not be necessary to run this in a timer at all - you should be able to rely on events to tell you when to research the next thing. The same goes for produceDroids(). I have a very rarely called timer in Semperfi-js which just sanity checks that bugs didn't eat production / research orders.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: NullBot: yet another AI for master

Post by NoQ »

Per wrote:Why do you call doResearch() all the time?
It has to be called in eventResearched and eventStructureBuilt and ... anything else? Well, i left those timers just to be sure i didn't forget anything. I'll try to remove them :3

By the way, does eventResearched get called when an ally finishes some research? Cause i didn't make sure labs are filled all the time (the lab remains idle instead of researching random things when the research path doesn't provide anything else to research).
Arreon wrote:First off, it uses templates that none of the other AIs use. Perhaps you can find a way to "import" stored templates (new master feature) into the ai scripts.
You can construct templates in run-time both in master and 2.3; my previous AI experiment, MCRbot, used twin assault cannons and other fancy things that aren't mentioned in templates.txt or assignweapons.txt. The new JS engine isn't aware of templates at all; you just order a factory to produce unit with some body, some propulsion and some weapons as separate function arguments.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: NullBot: yet another AI for master

Post by aubergine »

These two for loops seem to be the same, and if so the second would either never get called or do just the same as the first?

Code: Select all


// pick a suitable group for a new-born tank
function addTankToSomeGroup(tank) {
	for (var i=0; i<NUM_GROUPS; ++i)
		if (groupSize(battleGroup[i])<NUM_WARRIORS) {
			groupAddDroid(battleGroup[i], tank);
			return;
		}
	for (var i=0; i<NUM_GROUPS; ++i)
		if (groupSize(battleGroup[i])<MAX_WARRIORS) {
			groupAddDroid(battleGroup[i], tank);
			return;
		}
 ...
"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 master

Post by NoQ »

NUM_WARRIORS < MAX_WARRIORS.
We fill all groups till NUM_WARRIORS, and only then start filling them till MAX_WARRIORS.
The return statement guarantees that only one groupAddDroid call happens.
Or is there a better way to implement this?
cybersphinx
Inactive
Inactive
Posts: 1695
Joined: 01 Sep 2006, 19:17

Re: NullBot: yet another AI for master

Post by cybersphinx »

Arreon wrote:Perhaps you can find a way to "import" stored templates (new master feature) into the ai scripts.
So by only storing crap templates, the AI will only build crap units?
We want information... information... information.
User avatar
lav_coyote25
Professional
Professional
Posts: 3434
Joined: 08 Aug 2006, 23:18

Re: NullBot: yet another AI for master

Post by lav_coyote25 »

cybersphinx wrote:
Arreon wrote:Perhaps you can find a way to "import" stored templates (new master feature) into the ai scripts.
So by only storing crap templates, the AI will only build crap units?
well if this AI is anything like the semperfi-js AI - wont matter. it just sits in its base and does nothing, and when i quit, and try to get another game, crashes the game to desktop.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: NullBot: yet another AI for master

Post by Per »

The AI will not research anything that an ally is researching, so that should not be a problem. However, I've noted that if a human player races to researche something that an allied AI was already researching, then that AI's research lab will become idle without eventResearched being triggered for it. Will look for a fix for that.

In general, when I wrote the events/triggers, I did not think much about what events an AI wants from things that happens to allies, not itself. I will need to go over the events with that in mind.
User avatar
lav_coyote25
Professional
Professional
Posts: 3434
Joined: 08 Aug 2006, 23:18

Re: NullBot: yet another AI for master

Post by lav_coyote25 »

Per wrote:The AI will not research anything that an ally is researching, so that should not be a problem. However, I've noted that if a human player races to researche something that an allied AI was already researching, then that AI's research lab will become idle without eventResearched being triggered for it. Will look for a fix for that.

In general, when I wrote the events/triggers, I did not think much about what events an AI wants from things that happens to allies, not itself. I will need to go over the events with that in mind.
so these ai are not for skirmish . then what use are they|? :annoyed: :annoyed: :annoyed: :annoyed: :annoyed: :annoyed:
Post Reply