70 likes | 91 Views
Chapter 4 Practical Reasoning Agents. CSE 431 – Intelligent Agents. A Blocks World Problem. initial state { On(A,Table) , On(B,Table) , On(C,Table) , Clear(A) , Clear(B) , Clear(C) , Clear(Table) , Block(A) , Block(B) , Block(C) } goal state
E N D
Chapter 4Practical Reasoning Agents CSE 431 – Intelligent Agents
A Blocks World Problem • initial state • { On(A,Table) , On(B,Table) , On(C,Table) , Clear(A) , Clear(B) , Clear(C) , Clear(Table) , Block(A) , Block(B) , Block(C) } • goal state • { On(C,Table) , On(B,C) , On(A,B) } • actions • Move(b,x,y) Pre: { On(b,x) , Clear(b) , Clear(y) , Block(y) } Del: { On(b,x) , Clear(y) } Add: { On(b,y) , Clear(x) }MoveToTable(b,x) Pre: { On(b,x) , Clear(b) } Del: { On(b,x) } Add: { On(b,Table) , Clear(x) }
Key BDI Functions Percepts action B D I options filter brf
Practical Reasoning Agent B B0;I I0;while true do get next percept p through see() function; B brf(B, p)D options(B,I); I filter(B,D,I); plan(B,I,Ac); while not (empty() or succeeded(I,B) or impossible(I,B)) do hd(); execute(); tail(); get next percept p through see() function; B brf(B, p); if reconsider(I,B) then D options(B,I); I filter(B,D,I); end-if if not sound(,I,B) then plan(B,I,Ac) end-if end-whileend-while From Fig. 4.3, p. 75
Blocks World in Jam (1) GOALS: ACHIEVE blocks_stacked; FACTS: FACT ON “Block5” “Block4”; FACT ON “Block4” “Block3”; FACT ON “Block1” “Block2”; FACT ON “Block2” “Table”; FACT ON “Block3” “Table”; FACT CLEAR “Block1”; FACT CLEAR “Block5”; FACT CLEAR “Table”; Plan: { NAME: “Top-level plan” GOAL: ACHIEVE blocks_stacked; CONTEXT: BODY: ACHIEVE ON “Block3” “Table”; ACHIEVE ON “Block2” “Block3”; ACHIEVE ON “Block1” “Block2”; }
Blocks World in Jam (2) Plan: { NAME: “Stack blocks that are already clear” GOAL: ACHIEVE ON $OBJ1 $OBJ2; CONTEXT: BODY: ACHIEVE CLEAR $OBJ1; ACHIEVE CLEAR $OBJ2; PERFORM move $OBJ1 $OBJ2; UTILITY: 10; FAILURE: EXECUTE print “\n\nStack blocks failed:\n\n”; } Plan: { NAME: “Clear a block” GOAL: ACHIEVE CLEAR $OBJ; CONTEXT: FACT ON $OBJ2 $OBJ; BODY: ACHIEVE ON $OBJ2 “Table”; EFFECTS: RETRACT ON $OBJ2 $OBJ FAILURE: EXECUTE print “\n\nClearing blocks failed:\n\n”; }