Skip to content

Instantly share code, notes, and snippets.

@whutch

whutch/cheatsheet.js

Last active Dec 9, 2015
Embed
What would you like to do?
Bot Land JS Cheat Sheet
// GLOBALS
life // bot's current life (out of 1000?)
x // bot's current x coordinate
y // bot's current y coordinate
arenaWidth
arenaHeight
sharedA
sharedB
sharedC
sharedD
sharedE
// RANDOM
percentChance(n)
randInt(start, stop) // arguments are inclusive and exclusive, respectively
// MOVEMENT & POSITIONING
if (canMove(direction)) move(direction);
if (canMoveTo(x, y)) moveTo(x, y);
if (canMoveTo(entity)) moveTo(entity);
pursue(entity); // just an alias for moveTo(entity)
if (canTeleport(x, y) teleport(x, y);
if (canTeleport(entity)) teleport(entity);
isAdjacent(x, y)
isAdjacent(entity)
getDistanceTo(x, y)
getDistanceTo(entity)
getX(entity)
getY(entity)
// SELECTION & TARGETING
findMyClosestBot()
findClosestEnemyBot()
findClosestAlliedBot()
findClosestResource()
getEntityAt(x, y)
canSense(entity)
// SUPPORT
if (canShield() && !isShielded()) shield();
if (canShield() && !isShielded(entity)) shield(entity);
if (canCloak() && !isCloaked()) cloak();
if (canReflect() && !isReflecting()) reflect();
// OFFENSE
if (willLasersHit()) fireLasers();
if (willLasersHit(entity)) fireLasers(entity);
if (willLasersHit(direction)) fireLasers(direction);
if (willMeleeHit()) melee();
if (willMeleeHit(entity)) melee(entity);
if (willMeleeHit(direction)) melee(direction);
if (willMissilesHit()) fireMissiles();
if (willMissilesHit(entity)) fireMissiles(entity);
if (willArtilleryHit()) fireArtillery();
if (willArtilleryHit(entity)) fireArtillery(entity);
if (canZap() && !isZapping()) zap();
if (canLayMine()) layMine();
if (canCharge())
// MISC
if (canActivateSensors() && !areSensorsActivated()) activateSensors();
if (willHarvest()) harvest();
revealMines();
isEnemyMineAt(x, y)
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.