@Override public Action execute(Percept percept){
  kb.makePerceptSentence((AgentPercept)percept,t);
  kb.tellTemporalPhysicsSentences(t);
  AgentPosition current=kb.askCurrentPosition(t);
  Set<Room> safe=kb.askSafeRooms(t);
  if (kb.askGlitter(t)) {
    Set<Room> goals=new LinkedHashSet<Room>();
    goals.add(new Room(1,1));
    plan.add(new Grab());
    plan.addAll(planRoute(current,goals,safe));
    plan.add(new Climb());
  }
  Set<Room> unvisited=kb.askUnvisitedRooms(t);
  if (plan.isEmpty()) {
    plan.addAll(planRoute(current,SetOps.intersection(unvisited,safe),safe));
  }
  if (plan.isEmpty() && kb.askHaveArrow(t)) {
    Set<Room> possibleWumpus=kb.askPossibleWumpusRooms(t);
    plan.addAll(planShot(current,possibleWumpus,safe));
  }
  if (plan.isEmpty()) {
    Set<Room> notUnsafe=kb.askNotUnsafeRooms(t);
    plan.addAll(planRoute(current,SetOps.intersection(unvisited,notUnsafe),safe));
  }
  if (plan.isEmpty()) {
    Set<Room> start=new LinkedHashSet<Room>();
    start.add(new Room(1,1));
    plan.addAll(planRoute(current,start,safe));
    plan.add(new Climb());
  }
  Action action=plan.remove();
  kb.makeActionSentence(action,t);
  t=t + 1;
  return action;
}

@ Override public Action execute ( Percept percept ) { kb . makePerceptSentence ( ( AgentPercept ) percept , t ) ; kb . tellTemporalPhysicsSentences ( t ) ; AgentPosition current = kb . askCurrentPosition ( t ) ; Set < Room > safe = kb . askSafeRooms ( t ) ; if ( kb . askGlitter ( t ) ) { Set < Room > goals = new LinkedHashSet < Room > ( ) ; goals . add ( new Room ( 1 , 1 ) ) ; plan . add ( new Grab ( ) ) ; plan . addAll ( planRoute ( current , goals , safe ) ) ; plan . add ( new Climb ( ) ) ; } Set < Room > unvisited = kb . askUnvisitedRooms ( t ) ; if ( plan . isEmpty ( ) ) { plan . addAll ( planRoute ( current , SetOps . intersection ( unvisited , safe ) , safe ) ) ; } if ( plan . isEmpty ( ) && kb . askHaveArrow ( t ) ) { Set < Room > possibleWumpus = kb . askPossibleWumpusRooms ( t ) ; plan . addAll ( planShot ( current , possibleWumpus , safe ) ) ; } if ( plan . isEmpty ( ) ) { Set < Room > notUnsafe = kb . askNotUnsafeRooms ( t ) ; plan . addAll ( planRoute ( current , SetOps . intersection ( unvisited , notUnsafe ) , safe ) ) ; } if ( plan . isEmpty ( ) ) { Set < Room > start = new LinkedHashSet < Room > ( ) ; start . add ( new Room ( 1 , 1 ) ) ; plan . addAll ( planRoute ( current , start , safe ) ) ; plan . add ( new Climb ( ) ) ; } Action action = plan . remove ( ) ; kb . makeActionSentence ( action , t ) ; t = t + 1 ; return action ; }
function hybrid - wumpus - agent ( percept ) returns an action < br >
