/** * Create a new HandleDisaster. */ @GoalCreationCondition(rawevents=@RawEvent(value=ChangeEvent.FACTADDED, second="disasters")) public HandleDisaster(ISpaceObject disaster) { this.disaster = disaster; }
/** * */ @Belief(rawevents={@RawEvent(ChangeEvent.GOALADOPTED), @RawEvent(ChangeEvent.GOALDROPPED), @RawEvent(ChangeEvent.PARAMETERCHANGED)}) public List<Order> getOrders() { // System.out.println("getOrders belief called"); List<Order> ret = new ArrayList<Order>(); Collection<PurchaseBook> goals = agent.getComponentFeature(IBDIAgentFeature.class).getGoals(PurchaseBook.class); for(PurchaseBook goal: goals) { ret.add(goal.getOrder()); } return ret; }
/** * */ @Belief(rawevents={@RawEvent(ChangeEvent.GOALADOPTED), @RawEvent(ChangeEvent.GOALDROPPED)}) public List<Order> getOrders() { List<Order> ret = new ArrayList<Order>(); Collection<SellBook> goals = agent.getComponentFeature(IBDIAgentFeature.class).getGoals(SellBook.class); for(SellBook goal: goals) { ret.add(goal.getOrder()); } return ret; }
/** * */ // todo: support directly factadded etc. // @GoalCreationCondition(beliefs="garbages") @GoalCreationCondition(rawevents=@RawEvent(value=ChangeEvent.FACTADDED, second="garbages")) // public static Burn checkCreate(GarbageBurnerBDI outer, ISpaceObject garbage, IEvent event) public static Burn checkCreate(GarbageBurnerBDI outer, ISpaceObject garbage, ChangeEvent event) { // System.out.println("event: "+event.getType()); return garbage==null? null: new Burn(outer, garbage); }
/** * */ // Current limitation: As the target condition is checked only when plan finished the // completion of a disaster is not immediately noticed. @GoalTargetCondition(rawevents=@RawEvent(ChangeEvent.PLANFINISHED)) // Hack! todo: allow for detecting goal parameter changes public boolean checkTarget() { // System.out.println("check target of: "+this); Integer fires = (Integer)disaster.getProperty("fire"); Integer chems = (Integer)disaster.getProperty("chemicals"); Integer vics = (Integer)disaster.getProperty("victims"); return fires.intValue()==0 && chems.intValue()==0 && vics.intValue()==0; }
/** * Drop if there is another goal. */ @GoalDropCondition(rawevents={@RawEvent(ChangeEvent.GOALADOPTED), @RawEvent(ChangeEvent.GOALDROPPED)}) public boolean checkDrop(FireBrigadeBDI ag) { MovementCapa capa = ag.getMoveCapa(); boolean ret = capa.getCapability().getAgent().getComponentFeature(IBDIAgentFeature.class).getGoals().size()>1; // System.out.println("check drop fire brigade: "+this+" "+capa.getCapability().getAgent().getGoals()); return ret; }
/** * Drop if there is another goal. */ @GoalDropCondition(rawevents={@RawEvent(ChangeEvent.GOALADOPTED), @RawEvent(ChangeEvent.GOALDROPPED)}) public boolean checkDrop(AmbulanceBDI ag) { MovementCapa capa = ag.getMoveCapa(); boolean ret = capa.getCapability().getAgent().getComponentFeature(IBDIAgentFeature.class).getGoals().size()>1; // System.out.println("dropping: "+this); return ret; }
/** * */ @GoalTargetCondition(rawevents=@RawEvent(ChangeEvent.PLANFINISHED)) // Hack! todo: allow for detecting goal parameter changes public boolean checkTarget() { return ((Integer)getDisaster().getProperty("fire"))==0; } }
/** * */ @GoalTargetCondition(rawevents=@RawEvent(ChangeEvent.PLANFINISHED)) // Hack! todo: allow for detecting goal parameter changes public boolean checkTarget() { return ((Integer)getDisaster().getProperty("chemicals"))==0; }
/** * */ @GoalTargetCondition(rawevents=@RawEvent(ChangeEvent.PLANFINISHED)) // Hack! todo: allow for detecting goal parameter changes public boolean checkTarget() { return ((Integer)getDisaster().getProperty("victims"))==0; } }
/** * Drop if this goal is only option and there are others. */ @GoalDropCondition(rawevents={@RawEvent(ChangeEvent.GOALOPTION), @RawEvent(ChangeEvent.GOALADOPTED)}) public boolean checkDrop(FireBrigadeBDI ag, IGoal goal) { MovementCapa capa = ag.getMoveCapa(); boolean ret = GoalLifecycleState.OPTION.equals(goal.getLifecycleState()) && capa.getCapability().getAgent().getComponentFeature(IBDIAgentFeature.class).getGoals(ExtinguishFire.class).size()>1; // if(ret) // System.out.println("dropping ext fire: "+disaster); return ret; }
/** * Drop if this goal is only option and there are others. */ @GoalDropCondition(rawevents={@RawEvent(ChangeEvent.GOALOPTION), @RawEvent(ChangeEvent.GOALADOPTED)}) public boolean checkDrop(FireBrigadeBDI ag, IGoal goal) { MovementCapa capa = ag.getMoveCapa(); boolean ret = GoalLifecycleState.OPTION.equals(goal.getLifecycleState()) && capa.getCapability().getAgent().getComponentFeature(IBDIAgentFeature.class).getGoals(ClearChemicals.class).size()>1; // if(ret) // System.out.println("dropping clear chemicals: "+disaster); return ret; }
/** * Drop if this goal is only option and there are others. */ @GoalDropCondition(rawevents={@RawEvent(value=ChangeEvent.GOALOPTION, secondc=TreatVictims.class)}) public boolean checkDrop(AmbulanceBDI ag, IGoal goal) { MovementCapa capa = ag.getMoveCapa(); boolean ret = GoalLifecycleState.OPTION.equals(goal.getLifecycleState()) && capa.getCapability().getAgent().getComponentFeature(IBDIAgentFeature.class).getGoals(TreatVictims.class).size()>1; if(ret) System.out.println("dropping treat victim: "+disaster); return ret; } }
/** * */ // todo: support directly factadded etc. // @GoalCreationCondition(beliefs="garbages") @GoalCreationCondition(rawevents=@RawEvent(value=ChangeEvent.FACTADDED, second="garbages")) // public static boolean checkCreate(GarbageCollectorBDI outer, ISpaceObject garbage, IEvent event) public static boolean checkCreate(GarbageCollectorBDI outer, ISpaceObject garbage, ChangeEvent event) { boolean ret = outer.isDirty() && outer.getEnvironment().getSpaceObjectsByGridPosition(outer.getPosition(), "burner")==null; // if(ret) // System.out.println("collector creating new take goal for: "+garbage); return ret; }
/** * Create a new Move. */ // todo: GoHome.class.getName(); @GoalCreationCondition(rawevents={@RawEvent(ChangeEvent.GOALADOPTED), @RawEvent(ChangeEvent.GOALDROPPED)}) public static GoHome checkCreate(AmbulanceBDI ag) { MovementCapa capa = ag.getMoveCapa(); if(capa.getCapability().getAgent().getComponentFeature(IBDIAgentFeature.class).getGoals().size()==0 && capa.getHomePosition()!=null && capa.getPosition()!=null && capa.getEnvironment().getDistance(capa.getHomePosition(), capa.getPosition()).getAsDouble()>0.001) { return new GoHome(capa.getHomePosition()); } else { return null; } }
/** * Create a new Move. */ @GoalCreationCondition(rawevents=@RawEvent(ChangeEvent.GOALDROPPED)) public static GoHome checkCreate(FireBrigadeBDI ag) { MovementCapa capa = ag.getMoveCapa(); // System.out.println("check create go home: "+capa.getCapability().getAgent().getGoals().size()+" "+capa.getCapability().getAgent().getAgentName()); if(capa.getCapability().getAgent().getComponentFeature(IBDIAgentFeature.class).getGoals().size()==0 && capa.getHomePosition()!=null && capa.getPosition()!=null && capa.getEnvironment().getDistance(capa.getHomePosition(), capa.getPosition()).getAsDouble()>0.001) { return new GoHome(capa.getHomePosition()); } else { return null; } }