Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package rescueagents;
- import rescueframework.AbstractRobotControl;
- import world.Path;
- import world.Robot;
- import world.RobotPercepcion;
- /**
- * RobotControl class to implement custom robot control strategies
- */
- public class RobotControl extends AbstractRobotControl{
- /**
- * Default constructor saving world robot object and percepcion
- *
- * @param robot The robot object in the world
- * @param percepcion Percepcion of all robots
- */
- public RobotControl(Robot robot, RobotPercepcion percepcion) {
- super(robot, percepcion);
- }
- /**
- * Custom step strategy of the robot, implement your robot control here!
- *
- * @return Return NULL for staying in place, 0 = step up, 1 = step right,
- * 2 = step down, 3 = step left
- */
- public Integer step() {
- Path utvonalSerulthoz = percepcion.getShortestInjuredPath(robot.getLocation());
- if (utvonalSerulthoz != null) {
- if(robot.hasInjured()) {
- return percepcion.getShortestExitPath(robot.getLocation()).getFirstCell().directionFrom(robot.getLocation());
- } else {
- Path felfedezoUtSerult = percepcion.getShortestInjuredPath(robot.getLocation());
- return felfedezoUtSerult.getFirstCell().directionFrom(robot.getLocation());
- }
- } else {
- Path path = percepcion.getShortestUnknownPath(robot.getLocation());
- if (path != null) {
- return path.getFirstCell().directionFrom(robot.getLocation());
- } else {
- return percepcion.getShortestExitPath(robot.getLocation()).getFirstCell().directionFrom(robot.getLocation());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement