Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use robot as knowledge.
- module robotEvent {
- % Update the agent's state of movement.
- forall percept(state(NewState)), bel(state(State), State \= NewState)
- do delete(state(State)) + insert(state(NewState)).
- % Record when we are entering or leaving a room.
- if bel(in(Place)), not(percept(in(Place))) then delete(in(Place)).
- if percept(in(Place)), not(bel(in(Place))) then insert(in(Place)) + insert(visited(Place)).
- % Exercise 2.1b: insert rules for handling percepts other than "sendonce" percepts.
- % Record when we are entering or leaving a place (Halls included).
- forall bel(at(OldPlace)), percept(at(NewPlace)) do delete(at(OldPlace)) + insert(at(NewPlace)).
- %record sequence index change
- forall bel(sequenceIndex(OldInd)), percept(sequenceIndex(NewInd)) do delete(sequenceIndex(OldInd)) + insert(sequenceIndex(NewInd)).
- % Record when we are in- and out of range of picking up the block.
- forall percept(atBlock(BlockId)), not(bel(atBlock(BlockId))) do insert(atBlock(BlockId)).
- forall bel(atBlock(BlockId)), not(percept(atBlock(BlockId))) do delete(atBlock(BlockId)).
- % Record when we are holding or not holding the block.
- forall percept(holding(BlockId)), not(bel(holding(BlockId))) do insert(holding(BlockId)).
- forall bel(holding(BlockId)), not(percept(holding(BlockId))) do delete(holding(BlockId)).
- forall percept(color(BlockId, ColorID)), not(bel(color(BlockId, ColorID))) do insert(color(BlockId, ColorID)).
- forall bel(color(BlockId, ColorID)), not(percept(color(BlockId, ColorID))) do delete(color(BlockId, ColorID)).
- % Exercise 2.5b: insert code for goal management that allows an agent to systematically search for blocks. (if needed)
- 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.
- 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.
- % Visit unvisited rooms when there are no in(Room) goals.
- if not(goal(in(_))), not(bel(visited(Room))) then adopt(in(Room)).
- % Exercise 2.6b: insert code for goal management that makes the agent deliver a block when it
- % knows about a block that can be delivered. (if needed)
- 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.
- 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.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement