Robot Rumble ALPHA
discord
try it!
boards
tutorial
docs
login
/
signup
function robot(state, unit) { console.log("Bum bum bum buuuum!"); enemies = state.objsByTeam(state.otherTeam) closestEnemy = _.minBy(enemies, e => e.coords.distanceTo(unit.coords) + e.health/10 ) direction = unit.coords.directionTo(closestEnemy.coords); if(unit.coords.distanceTo(closestEnemy.coords) < 3) { let closeGuys=0; for(let i=-2;i<3;i++){ for(let j=-2;j<3;j++){ let obj=state.objByCoords(new Coords(closestEnemy.coords.y+i,closestEnemy.coords.x+j)); if(obj&&obj.team==unit.team){ closeGuys++; } } } if(closeGuys<2){ return Action.move(direction.opposite); } if(unit.coords.distanceTo(closestEnemy.coords) === 1) { return Action.attack(direction); } else { return Action.move(direction); } } let to = unit.coords.directionTo(new Coords(10,10)); let inward = state.objByCoords(new Coords(unit.coords.y+to.toCoords.y,unit.coords.x+to.toCoords.x)); if(!state.objByCoords(new Coords(unit.coords.y+to.opposite.toCoords.y,unit.coords.x+to.opposite.toCoords.x))){ return Action.move(unit.coords.directionTo(new Coords(10,10)).opposite); } if(!inward){ return Action.attack(to); } console.log("do nothing"); return null; }
Made with <3 by Anton and Noa
github org