#Red Team - BouncerBot function moveTowards(toX,toY,curX,curY){ var xDiff = toX - curX, yDiff = toY - curY; var xDir = (xDiff < 0) ? 0 : ((xDiff > 0) ? 2 : 1), yDir = (yDiff < 0) ? 0 : ((yDiff > 0) ? 2 : 1); return moves[yDir][xDir]; } function randInt(max){ return Math.ceil(Math.random() * max); } var me = 29750; var moves = [ [4,3,3], [2,0,1], [5,5,6] ]; // Directions: -1 = up/left, 1 = down/right, 0 = none if(x === 0){ moves[0] = [3,3,3]; moves[2] = [6,6,6]; } else if(x == 127){ moves[0] = [4,4,4]; moves[2] = [5,5,5]; } for(var i in eNear){ var xDiff = eNear[i].x - x, yDiff = eNear[i].y - y; if(xDiff >= -1 && xDiff <= 1 && yDiff >= -1 && yDiff <= 1){ // If the enemy is directly adjacent, attack setMsg(''); return moves[yDiff + 1][xDiff + 1]; } } if(eNear.length > 0){ // If it can't attack, move toward the enemy. return moveTowards(eNear[0].x,eNear[0].y,x,y); } var msg = getMsg(me) || '', newDir = parseInt(msg); if(msg === ''){ newDir = randInt(4) + 2; } var isEndgame = move > 512; if(x === 0 || (isEndgame && x < 16)) newDir = (msg == 4) ? 3 : 6; else if(x == 127 || (isEndgame && x > 111)) newDir = (msg == 3) ? 4 : 5; else if((!isEndgame && y < 16) || y === 0) newDir = (msg == 4) ? 5 : 6; else if((!isEndgame && y > 111) || y == 127) newDir = (msg == 5) ? 4 : 3; if(newDir != msg) setMsg(newDir.toString()); return newDir; My bot bounces from wall to wall (not exactly, so it covers different ground) looking for enemies. If it gets one in its range, it attacks, drags them toward a wall, and tries to take them out (think a bouncer at a club).