Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. package rescueagents;
  2.  
  3. import rescueframework.AbstractRobotControl;
  4. import world.Path;
  5. import world.Robot;
  6. import world.RobotPercepcion;
  7.  
  8. /**
  9. * RobotControl class to implement custom robot control strategies
  10. */
  11. public class RobotControl extends AbstractRobotControl{
  12. /**
  13. * Default constructor saving world robot object and percepcion
  14. *
  15. * @param robot The robot object in the world
  16. * @param percepcion Percepcion of all robots
  17. */
  18. public RobotControl(Robot robot, RobotPercepcion percepcion) {
  19. super(robot, percepcion);
  20. }
  21.  
  22.  
  23. /**
  24. * Custom step strategy of the robot, implement your robot control here!
  25. *
  26. * @return Return NULL for staying in place, 0 = step up, 1 = step right,
  27. * 2 = step down, 3 = step left
  28. */
  29. public Integer step() {
  30. Path utvonalSerulthoz = percepcion.getShortestInjuredPath(robot.getLocation());
  31. if (utvonalSerulthoz != null) {
  32. if(robot.hasInjured()) {
  33. return percepcion.getShortestExitPath(robot.getLocation()).getFirstCell().directionFrom(robot.getLocation());
  34. } else {
  35. Path felfedezoUtSerult = percepcion.getShortestInjuredPath(robot.getLocation());
  36. return felfedezoUtSerult.getFirstCell().directionFrom(robot.getLocation());
  37. }
  38.  
  39. } else {
  40. Path path = percepcion.getShortestUnknownPath(robot.getLocation());
  41. if (path != null) {
  42. return path.getFirstCell().directionFrom(robot.getLocation());
  43. } else {
  44. return percepcion.getShortestExitPath(robot.getLocation()).getFirstCell().directionFrom(robot.getLocation());
  45. }
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement