CardinalEdge getHomeEdge(Entity entity) { // if I am crippled and using forced withdrawal rules, my home edge is the "retreat" edge if(entity.isCrippled(true) && getBehaviorSettings().isForcedWithdrawal()) { if(getBehaviorSettings().getRetreatEdge() == CardinalEdge.NEAREST_OR_NONE) { return BoardUtilities.getClosestEdge(entity); } else { return getBehaviorSettings().getRetreatEdge(); } } // otherwise, return the destination edge return getBehaviorSettings().getDestinationEdge(); }