I'm writing a village simulator where virtual people live their virtual lives. Eat, sleep, hunt, gather resources, etc. I'd like to use a goal-oriented action planner to give some brains to my sims, so they could think ahead and plan their actions.
I wrote a planner that uses boolean values to represent the world states, and uses regressive search to form the plans. The rules it uses look like these
rule 1: "go to the forest"
condition: "the sim's location != the forest"
effect: "the sim's location := the forest"
rule 2: "get wood"
conditions: "the sim's location == any forest", "the sim has no wood"
effects: "the sim has wood"
rule 3: "craft fishing rod"
conditions: "the sim has wood"
effects: "the sim has no wood", "the sim has a fishing rod"
rule 4: "go to the lake"
conditions: "the sim's location != the lake"
effects: "the sim's location := the lake"
rule 5: "get water"
conditions: "the sim's location == any lake", 'the sim has no water"
effects: "the sim has water"
rule 6: "get fish"
conditions: "the sim's location == any lake", "the sim has a fishing rod", "the sim has no fish"
effects: "the sim has a fish"
etc
If I give a sim a goal "to have some water", he goes to a nearest lake and takes some water. If a give him a goal "there's a fish in the forest", he goes to a nearest forest, takes a piece of wood, crafts a fishing rod, goes to a nearest lake, catches a fish, goes to the forest that I specified in the goal, and drops the fish there. Works excellent!
But I have no idea how to modify the planner the way it could work with integer values. What if I want a sim to be able to have one, two or more pieces of wood?
Let's make a rule
rule "get an extra piece of wood"
conditions: "the sim's location == any forest", "there's a room in the sim's inventory"
effects "increment amount of wood in the sim's inventory", "decrement amount of wood in the forest"
then set amount of wood in the sim's inventory to zero, and set a goal "the sim has two pieces of wood".
The planner looks for a rule that has an effect "has two pieces of wood" (since it is our goal and the first condition to satisfy), and founds nothing. The rule we've made would fit only if the sim already had one piece of wood, but he doesn't.