KarelWorld

public class KarelWorld(source)

Represents the FOP Bot world on a graphical user interface.

Constructors

Link copied to clipboard
public void KarelWorld(int width, int height)
Constructs and initializes a world with the specified size.

Properties

Link copied to clipboard
public long actionLimit
The maximum number of actions that can be performed in this world.
Link copied to clipboard
public int delay
The delay in milliseconds of this world.
Link copied to clipboard
The fields of this world.
Link copied to clipboard
public final int height
The height of this world.
Link copied to clipboard
public final int width
The width of this world.

Functions

Link copied to clipboard
public void addRobot(Robot robot)
Adds the specified robot to this world.
Link copied to clipboard
protected void checkNumberOfCoins(int numberOfCoins)
Validates that the number of coins is not negative.
Link copied to clipboard
protected void checkXCoordinate(int x)
Validates if the specified X coordinate is within the world.
Link copied to clipboard
protected void checkYCoordinate(int y)
Validates if the specified Y coordinate is within the world.
Link copied to clipboard
@ApiStatus.Internal()
public long getActionCount()
Returns the amount of traces stored.
Link copied to clipboard
@ApiStatus.Internal()
public long getActionLimit()
Returns the maximum amount of traces to be stored.
Link copied to clipboard
Returns all field entities on this world.
Link copied to clipboard
public int getDelay()
Returns the current delay in milliseconds of this world.
Link copied to clipboard
Returns all entity states (fields) of this world.
Link copied to clipboard
public Field getField(int x, int y)
Returns the field of this world at the specified coordinate.
Link copied to clipboard
@Nullable()
public @Nullable() Color getFieldColor(int x, int y)
Returns the color of the field at the specified coordinates or null if no color is set.
Link copied to clipboard
@ApiStatus.Internal()
public GuiPanel getGuiPanel()
Returns the GuiPanel of this world.
Link copied to clipboard
public int getHeight()
Returns the height of this world.
Link copied to clipboard
Returns the InputHandler of this world.
Link copied to clipboard
public long getRobotCount()
Returns the amount of robots in this world.
Link copied to clipboard
protected Map<String, Array<Image>> getRobotImageMap(Class<? extends Robot> robotClass)
Returns robot image map related to the specified robot class instance.
Link copied to clipboard
Returns robot image map related to the specified image identification.
Link copied to clipboard
public RobotTrace getTrace(Robot robot)
Returns the previous robot tracing of the specified robot.
Link copied to clipboard
Returns the previous robots tracing.
Link copied to clipboard
public int getWidth()
Returns the width of this world.
Link copied to clipboard
protected boolean isAnotherRobotInField(int x, int y, Robot robot)
Returns true if the specified robot is located at the specified coordinate.
Link copied to clipboard
protected boolean isBlockInField(int x, int y)
Returns true if a block is at the specified coordinate.
Link copied to clipboard
protected boolean isCoinInField(int x, int y)
Returns true if at least one coin is on the specified coordinate.
Link copied to clipboard
public boolean isDrawTurnedOffRobots()
Returns true if turned off robots are drawn.
Link copied to clipboard
public boolean isVisible()
Returns true if this world is visible on the graphical user interface.
Link copied to clipboard
protected boolean isWallInField(int x, int y, boolean horizontal)
Returns true if a wall and its orientation is on the specified field.
Link copied to clipboard
protected void loadImagesIfNotLoaded()
Load all images for displaying FoPBot if required.
Link copied to clipboard
protected boolean pickCoin(int x, int y)
Picks up a coin from the specified coordinate and return true if a coin was removed at the specified coordinate after this call.
Link copied to clipboard
public void placeBlock(int x, int y)
Places a block at the specified coordinate.
Link copied to clipboard
public void placeHorizontalWall(int x, int y)
Places a horizontal wall at the specified coordinate.
Link copied to clipboard
public void placeVerticalWall(int x, int y)
Places a vertical wall at the specified coordinate.
Link copied to clipboard
public void putCoins(int x, int y, int numberOfCoins)
Places the specified number of coins at the specified coordinate.
Link copied to clipboard
public void reset()
Resets this world by removing all entities from the fields.
Link copied to clipboard
@ApiStatus.Internal()
public void setActionLimit(long actionLimit)
Sets the maximum amount of traces to be stored.
Link copied to clipboard
public void setAndLoadRobotImages(Class<? extends Robot> robotClass, InputStream turnedOn, InputStream turnedOff, int rotationOffsetOn, int rotationOffsetOff)
Loads robot images for a specific robot class.
Link copied to clipboard
public void setAndLoadRobotImagesById(String imageId, InputStream turnedOn, InputStream turnedOff, int rotationOffsetOn, int rotationOffsetOff)
Loads robot images for a specific image identification.
Link copied to clipboard
public void setDelay(int delay)
Sets the delay that delays all robot actions after their execution.
Link copied to clipboard
public void setDrawTurnedOffRobots(boolean drawTurnedOffRobots)
Sets whether turned off robots should be drawn.
Link copied to clipboard
public void setFieldColor(int x, int y, @Nullable() @Nullable() Color color)
Sets the color of the field at the specified coordinates.
Link copied to clipboard
@ApiStatus.Internal()
public void setGuiPanel(GuiPanel guiPanel)
Sets the GuiPanel of this world.
Link copied to clipboard
public void setVisible(boolean visible)
Sets the visibility of the world on the graphical user interface to the specified visibility value.
Link copied to clipboard
protected void sleep()
Puts this world to sleep for the specified amount time given by delay (in milliseconds).
Link copied to clipboard
protected void triggerUpdate()
Triggers that an update of the graphical user interface is needed.
Link copied to clipboard
protected void updateGui()
Updates the graphical user interface window.
Link copied to clipboard
protected void updateRobotField(Robot robot, int oldX, int oldY)
Updates the entity array to be in sync with the robots X and Y coordinates.