Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import info.gridworld.actor.*;
- import info.gridworld.grid.*;
- import java.awt.Color;
- import java.util.ArrayList;
- public class QuickCrab extends CrabCritter{
- public ArrayList<Location> getMoveLocations(){
- ArrayList<Location> locs = new ArrayList<Location>();
- Grid gr = getGrid();
- secondValid(locs,getDirection() + Location.LEFT);
- secondValid(locs,getDirection() + Location.RIGHT);
- if (locs.size() == 0)
- return super.getMoveLocations();
- return locs;
- }
- private void secondValid(ArrayList<Location> locs,int dir){
- Grid gr = getGrid();
- Location loc = getLocation();
- Location temp = loc.getAdjacentLocation(dir);
- if(gr.isValid(temp) && gr.get(temp) == null){
- Location loc2 = temp.getAdjacentLocation(dir);
- if(gr.isValid(loc2) && gr.get(loc2)== null)
- locs.add(loc2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment