Robot Rumble ALPHA
discord
try it!
boards
tutorial
docs
login
/
signup
function robot(state, unit) { let enemies = state.objsByTeam(state.otherTeam) let closestEnemy = _.minBy(enemies, e => e.coords.distanceTo(unit.coords) ); let direction = unit.coords.directionTo(closestEnemy.coords); let distance = unit.coords.distanceTo(closestEnemy.coords); console.log(direction.opposite); if (distance === 1 && state.objByCoords(direction.opposite.toCoords.add(unit.coords)) != null) { return Action.attack(direction); } else if (distance === 1) { return Action.move(direction.opposite); } else { return Action.move(unit.coords.directionTo(new Coords(9,9))); } }
Made with <3 by Anton and Noa
github org