Here some general idea for an AI Planning procedure

Condition based AI Planner

The “world” the AI is acting in, is based on conditions for states:

State: an attainable goal, state of an entity etc
Condition: the required parameters that have to be fulfilled to do an action or have an entity at this specific state.


Example: AI for an RTS game.

Goal: have a collectorunit.
Condition: do a build of a collector


Goal: do a build of a collector
Condition: have the resources (50 wood), have a free unit slot, have an active barracks building.

Goal-1: have a free unit slot
Condition: building a free unit slot. ->fulfilled currently.
Goal-2: have the resources (50 wood),
Condition: collect resources to reach the required amount. ->fulfilled currently.
Goal-3: , have an active barracks building
Condition: build up an barracks building.

Goal: build up an barracks building
Condition: have collectorto build the building on a free field.

Goal: have collectorto build the building on a free field.
Condition: have a collector: fulfilled
Condition: have the required resources to build barracks.

Etc..


Once all conditions are met at the current state of the world, the AI can pursue the actions of the plan, to reach the goal. So each step in accessing the condition, the AI tests if all conditions are currently fulfilled (at the time of doing the planning). If all are fulfilled, the AI knows, that following the actions is possible, and will lead to the conditions required to reach the goal.
-> in a dynamic world with an opponent, fulfilling the conditions by doing actions is not always assured. The AI must value actions according to their risk, and better, to the actions the opponent does at the time of pursuing the plan.


The AI has a goal that it wants to have solved. To reach the goal it searches backwards from the goal, what conditions have to be fulfilled, and how these conditions can be fulfilled.
To reach a goal, the conditions to be fulfilled can split up in different paths. The AI should search through all the possible alternative paths.
When a condition is not yet fulfilled at the status of the path at this “time” of the path,
It must look for the goals/actions to fulfill these conditions.
These goals (or number of different goals) have conditions themselves.

The whole process calculated backwards from the final goal different paths / plans how to fulfill the conditions to progress on the path. This way the AI can indepently from predefined plans dynamically find a solution to fulfilling a goal.
The designer just needs to define the actions and conditions that are required in the world.

A certain action (going to a position an building something for example)
is yielding a certain risk. For example: impossible to very likely.
A trained AI can learn to evaluate the risk of the action giving its environment.
Building something close to enemy units is less likely to succeed (higher risk) than at the AIs base. Neural Nets or genetic algorithms can be used to train such risk-evaluation.


Once the plan to reach a goal is found, and the AI is pursuing the goal, it has to monitor if all the required conditions for each step that is currently done are still valid. In case that something changed, the AI can decide to a new search, or search for a plan to fulfill the conditions that are required right now with an additional plan.


Not every condition can be fulfilled by only one action, but by n .
This indicates, that the path of the recursive plan-search-tree is split there.
For example: conflicting a certain kind of damage can be done by many different units.
Thus the search should look up plans to use any kind of unit that can do that, and favor the units that are already available.


test-too:

preset a number of action and condition by easy to read names, and calculate paths
that are dislayed. The path are sortet for their length and a “cost” value assigned to every action.
(costs are time and resources used for example, or “fragility of the unit to attacks”)



entity -> possesses action. (requiring condition)
means that we need the entity available, and fulfilling the conditions for the entity to conflict the action

Last edited by Oxy; 07/14/08 22:17.