Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Action decide(Perception perception) {
- // todo modify to improve the ReactiveAgent's decision process
- if (perception.getN() != null && !perception.getN().hasWall() && !perception.getN().hasAgent()){
- return Action.NORTH;
- }
- if (perception.getW() != null && !perception.getW().hasWall() && !perception.getW().hasAgent()){
- return Action.WEST;
- }
- if (perception.getS() != null && !perception.getS().hasWall() && !perception.getS().hasAgent()){
- return Action.SOUTH;
- }
- if (perception.getE() != null && !perception.getE().hasWall() && !perception.getE().hasAgent()){
- return Action.EAST;
- }
- return Action.WEST; // life is peaceful there :-)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement