23.08.2015 Views

Here - Agents Lab - University of Nottingham

Here - Agents Lab - University of Nottingham

Here - Agents Lab - University of Nottingham

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

1 init module {2 knowledge{3 block(X) :- on(X,_).4 clear(X) :- block(X), not( on(_,X)).5 clear(table).6 }7 actionspec{8 move(X,Y) {9 pre{ clear(X), clear(Y), on(X,Z), not(on(X,Y)) }10 post{ not(on(X,Z)), on(X,Y) }11 }12 }13 goals{ on(b1,table), on(b2,b1), on(b3,b2), on(b4,b3). }14 beliefs{}15 }16 event module { program {17 forall bel(percept(on(X,Y)), not(on(X,Y))) do insert(on(X,Y)).18 forall bel(on(X,Y), not(percept(on(X,Y)))) do delete(on(X,Y)).19 }}20 main module { program[order=random] {21 if bel(true) then move(X,Y).22 }}Fig. 1: A simple Goal agent for solving the Blocks World problemas the desired configuration. The task for the agent is to move blocks aroundone at a time until the final configuration is realised.The program processes percepts and randomly selects an action that is enabledin the Blocks World environment. The init module consists <strong>of</strong> code toinitialize the mental state <strong>of</strong> the agent and a single action specification for themove(X,Y) action that the agent can perform in the Blocks World. The Prologrules in the knowledge section <strong>of</strong> this module define the concepts <strong>of</strong> a blockand a block being clear. An initial goal is specified in the goals section. Initiallythe agent has no beliefs; the agent must first perceive the environment toobtain information about the blocks’ configuration. The event module is executedat the start <strong>of</strong> each decision or reasoning cycle <strong>of</strong> an agent. Its purposeis to process received percepts (and messages). The two forall rules part <strong>of</strong>this module process the percepts received at the start <strong>of</strong> the cycle <strong>of</strong> the formpercept(on(X,Y)). The first rule checks whether the agent sees that a block Xis on top <strong>of</strong> a block Y and inserts this fact if the agent does not currently believeit; the second rule removes facts that are believed but not perceived (assumingfull observability this is a sound rule).The main module consists <strong>of</strong> the decision logic for acting in the environmentand selects actions after the mental state has been updated with the most recentperceptual information. The option order=random associated with the program154

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!