Packageorg.MARS.simulation
Classpublic final class Environment

Encapsulates all methods required to add various objects to the Simulation.

Note: Environment class is implemented as a Singleton, therefore at most one instance of this class can exist. Use Environment.getInstance() to access this instance.



Public Methods
 MethodDefined by
  
constructor
Environment
  
addDynamicObject(object:IBody, isDetectable:Boolean):void
Adds a dynamical (movable) object to the Simulation
Environment
  
addLineShape(start:Vector, end:Vector, width:Number = 10):void
Adds a line to the table's surface
Environment
  
addRobot(robot:Robot):void
Adds the robot to the Simulation
Environment
  
addTableShape(shape:Shape):void
Adds a table shape.
Environment
  
addWallShape(shape:Shape):void
Adds a wall to the Simulation
Environment
  
Checks if all of the dynamic objects, including the robot, are on the table
Environment
  
Checks if all of the dynamic objects, including the robot, are colliding with any of the walls
Environment
  
[static] Gets the instance of the singleton
Environment
  
isCollidingWithWall(shape:Shape):Boolean
Checks if the shape collides with any of the walls
Environment
  
isOnLine(shape:Shape):Boolean
Checks if the shape is on ony of the lines
Environment
  
isOnTable(shape:Shape):Boolean
Checks if the shape is on the table
Environment
  
updateRobots():void
Call the step() method of all of the robots in the Simulation
Environment
Constructor detail
Environment()constructor
public function Environment()

constructor

Method detail
addDynamicObject()method
public function addDynamicObject(object:IBody, isDetectable:Boolean):void

Adds a dynamical (movable) object to the Simulation

Parameters
object:IBody
 
isDetectable:Boolean — - wheather the object is detectable by the robot's sensors
addLineShape()method 
public function addLineShape(start:Vector, end:Vector, width:Number = 10):void

Adds a line to the table's surface

Parameters
start:Vector — - starting point of the line
 
end:Vector — - ending point of the line
 
width:Number (default = 10) — - width of the line (10 by default)
addRobot()method 
public function addRobot(robot:Robot):void

Adds the robot to the Simulation

Parameters
robot:Robot
addTableShape()method 
public function addTableShape(shape:Shape):void

Adds a table shape. All table shapes combined make up the robot's environment.

Parameters
shape:Shape
addWallShape()method 
public function addWallShape(shape:Shape):void

Adds a wall to the Simulation

Parameters
shape:Shape
checkAllOnTable()method 
public function checkAllOnTable():void

Checks if all of the dynamic objects, including the robot, are on the table

checkAllWallCollisions()method 
public function checkAllWallCollisions():void

Checks if all of the dynamic objects, including the robot, are colliding with any of the walls

getInstance()method 
public static function getInstance():Environment

Gets the instance of the singleton

Returns
Environment — Simulation instance
isCollidingWithWall()method 
public function isCollidingWithWall(shape:Shape):Boolean

Checks if the shape collides with any of the walls

Parameters
shape:Shape

Returns
Boolean — true if the shape is within or intersects one of the walls and false if the shape is outside of all of the walls.
isOnLine()method 
public function isOnLine(shape:Shape):Boolean

Checks if the shape is on ony of the lines

Parameters
shape:Shape

Returns
Boolean — true if the shape is within or intersects one of the lines and false if the shape is outside of all of the lines.
isOnTable()method 
public function isOnTable(shape:Shape):Boolean

Checks if the shape is on the table

Parameters
shape:Shape

Returns
Boolean — true if the shape is within or intersects one of the table's shapes and false if the shape is outside of the table's shapes.
updateRobots()method 
public function updateRobots():void

Call the step() method of all of the robots in the Simulation

See also

Robot.step()