Skip to content

Instantly share code, notes, and snippets.

@dchaplinsky
Created January 5, 2014 16:31
Show Gist options
  • Select an option

  • Save dchaplinsky/8270334 to your computer and use it in GitHub Desktop.

Select an option

Save dchaplinsky/8270334 to your computer and use it in GitHub Desktop.
/*
* This other bot is helping-- somewhat.
*/
var stop = function(self) {
self.thrusters.top(false);
self.thrusters.left(false);
self.thrusters.bottom(false);
self.thrusters.right(false);
}
this.on("start", function() {
this.thrusters.bottom(true);
});
this.on("sensor:top", function(foo) {
if (foo) {
stop(this);
this.thrusters.left(true);
this.radar.ping();
}
});
this.on("radar:hit", function(angle, distance) {
if (distance < 5) {
stop(this);
} else {
this.thrusters.left(true);
}
this.radar.ping();
});
this.on("radar:miss", function(angle, distance) {
this.thrusters.left(true);
this.radar.ping();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment