com.anji.floatingeye
Class FloatingEye

java.lang.Object
  extended by com.anji.floatingeye.FloatingEye
All Implemented Interfaces:
XmlPersistable

public class FloatingEye
extends java.lang.Object
implements XmlPersistable

TODO - non square surface & non square eyes Implements a floating eye that integrates with an AnjiNet ANN. Foating eye manages a 2-d matrix of short values known as a "surface" (this could be a graphical image or a game board), the loaction of the eye in x,y,z coordinates. x,y are the location on the surface, z is the location above or below the surface. An "eye image" is managed - a 2-d matrix of short values corresponding to pixels in the eye. The zoom factor of the eye is determined by the z value. At z=0, each pixel of the eye corresponds to a single space on the surface. At z=1 each eye pixel can see a maxBlurFactor by maxBlurFactor square. The eye image is centered on the x,y coordinates (off center by 1/2 pixel if the eye is at a zoom factor where the visual field spans an even number spaces).

Author:
Philip Tucker

Constructor Summary
FloatingEye(java.lang.String aName, java.util.List controlNeurons, Surface aSurface, int anEyeDim, EyeMovementParms someMovementParms)
          A floating eye is a 2-d window of inputs to a neural net that can zoom in and out relative to a 2-d surface.
 
Method Summary
 double getEyeDirectionRadians()
           
 java.awt.Image getEyeImage()
           
 FloatingLocation getEyeLocation()
           
 int getEyePixel(int x, int y)
           
 int getHeight()
           
 int getStepNum()
           
 IntLocation2D getSurfaceLocation()
          translates eye location values from representation range (-1.0 ...
 int getWidth()
           
 java.lang.String getXmld()
           
 java.lang.String getXmlRootTag()
           
 double getZoom()
           
 void reset()
          reset neural net and state of eye
 void step()
          load eye, step network, and update position from network output
 void step(int count)
           
 java.lang.String toString()
           
 java.lang.String toXml()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FloatingEye

public FloatingEye(java.lang.String aName,
                   java.util.List controlNeurons,
                   Surface aSurface,
                   int anEyeDim,
                   EyeMovementParms someMovementParms)
A floating eye is a 2-d window of inputs to a neural net that can zoom in and out relative to a 2-d surface. Assumes first 3 inputs to net are x,y,z coordinates, and first 5 outputs are move X, move Y, move Z, rotate, and affinity (i.e., how much the network "likes" the current position over which it is centered). All other inputs correspond to the inputs to the eye, a 2-d metrix squashed into a 1-d array. AnjiNet is not thread safe, so the caller should not access AnjiNet after passing it to FloatingEye.

Parameters:
aName - identifying string
controlNeurons - list of neurons, must be at least 4 (x, y, z, rotate) in general, but any of them for which the corresponding maxMovePerStep parameter is 0 are not required
aSurface - 2-d matrix of ints
anEyeDim -
someMovementParms - paramaters controlling movement of eye
Method Detail

toXml

public java.lang.String toXml()
Specified by:
toXml in interface XmlPersistable
Returns:
String XML representation of object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

reset

public void reset()
reset neural net and state of eye


getZoom

public double getZoom()
Returns:
zoom factor between 0 (exclusive) and 1 (inclusive)

getWidth

public int getWidth()
Returns:
width of eye in pixels

getHeight

public int getHeight()
Returns:
height of eye in pixels

getSurfaceLocation

public IntLocation2D getSurfaceLocation()
translates eye location values from representation range (-1.0 ... 1.0 double) to surface range (0 ... width/length int)

Returns:
surface location of eye center in x,y coordinates

step

public void step(int count)
Parameters:
count - number of times to step
See Also:
step()

step

public void step()
load eye, step network, and update position from network output


getEyeLocation

public FloatingLocation getEyeLocation()
Returns:
eye location values between -1.0d and 1.0d

getEyeDirectionRadians

public double getEyeDirectionRadians()
Returns:
eye direction between -1 and 1

getEyeImage

public java.awt.Image getEyeImage()
Returns:
eye image

getStepNum

public int getStepNum()
Returns:
number of steps this eye has performed

getEyePixel

public int getEyePixel(int x,
                       int y)
Parameters:
x -
y -
Returns:
pixel value at x,y

getXmlRootTag

public java.lang.String getXmlRootTag()
Specified by:
getXmlRootTag in interface XmlPersistable
Returns:
root tag
See Also:
XmlPersistable.getXmlRootTag()

getXmld

public java.lang.String getXmld()
Specified by:
getXmld in interface XmlPersistable
Returns:
id
See Also:
XmlPersistable.getXmld()