Teabot

by Sam Fereday

JavaScript

//// Make this in pixel art. :)
/// Assumes we have a homing cupmat and teabag store (rather than image recognition at this stage)
var Bot = function(){};

// Runs at power up or just after.
Bot.prototype.awaken = function(){

	/// Logic steps
	// Check if I've got a payload of a teabag  
	// If I do, see if I can sense the homing cupmat nearby
	// If I don't, see if I can locate the teabag storage
  var destination = null;
  
  if(this.hasPayload()) {
  	destination = this.findCupMat();
  } else {
  	destination = this.findTeaStore();
  }
  
  // If you find one or the other, set a path to both, or find location from present location. Arbitrary values are fine since we'll use our current position as the base x, y and alt.
  if(destination) {
  	this.findPathToTarget(destination.x, destination.y);
  	return;
  }
  
  // If I can't find either, then indicate that neither are available and wait for a solution, disable self after 'n' minutes if nothing received
	this.enableIdleMode();

};

// Simple methods to instigate initializing where or what we're doing
Bot.prototype.enableIdleMode = function(){
	// ...
};

Bot.prototype.findCupmat = function(){
	// ...
};

Bot.prototype.findTeaStore = function(){
	// ...
};

// Dealing with picking up tea bags
Bot.prototype.pickupPayload = function(){
 // ...
};

Bot.prototype.dropPayload = function(){
 // ...
};

// Primary functions to calculate where and what we're doing in the world
Bot.prototype.observeSurroundings = function(){

	// The best way to do this would be to use a spherical radar map of the area. Depending on where the obstacles hit, we'd want to negate that on our velocity, or, basically adjust or directions. If we're completely trapped in say a box, we'll go in to idle considering there's no opening to use. That's a rare case, but if you get stuck in a shelf or something, you don't want to be screwing around and knocking shit all over the shop.
  
  // I do wonder if it would be far less performance heavy if...