Skip to content

Instantly share code, notes, and snippets.

@tantalor tantalor/counters.js
Created Feb 15, 2011

Embed
What would you like to do?
Starcraft 2 counters for basic units (node)
var
ZERGLING = 'Zergling',
ROACH = 'Roach',
HYDRALISK = 'Hydralisk',
BANELING = 'Baneling',
MARINE = 'Marine',
HELLION = 'Hellion',
MARAUDER = 'Marauder',
REAPER = 'Reaper',
TANK = 'Siege Tank',
ZEALOT = 'Zealot',
SENTRY = 'Sentry',
STALKER = 'Stalker',
IMMORTAL = 'Immortal';
var
ZERG = 'Zerg',
TERRAN = 'Terran',
PROTOSS = 'Protoss';
var UNITS = new Object();
UNITS[ZERG] = [ZERGLING, ROACH, HYDRALISK, BANELING];
UNITS[TERRAN] = [MARINE, HELLION, MARAUDER, REAPER, TANK];
UNITS[PROTOSS] = [ZEALOT, SENTRY, STALKER, IMMORTAL];
var
ARMORED = [ROACH, STALKER, MARAUDER, IMMORTAL, TANK],
LIGHT = [MARINE, HELLION, ZEALOT, HYDRALISK, ZERGLING, REAPER, SENTRY];
var BONUS = new Object();
BONUS[STALKER] = ARMORED;
BONUS[MARAUDER] = ARMORED;
BONUS[IMMORTAL] = ARMORED;
BONUS[TANK] = ARMORED;
BONUS[BANELING] = LIGHT;
BONUS[HELLION] = LIGHT;
BONUS[REAPER] = LIGHT;
var COUNTER = new Object();
COUNTER[ZERGLING] = [STALKER, MARAUDER, HYDRALISK, IMMORTAL, SENTRY],
COUNTER[ROACH] = [ZEALOT, BANELING, HELLION],
COUNTER[HYDRALISK] = [],
COUNTER[BANELING] = [ZERGLING, MARINE, ZEALOT],
COUNTER[MARINE] = [MARAUDER, HYDRALISK, IMMORTAL],
COUNTER[HELLION] = [ZEALOT, ZERGLING, SENTRY],
COUNTER[MARAUDER] = [HELLION, ROACH, STALKER],
COUNTER[REAPER] = [ZEALOT, ZERGLING],
COUNTER[TANK] = [MARINE, HYDRALISK, ZERGLING, REAPER],
COUNTER[ZEALOT] = [MARAUDER, IMMORTAL, HYDRALISK],
COUNTER[STALKER] = [REAPER, HELLION, SENTRY],
COUNTER[SENTRY] = [],
COUNTER[IMMORTAL] = [STALKER, ROACH, TANK]
function weak_against (u) {
var units = [];
for (var v in COUNTER) {
if (COUNTER[v].contains(u)) {
units.push(v);
}
}
for (var v in BONUS) {
if (u === v) continue;
if (!BONUS[v].contains(u)) continue; // v must have bonus vs unit
if (u in BONUS && BONUS[u].contains(v)) continue; // unit must not have bonus vs v
if (COUNTER[u].contains(v)) continue; // unit must not counter v
if (!units.contains(v)) {
units.push(v);
}
}
return units.sort();
}
function strong_against (u) {
var units = COUNTER[u].concat();
if (u in BONUS) {
for (var i = 0; i < BONUS[u].length; i++) {
var v = BONUS[u][i];
if (u === v) continue;
if (COUNTER[v].contains(u)) continue; // v must not counter unit
if (v in BONUS && BONUS[v].contains(u)) continue; // v must not have bonus vs unit
if (!units.contains(v)) {
units.push(v);
}
}
}
return units.sort();
}
function describe (u) {
var d = [];
if (ARMORED.contains(u)) {
d.push('armored');
}
if (LIGHT.contains(u)) {
d.push('light');
}
if (BONUS[u] === ARMORED) {
d.push('bonus vs armored');
}
if (BONUS[u] === LIGHT) {
d.push('bonus vs light');
}
return d;
}
Array.prototype.contains = function (o) {
return this.indexOf(o) >= 0;
}
var sys = require('sys');
var print = function (s) { sys.print(s+"\n") };
for (var race in UNITS) {
print("# "+race);
for (var i = 0; i < UNITS[race].length; i++) {
var unit = UNITS[race][i];
var desc = describe(unit);
print("## "+unit+(desc?" ("+desc.join(', ')+")":""));
print(" * strong against: "+(strong_against(unit).map(function (u) {return u+(unit in BONUS && BONUS[unit].contains(u)?' (bonus)':'');}).join(', ')||"None"));
print(" * weak against: "+(weak_against(unit).map(function (u) {return u+(u in BONUS && BONUS[u].contains(unit)?' (bonus)':'');}).join(', ')||"None"));
print("");
}
}

Zerg

Zergling (light)

  • strong against: Hydralisk, Immortal, Marauder, Sentry, Stalker
  • weak against: Baneling (bonus), Hellion (bonus), Reaper (bonus), Siege Tank

Roach (armored)

  • strong against: Baneling, Hellion, Zealot
  • weak against: Immortal (bonus), Marauder (bonus), Siege Tank (bonus), Stalker (bonus)

Hydralisk (light)

  • strong against: None
  • weak against: Baneling (bonus), Hellion (bonus), Marine, Reaper (bonus), Siege Tank, Zealot, Zergling

Baneling (bonus vs light)

  • strong against: Hellion (bonus), Hydralisk (bonus), Marine (bonus), Reaper (bonus), Sentry (bonus), Zealot (bonus), Zergling (bonus)
  • weak against: Roach

Terran

Marine (light)

  • strong against: Hydralisk, Immortal, Marauder
  • weak against: Baneling (bonus), Hellion (bonus), Reaper (bonus), Siege Tank

Hellion (light, bonus vs light)

  • strong against: Hydralisk (bonus), Marine (bonus), Sentry (bonus), Zealot (bonus), Zergling (bonus)
  • weak against: Baneling (bonus), Marauder, Roach, Stalker

Marauder (armored, bonus vs armored)

  • strong against: Hellion, Roach (bonus), Stalker (bonus)
  • weak against: Marine, Zealot, Zergling

Reaper (light, bonus vs light)

  • strong against: Hydralisk (bonus), Marine (bonus), Sentry (bonus), Zealot (bonus), Zergling (bonus)
  • weak against: Baneling (bonus), Siege Tank, Stalker

Siege Tank (armored, bonus vs armored)

  • strong against: Hydralisk, Marine, Reaper, Roach (bonus), Zergling
  • weak against: Immortal (bonus)

Protoss

Zealot (light)

  • strong against: Hydralisk, Immortal, Marauder
  • weak against: Baneling (bonus), Hellion (bonus), Reaper (bonus), Roach

Sentry (light)

  • strong against: None
  • weak against: Baneling (bonus), Hellion (bonus), Reaper (bonus), Stalker, Zergling

Stalker (armored, bonus vs armored)

  • strong against: Hellion, Reaper, Roach (bonus), Sentry
  • weak against: Immortal (bonus), Marauder (bonus), Zergling

Immortal (armored, bonus vs armored)

  • strong against: Roach (bonus), Siege Tank (bonus), Stalker (bonus)
  • weak against: Marine, Zealot, Zergling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.