Skip to content

Commit

Permalink
Update the NullBot AI to version 3.06.
Browse files Browse the repository at this point in the history
This is a major update from NullBot 2.05.
The AI should now cause less lags and offer
more varied and adaptive gameplay,
with a different algorithm for picking
weapon branches during the game.

The set of selectable AI personalities remain
the same. The Turtle AI is updated to randomly
choose a cannon/mortar-based research path.
The generic AI no longer chooses the
machinegun-flamer research path because
balance intentions have changed.

All AIs now should be adapted quite well
to sea-only and air-only maps. Hover AI
would also use land propulsions on land maps,
which essentially turns it into an AI
with an ultra-technological build order,
still focused on rockets.
  • Loading branch information
haoNoQ committed Jul 1, 2016
1 parent 6744ea2 commit 11ef362
Show file tree
Hide file tree
Showing 31 changed files with 3,601 additions and 4,871 deletions.
45 changes: 45 additions & 0 deletions data/mp/multiplay/skirmish/nb_common/standard_build_order.js
@@ -0,0 +1,45 @@

// A fallback build order for the standard ruleset.

function buildOrder_StandardFallback() {
var derrickCount = countFinishedStructList(structures.derricks);
// might be good for Insane AI, or for rebuilding
if (derrickCount > 0)
if (buildMinimum(structures.gens, 1)) return true;
// lab, factory, gen, cc - the current trivial build order for the 3.2+ starting conditions
if (buildMinimum(structures.labs, 1)) return true;
if (buildMinimum(structures.factories, 1)) return true;
if (buildMinimum(structures.gens, 1)) return true;
// make sure trucks go capture some oil at this moment
if (buildMinimumDerricks(1)) return true;
// what if one of them is being upgraded? will need the other anyway.
// also, it looks like the right timing in most cases.
if (buildMinimum(structures.gens, 2)) return true;
if (buildMinimum(structures.hqs, 1)) return true;
// make sure we have at least that much oils by now
if (buildMinimumDerricks(5)) return true;
// support hover maps
var ret = scopeRatings();
if (ret.land === 0 && !iHaveHover())
if (buildMinimum(structures.labs, 4)) return true;
if (ret.land === 0 && ret.sea === 0 && !iHaveVtol())
if (buildMinimum(structures.labs, 4)) return true;
if (gameTime > 300000) {
// build more factories and labs when we have enough income
if (buildMinimum(structures.labs, derrickCount / 3)) return true;
if (needFastestResearch() === PROPULSIONUSAGE.GROUND) {
if (buildMinimum(structures.factories, 2)) return true;
if (scopeRatings().land > 0)
if (buildMinimum(structures.templateFactories, 1)) return true;
}
if (buildMinimum(structures.vtolFactories, 1)) return true;
return false;
}
// support hover maps
var ret = scopeRatings();
if (ret.land === 0 && !iHaveHover())
if (buildMinimum(structures.labs, 4)) return true;
if (ret.land === 0 && ret.sea === 0 && !iHaveVtol())
if (buildMinimum(structures.labs, 4)) return true;
return true;
}
160 changes: 160 additions & 0 deletions data/mp/multiplay/skirmish/nb_generic.js
@@ -0,0 +1,160 @@

/*
* This file defines a standard AI personality for the base game.
*
* It relies on ruleset definition in /rulesets/ to provide
* standard strategy descriptions and necessary game stat information.
*
* Then it passes control to the main code.
*
*/

// You can redefine these paths when you make a customized AI
// for a map or a challenge.
NB_PATH = "/multiplay/skirmish/";
NB_INCLUDES = NB_PATH + "nb_includes/";
NB_RULESETS = NB_PATH + "nb_rulesets/";
NB_COMMON = NB_PATH + "nb_common/";

// please don't touch this line
include(NB_INCLUDES + "_head.js");

////////////////////////////////////////////////////////////////////////////////////////////
// Start the actual personality definition

// the rules in which this personality plays
include(NB_RULESETS + "standard.js");
include(NB_COMMON + "standard_build_order.js");

// variables defining the personality
var subpersonalities = {
MR: {
chatalias: "mr",
weaponPaths: [ // weapons to use; put late-game paths below!
weaponStats.rockets_AT,
weaponStats.machineguns,
weaponStats.rockets_AS,
weaponStats.rockets_AA,
weaponStats.rockets_Arty,
],
earlyResearch: [ // fixed research path for the early game
"R-Wpn-MG-Damage01",
"R-Defense-Tower01",
"R-Vehicle-Prop-Halftracks",
"R-Struc-PowerModuleMk1",
"R-Wpn-MG-Damage03",
],
minTanks: 1, // minimal attack force at game start
becomeHarder: 3, // how much to increase attack force every 5 minutes
maxTanks: 16, // maximum for the minTanks value (since it grows at becomeHarder rate)
minTrucks: 2, // minimal number of trucks around
minHoverTrucks: 3, // minimal number of hover trucks around
maxSensors: 1, // number of mobile sensor cars to produce
minMiscTanks: 1, // number of tanks to start harassing enemy
maxMiscTanks: 2, // number of tanks used for defense and harass
vtolness: 65, // the chance % of not making droids when adaptation mechanism chooses vtols
defensiveness: 65, // same thing for defenses; set this to 100 to enable turtle AI specific code
maxPower: 700, // build expensive things if we have more than that
repairAt: 50, // how much % healthy should droid be to join the attack group instead of repairing
},
MC: {
chatalias: "mc",
weaponPaths: [
weaponStats.cannons,
weaponStats.machineguns,
weaponStats.mortars,
weaponStats.cannons_AA,
],
earlyResearch: [
"R-Wpn-MG-Damage01",
"R-Vehicle-Prop-Halftracks",
"R-Wpn-Cannon1Mk1",
"R-Struc-PowerModuleMk1",
"R-Wpn-MG-Damage03",
],
minTanks: 1, becomeHarder: 3, maxTanks: 16,
minTrucks: 3, minHoverTrucks: 4, maxSensors: 1,
minMiscTanks: 1, maxMiscTanks: 2,
vtolness: 65, defensiveness: 65,
maxPower: 700,
repairAt: 50,
},
FR: {
chatalias: "fr",
weaponPaths: [
weaponStats.rockets_AT,
weaponStats.flamers,
weaponStats.fireMortars,
weaponStats.rockets_AA,
weaponStats.lasers,
],
earlyResearch: [
"R-Wpn-Flamer-ROF01",
"R-Vehicle-Prop-Halftracks",
"R-Struc-PowerModuleMk1",
],
minTanks: 1, becomeHarder: 3, maxTanks: 16,
minTrucks: 3, minHoverTrucks: 4, maxSensors: 1,
minMiscTanks: 1, maxMiscTanks: 2,
vtolness: 65, defensiveness: 65,
maxPower: 700,
repairAt: 50,
},
FC: {
chatalias: "fc",
weaponPaths: [
weaponStats.cannons,
weaponStats.flamers,
weaponStats.fireMortars,
weaponStats.cannons_AA,
weaponStats.lasers,
],
earlyResearch: [
"R-Wpn-Flamer-ROF01",
"R-Vehicle-Prop-Halftracks",
"R-Wpn-Cannon1Mk1",
"R-Struc-PowerModuleMk1",
],
minTanks: 1, becomeHarder: 3, maxTanks: 16,
minTrucks: 3, minHoverTrucks: 4, maxSensors: 1,
minMiscTanks: 1, maxMiscTanks: 2,
vtolness: 65, defensiveness: 65,
maxPower: 700,
repairAt: 50,
},
};

// this function describes the early build order
// you can rely on personality.chatalias for choosing different build orders for
// different subpersonalities
function buildOrder() {
// Only use this build order in early game, on standard difficulty, in T1 no bases.
// Otherwise, fall back to the safe build order.
if (gameTime > 300000 || difficulty === INSANE
|| isStructureAvailable("A0ComDroidControl") || baseType !== CAMP_CLEAN)
return buildOrder_StandardFallback();
if (personality.chatalias === "fc" || personality.chatalias == "fr") {
if (buildMinimum(structures.labs, 1)) return true;
if (buildMinimum(structures.factories, 1)) return true;
if (buildMinimum(structures.labs, 2)) return true;
if (buildMinimum(structures.factories, 2)) return true;
if (buildMinimumDerricks(2)) return true;
if (buildMinimum(structures.hqs, 1)) return true;
if (buildMinimum(structures.gens, 2)) return true;
} else {
if (buildMinimum(structures.factories, 2)) return true;
if (buildMinimumDerricks(1)) return true;
if (buildMinimum(structures.labs, 1)) return true;
if (buildMinimum(structures.hqs, 1)) return true;
if (buildMinimum(structures.factories, 3)) return true;
if (buildMinimum(structures.gens, 2)) return true;
}
return captureSomeOil();
}



////////////////////////////////////////////////////////////////////////////////////////////
// Proceed with the main code

include(NB_INCLUDES + "_main.js");
@@ -1,6 +1,6 @@
{
"AI": {
"js": "nullbot.js",
"js": "nb_generic.js",
"name": "NullBot",
"tip": "NullBot - an adaptive skirmish AI"
}
Expand Down
103 changes: 103 additions & 0 deletions data/mp/multiplay/skirmish/nb_hover.js
@@ -0,0 +1,103 @@

/*
* This file defines a standard AI personality for the base game.
*
* It relies on ruleset definition in /rulesets/ to provide
* standard strategy descriptions and necessary game stat information.
*
* Then it passes control to the main code.
*
*/

// You can redefine these paths when you make a customized AI
// for a map or a challenge.
NB_PATH = "/multiplay/skirmish/";
NB_INCLUDES = NB_PATH + "nb_includes/";
NB_RULESETS = NB_PATH + "nb_rulesets/";
NB_COMMON = NB_PATH + "nb_common/";

// please don't touch this line
include(NB_INCLUDES + "_head.js");

////////////////////////////////////////////////////////////////////////////////////////////
// Start the actual personality definition

// the rules in which this personality plays
include(NB_RULESETS + "standard.js");
include(NB_COMMON + "standard_build_order.js");

// variables defining the personality
var subpersonalities = {
R: {
chatalias: "r",
weaponPaths: [ // weapons to use; put late-game paths below!
weaponStats.rockets_AT,
weaponStats.rockets_AS,
weaponStats.rockets_AA,
weaponStats.rockets_Arty,
],
earlyResearch: [ // fixed research path for the early game
"R-Sys-Engineering01",
"R-Struc-Research-Module",
"R-Wpn-Rocket05-MiniPod",
"R-Vehicle-Prop-Hover",
"R-Wpn-Rocket02-MRL",
"R-Vehicle-Body05",
"R-Vehicle-Prop-Halftracks",
"R-Wpn-Rocket-ROF01",
"R-Struc-RepairFacility",
"R-Defense-MRL",
"R-Defense-Pillbox06",
"R-Vehicle-Body11",
"R-Wpn-Rocket-ROF02",
"R-Struc-RprFac-Upgrade01",
"R-Defense-WallTower06",
],
minTanks: 5, // minimal attack force at game start
becomeHarder: 2, // how much to increase attack force every 5 minutes
maxTanks: 16, // maximum for the minTanks value (since it grows at becomeHarder rate)
minTrucks: 1, // minimal number of trucks around
minHoverTrucks: 4, // minimal number of hover trucks around
maxSensors: 1, // number of mobile sensor cars to produce
minMiscTanks: 1, // number of tanks to start harassing enemy
maxMiscTanks: 3, // number of tanks used for defense and harass
vtolness: 75, // the chance % of not making droids when adaptation mechanism chooses vtols
defensiveness: 75, // same thing for defenses; set this to 100 to enable turtle AI specific code
maxPower: 2500, // build expensive things if we have more than that
repairAt: 60, // how much % healthy should droid be to join the attack group instead of repairing
},
};

// this function describes the early build order
// you can rely on personality.chatalias for choosing different build orders for
// different subpersonalities
function buildOrder() {
// HACK: Tweak the rocket path a bit.
personality.weaponPaths[0].weapons = [
{ res: "R-Wpn-Rocket02-MRL", stat: "Rocket-MRL", weight: WEIGHT.MEDIUM }, // mra
{ res: "R-Wpn-Rocket01-LtAT", stat: "Rocket-LtA-T", weight: WEIGHT.MEDIUM }, // lancer
{ res: "R-Wpn-Rocket07-Tank-Killer", stat: "Rocket-HvyA-T", weight: WEIGHT.MEDIUM }, // tk
{ res: "R-Wpn-Missile2A-T", stat: "Missile-A-T", weight: WEIGHT.MEDIUM }, // scourge
{ res: "R-Wpn-MdArtMissile", stat: "Missile-MdArt", weight: WEIGHT.HEAVY }, // seraph
];
// Only use this build order in early game, on standard difficulty, in T1 no bases.
// Otherwise, fall back to the safe build order.
if (gameTime > 720000 || difficulty === INSANE
|| isStructureAvailable("A0ComDroidControl") || baseType !== CAMP_CLEAN)
return buildOrder_StandardFallback();
if (buildMinimum(structures.labs, 2)) return true;
if (buildMinimum(structures.factories, 1)) return true;
if (buildMinimum(structures.labs, 3)) return true;
if (buildMinimum(structures.gens, 1)) return true;
if (buildMinimumDerricks(2)) return true;
if (buildMinimum(structures.labs, 4)) return true;
if (buildMinimum(structures.hqs, 1)) return true;
return captureSomeOil();
}



////////////////////////////////////////////////////////////////////////////////////////////
// Proceed with the main code

include(NB_INCLUDES + "_main.js");
@@ -1,6 +1,6 @@
{
"AI": {
"js": "nullbot-hover.js",
"js": "nb_hover.js",
"name": "Hover AI",
"tip": "An AI specially tweaked for sea maps, based on NullBot"
}
Expand Down

0 comments on commit 11ef362

Please sign in to comment.