Skip to content

Instantly share code, notes, and snippets.

@sivartydrup
Last active October 29, 2018 15:45
Show Gist options
  • Save sivartydrup/4498853 to your computer and use it in GitHub Desktop.
Save sivartydrup/4498853 to your computer and use it in GitHub Desktop.
AI bot for fightcodegame.com
var Robot = function(robot) {
robot.rotateCannon(90);
};
Robot.prototype.onIdle = function(ev) {
ev.robot.clone();
ev.robot.ahead(1000);
if (ev.robot.parentId !== null) {
ev.robot.rotateCannon(3);
ev.robot.rotateCannon(30);
}
};
Robot.prototype.onScannedRobot = function(ev) {
if(ev.scannedRobot.id !== ev.robot.parentId && ev.scannedRobot.parentId !== ev.robot.id) {
ev.robot.fire(1);
if (ev.robot.parentId !== null) {
ev.robot.rotateCannon(-10);
ev.robot.rotateCannon(-10);
}
}
};
Robot.prototype.onWallCollision = function(ev) {
if (ev.robot.parentId == null) {
ev.robot.turn(ev.bearing + 90);
}
else {
ev.robot.turn(ev.bearing + 150);
}
};
Robot.prototype.onRobotCollision = function(ev) {
ev.robot.back(100);
ev.robot.turn(90);
};
Robot.prototype.onHitByBullet = function(ev) {
if (ev.robot.parentId !== null) {
ev.robot.turn(90 - ev.bulletBearing);
}
};
@TheFurryWaluigi421
Copy link

wa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment