nanomunchers.bot
Class NanoBot

java.lang.Object
  extended bynanomunchers.bot.NanoBot

public class NanoBot
extends java.lang.Object

Reprsents the humble Nanomuncher

Author:
David Kaplin

Field Summary
protected  boolean alive
           
protected  int cycle
           
static int DOWN
           
protected  int[] instructionOrder
           
static int LEFT
           
protected  Node location
           
protected  int nodesMunched
           
protected  int positionDelta
           
static int RIGHT
           
protected  Node startPosition
           
static int UP
           
 
Constructor Summary
NanoBot(java.lang.String instOrder, Node start)
          Creates a new nanomuncher.
 
Method Summary
 void clear()
          Renews the nanomuncher to its inital place and diet.
 java.lang.String getCode()
           
 Node getCurrentLocation()
           
 int getDirection()
           
 int getNodesMunched()
           
 boolean isAlive()
           
 void kill()
          Kills the nanomuncher.
 void move()
          Actually performs the move.
 Node nextMove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UP

public static final int UP
See Also:
Constant Field Values

LEFT

public static final int LEFT
See Also:
Constant Field Values

DOWN

public static final int DOWN
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values

nodesMunched

protected int nodesMunched

alive

protected boolean alive

cycle

protected int cycle

positionDelta

protected int positionDelta

instructionOrder

protected int[] instructionOrder

startPosition

protected Node startPosition

location

protected Node location
Constructor Detail

NanoBot

public NanoBot(java.lang.String instOrder,
               Node start)
Creates a new nanomuncher.

Parameters:
instOrder - "LRUD" for example
start -
Method Detail

nextMove

public Node nextMove()
Returns:
the next move disregarding other nanomunchers that the nanomuncher wants to take.

move

public void move()
Actually performs the move.


getDirection

public int getDirection()
Returns:
the nanomunchers current direction (facing its next move)

getNodesMunched

public int getNodesMunched()
Returns:
number of nodes consumed.

isAlive

public boolean isAlive()
Returns:
true if the nanomuncher is still kicking :)

kill

public void kill()
Kills the nanomuncher. Usually invoked during a conflict death


clear

public void clear()
Renews the nanomuncher to its inital place and diet.


getCurrentLocation

public Node getCurrentLocation()
Returns:
node that the nanomuncher is currently occupying

getCode

public java.lang.String getCode()
Returns:
"LRDU" for Left Right Down Up "UNKNOWN" for other combinations.