alchemist-interfaces / it.unibo.alchemist.model.interfaces / Environment2DWithObstacles

Environment2DWithObstacles

interface Environment2DWithObstacles<W : Obstacle2D!, T : Any!, P : Position<out P>!> : Environment<T, P>

Functions

addObstacle

Adds an Obstacle2D to this environment.

abstract fun addObstacle(o: W): Unit

getObstacles

abstract fun getObstacles(): MutableList<W>!

getObstaclesInRange

Given a point and a range, retrieves all the obstacles within.

abstract fun getObstaclesInRange(centerx: Double, centery: Double, range: Double): MutableList<W>!

hasMobileObstacles

abstract fun hasMobileObstacles(): Boolean

intersectsObstacle

Checks whether there is at least an obstacle intersecting the line connecting [sx, sy] and [ex, ey].

abstract fun intersectsObstacle(sx: Double, sy: Double, ex: Double, ey: Double): Boolean

Checks whether there is at least an obstacle intersecting the line connecting p1 and p2.

abstract fun intersectsObstacle(p1: P, p2: P): Boolean

next

This method must calculate the RELATIVE next allowed position given the current position and the position in which the node wants to move. For example, if your node is in position [2,3], wants to move to [3,4] but the next allowed position (because, e.g., of physical obstacles) is [2.5,3.5], the result must be a Position containing coordinates [0.5,0.5], so it's the relative movement considering the starting position as origin.

abstract fun next(ox: Double, oy: Double, nx: Double, ny: Double): P

removeObstacle

Removes an Obstacle2D from this environment.

abstract fun removeObstacle(o: W): Boolean