Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. use robot as knowledge.
  2.  
  3. module robotEvent {
  4. % Update the agent's state of movement.
  5. forall percept(state(NewState)), bel(state(State), State \= NewState)
  6. do delete(state(State)) + insert(state(NewState)).
  7.  
  8. % Record when we are entering or leaving a room.
  9. if bel(in(Place)), not(percept(in(Place))) then delete(in(Place)).
  10. if percept(in(Place)), not(bel(in(Place))) then insert(in(Place)) + insert(visited(Place)).
  11.  
  12. % Exercise 2.1b: insert rules for handling percepts other than "sendonce" percepts.
  13. % Record when we are entering or leaving a place (Halls included).
  14. forall bel(at(OldPlace)), percept(at(NewPlace)) do delete(at(OldPlace)) + insert(at(NewPlace)).
  15.  
  16. %record sequence index change
  17. forall bel(sequenceIndex(OldInd)), percept(sequenceIndex(NewInd)) do delete(sequenceIndex(OldInd)) + insert(sequenceIndex(NewInd)).
  18.  
  19.  
  20. % Record when we are in- and out of range of picking up the block.
  21. forall percept(atBlock(BlockId)), not(bel(atBlock(BlockId))) do insert(atBlock(BlockId)).
  22. forall bel(atBlock(BlockId)), not(percept(atBlock(BlockId))) do delete(atBlock(BlockId)).
  23.  
  24. % Record when we are holding or not holding the block.
  25. forall percept(holding(BlockId)), not(bel(holding(BlockId))) do insert(holding(BlockId)).
  26. forall bel(holding(BlockId)), not(percept(holding(BlockId))) do delete(holding(BlockId)).
  27.  
  28. forall percept(color(BlockId, ColorID)), not(bel(color(BlockId, ColorID))) do insert(color(BlockId, ColorID)).
  29. forall bel(color(BlockId, ColorID)), not(percept(color(BlockId, ColorID))) do delete(color(BlockId, ColorID)).
  30. % Exercise 2.5b: insert code for goal management that allows an agent to systematically search for blocks. (if needed)
  31.  
  32. forall bel(color(Block,Color), in(Room)), not(percept(block(Block,Color,Room))) do delete(block(Block,Color,Room)). % Delete faulty information about blocks in the room.
  33. forall percept(color(Block,Color), in(Room)), not(bel(block(Block,Color,Room))) do insert(block(Block,Color,Room)). % When information about a block is gathered, update beliefs about the block. N.B. Room is tracked.
  34.  
  35. % Visit unvisited rooms when there are no in(Room) goals.
  36. if not(goal(in(_))), not(bel(visited(Room))) then adopt(in(Room)).
  37.  
  38. % Exercise 2.6b: insert code for goal management that makes the agent deliver a block when it
  39. % knows about a block that can be delivered. (if needed)
  40. if not(goal(holding(_))), not(bel(holding(Block))), bel(nextColorInSeq(Color)), bel(block(Block,Color,Room)) then adopt(holding(Block), in(Room)). % When not holding or no goal containing holding but there is still a next color, adopt goal going to the room of the block and holding it.
  41. if not(goal(in(_))), bel(holding(_)) then adopt(in('DropZone')). % Bot picks up only next color so if it is holding something, it'll be delivered to the dropzone.
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement