Class QLR3new

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--interfaces.Controller
              |
              +--QLR3new
All Implemented Interfaces:
java.lang.Runnable

public class QLR3new
extends Controller


Fields inherited from class interfaces.Controller
SENSOR_TYPE_LIGHT, SENSOR_TYPE_TOUCH
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
QLR3new()
           
 
Method Summary
 void begin()
          Sets the system going
 AbstractRobot getRobot()
          Returns the AbstractRobot associated with this controller
 int[] getSensors()
          Returns an array of the sensors used by this controller, and the type of sensor required.
 void halt()
          Stops this controller's thread running, i.e.
 void initController(AbstractRobot r)
          Methods required by Controller
 void initTable()
          Initialises the Q-table entries to 0.0
 void pause()
           
 int Q(int STATE)
          The main Q(s,a) function
 int rand(int limit)
          Generates a random number between 0 and the limit
 void run()
          Starts this controller's thread running.
 void unpause()
           
 void updateTable()
          Updates the utility table according to the Q learning equation
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QLR3new

public QLR3new()
Method Detail

initController

public void initController(AbstractRobot r)
Methods required by Controller
Overrides:
initController in class Controller
Following copied from class: interfaces.Controller
Parameters:
r - the AbstractRobot associated with this controller

getSensors

public int[] getSensors()
Description copied from class: Controller
Returns an array of the sensors used by this controller, and the type of sensor required. This type must be one of the sensor type constants declared above. The index of the array is used to establish which sensor is being defined. e.g. if array[0] is SENSOR_TYPE_TOUCH then sensor 1 will be set to a touch sensor. The sensors array *must* be initialised with the correct values from the outset, and must not be set in initController(), or any other method. (see example Controllers for working examples)
Overrides:
getSensors in class Controller
Following copied from class: interfaces.Controller
Returns:
the sensor array

run

public void run()
Description copied from class: Controller
Starts this controller's thread running. The 'real' controller functionality should be started from here.
Overrides:
run in class Controller

halt

public void halt()
Description copied from class: Controller
Stops this controller's thread running, i.e. must allow run() to return as quickly as possible. However it is acceptable for this method to do some housekeeping before stopping the controller, e.g. save some internal data strcuture to a file.
Overrides:
halt in class Controller

getRobot

public AbstractRobot getRobot()
Description copied from class: Controller
Returns the AbstractRobot associated with this controller
Overrides:
getRobot in class Controller
Following copied from class: interfaces.Controller
Returns:
the AbstractRobot

rand

public int rand(int limit)
Generates a random number between 0 and the limit
Parameters:
limit -  
Returns:
the random number as an int

initTable

public void initTable()
Initialises the Q-table entries to 0.0

updateTable

public void updateTable()
Updates the utility table according to the Q learning equation

Q

public int Q(int STATE)
The main Q(s,a) function
Returns:
the current best action to perform (as an int)

begin

public void begin()
Sets the system going

pause

public void pause()
Overrides:
pause in class Controller

unpause

public void unpause()
Overrides:
unpause in class Controller