I am looking at and reading resources like this:
and this:
I have made a forward-searching planner using A*; but am now trying to search backwards for the efficiency gains.
Orkin specifically says
The planning example illustrated in Figure 2 consists of actions that have constant Boolean values for preconditions and effects, but it is important to point out that preconditions and effects can also represented by variables. The planner solves for these variables as it regresses from the goal. Variables add power and flexibility to the planner, as it can now satisfy more general preconditions. For instance, a Goto action with the effect of moving a character to a variable destination is far more powerful than a Goto action that moves to a constant, predetermined location.
So I'm not attempting to visualise this prior to implementing it; but I cannot work out how to solve the variables moving away from where they're needed:
KEY CURRENT GOAL
itemStockpiled false true
------------------------------------------
StockpileItem Effect: itemStockpiled true
Precond: hasItem ?itemId? **** How can I test this?
agentAtPosition ?stockPos?
itemStockpiled true true
hasItem 0 ?itemId?
agentAtPosition ??? ?stockPos?
------------------------------------------
Goto Effect: agentAtPosition ?stockPos? **** Where is this?
itemStockpiled true true
hasItem 0 ?itemId?
agentAtPosition ?stockPos? ?stockPos?
------------------------------------------
PickupItem Effect: hasItem ?itemId?
Precond: agentAtPosition ?itemPos?
itemStockpiled true true
hasItem ?itemId? ?itemId?
agentAtPosition ?stockPos? ?itemPos? **** So we need to go
back to the item from
the stockpile pos
------------------------------------------
Goto Effect: agentAtPosition ?itemPos? **** Where is this?
Precond: foundItem true
itemStockpiled true true
hasItem ?itemId? ?itemId?
agentAtPosition ?itemPos? ?itemPos?
foundItem false true
------------------------------------------
FindItem Effect: foundItem true
itemStockpiled true true
hasItem ?itemId? ?itemId?
agentAtPosition ?itemPos? ?itemPos?
foundItem true true
------------------------------------------
You'll see how in the above comments, I don't understand how I can check for things like an existance of a path, before I know where I'm finding a path too. For the item, I imaging I can have a boolean flag of "hasItem", and keep track of the itemId in a variable that isn't populated until FindItem
is successful (and then used when executing the path); but how would this work with a GoTo
action?
If I use a world-state variable "agentAtPosition" as an effect for Goto
; it will be set at two different points in the plan; meaning that subsequent actions that need "agentAtPosition" to be true will already have their preconditions met, effectively ending the planning, erroneously thinking it found a path:
KEY CURRENT GOAL
itemStockpiled false true
------------------------------------------
StockpileItem Effect: itemStockpiled true
Precond: hasItem true
agentAtPosition true
itemStockpiled true true
hasItem false true
agentAtPosition false true
------------------------------------------
Goto Effect: agentAtPosition true
itemStockpiled true true
hasItem false true
agentAtPosition true true
------------------------------------------
PickupItem Effect: hasItem true
Precond: agentAtPosition true
itemStockpiled true true
hasItem true true
agentAtPosition true true
------------------------------------------
How do I work around this?