|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjas.space.AbstractTurtle
jas.space.DigitalTurtle
public class DigitalTurtle
TO DO Documentation.
Title: JAS
Description: Java Agent-based Simulation library
Copyright (C) 2002 Michele Sonnessa
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
Field Summary |
---|
Fields inherited from class jas.space.AbstractTurtle |
---|
DEFALUT_COLOR, DIR_EAST, DIR_NORTH, DIR_NORTH_EAST, DIR_NORTH_WEST, DIR_SOUTH, DIR_SOUTH_EAST, DIR_SOUTH_WEST, DIR_WEST, MOVE_BOUND, MOVE_REFLECT, MOVE_TORUS |
Constructor Summary | |
---|---|
DigitalTurtle(int id,
IObjGrid grid)
Create a turtle with a given identifier on the given grid at position (0,0). |
|
DigitalTurtle(int id,
IObjGrid grid,
int x,
int y)
Create a turtle with a given identifier on the given grid at the given position. |
|
DigitalTurtle(int id,
IObjGrid grid,
int x,
int y,
java.awt.Color color)
Create a turtle with a given identifier on the given grid at the given position. |
Method Summary | |
---|---|
void |
forward(int steps)
Make some steps forward, according the current heading. |
int |
getHeading()
Return the current heading of the turtle. |
int |
getNextX(int steps)
Return the new x coordinate walking the current heading direction for given steps. |
int |
getNextY(int steps)
Return the new y coordinate walking the current heading direction for given steps. |
boolean |
leap(int steps)
Make some steps forward, but moves only if the target position is empty. |
void |
setCardinalHeading(int directionType)
Set the turtle's heading using a constant for cardinal points. |
void |
setHeading(int heading)
Set the current heading. |
void |
setRandomHeading()
Randomize the turtle's heading. |
void |
turnCardinalLeft(int steps)
|
void |
turnCardinalRight(int steps)
|
void |
turnLeft(int degrees)
Change the current heading rotating it to the left. |
void |
turnRight(int degrees)
Change the current heading rotating it to the right. |
Methods inherited from class jas.space.AbstractTurtle |
---|
forward, getColor, getDistanceFrom, getID, getMovingType, getNextX, getNextY, getWorldHeight, getWorldWidth, getX, getY, leap, setColor, setIfEmptyXY, setMovingType, setX, setXY, setY |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DigitalTurtle(int id, IObjGrid grid)
id
- The identifier for turtle.grid
- The grid upon the turtle moves.public DigitalTurtle(int id, IObjGrid grid, int x, int y)
id
- The identifier for turtle.x
- The initial x coordinate of the turtle.y
- The initial y coordinate of the turtle.grid
- The grid upon the turtle moves.public DigitalTurtle(int id, IObjGrid grid, int x, int y, java.awt.Color color)
id
- The identifier for turtle.x
- The initial x coordinate of the turtle.y
- The initial y coordinate of the turtle.color
- The initial color of the turtle.grid
- The grid upon the turtle moves.Method Detail |
---|
public void forward(int steps)
AbstractTurtle
forward
in class AbstractTurtle
steps
- The number of steps the turtle has to make.public int getHeading()
AbstractTurtle
getHeading
in class AbstractTurtle
public int getNextX(int steps)
AbstractTurtle
getNextX
in class AbstractTurtle
steps
- The number of steps to move forward.
public int getNextY(int steps)
AbstractTurtle
getNextY
in class AbstractTurtle
steps
- The number of steps to move forward.
public boolean leap(int steps)
AbstractTurtle
leap
in class AbstractTurtle
steps
- The number of steps the turtle has to make.
public void setCardinalHeading(int directionType)
AbstractTurtle
setCardinalHeading
in class AbstractTurtle
directionType
- One of DIR_NORTH, DIR_NORTH_EAST, ... constant.public void setHeading(int heading)
AbstractTurtle
setHeading
in class AbstractTurtle
heading
- The new heading.public void setRandomHeading()
AbstractTurtle
setRandomHeading
in class AbstractTurtle
public void turnCardinalLeft(int steps)
turnCardinalLeft
in class AbstractTurtle
public void turnCardinalRight(int steps)
turnCardinalRight
in class AbstractTurtle
public void turnLeft(int degrees)
AbstractTurtle
turnLeft
in class AbstractTurtle
degrees
- The number of degrees to rotate the heading.public void turnRight(int degrees)
AbstractTurtle
turnRight
in class AbstractTurtle
degrees
- The number of degrees to rotate the heading.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |