The short answer
AO* is a heuristic search algorithm for AND-OR graphs. It works on problems that can be broken into smaller subproblems. Some subproblems must all be solved (AND), and others offer alternatives where solving one is enough (OR). When its estimates never overestimate the remaining cost, AO* finds the cheapest way to solve the whole problem.
AO* has no opponent. It is not a game-playing method, although it searches a tree in a way that is related to the methods used in adversarial search.
AND-OR graphs
An AND-OR graph shows a problem and the ways to break it down.
- An OR node is a problem with several alternative solutions. Solving any one of them solves it.
- An AND node is a problem that splits into several subproblems. All of them must be solved.
In many textbook drawings, the arrows leaving an AND node are joined by a curved line, which helps tell AND from OR at a glance.
How AO* works
AO* keeps a solution graph, which is its current best plan, and improves it step by step:
- Estimate the cost of the top problem, using a heuristic for any part that hasn’t been explored yet.
- Follow the best plan from the top. At OR nodes, take the cheapest option. At AND nodes, take all the subproblems.
- Pick an unexplored subproblem on that plan and expand it. This means adding its options and estimating their costs.
- Recalculate costs from the expanded node back up to the top. The best plan may change.
- Repeat until the best plan has no unexplored parts left.
The cost of an AND node is the sum of its children’s costs, since all of them must be done. The cost of an OR node is the smallest of its children’s costs, since only one needs to be done.
A heuristic is an estimate of the remaining cost from a node. If it never overestimates, it is called admissible. Under the usual assumptions, such as positive costs and no loops in the graph, AO* then finds the cheapest solution.
Worked example: getting dinner ready
Suppose the goal is to have dinner ready. There are two main options.
- Option A: order takeout. This is a single step that costs 10.
- Option B: cook pasta and make a sauce. Both parts are needed, so this is an AND node with two parts:
- Cook the pasta. This costs 2.
- Make the sauce. This is an OR node with two ways to do it:
- Buy a jar of sauce. This costs 3.
- Make the sauce from scratch. This costs 6.
AO* starts with the top goal. It hasn’t explored the sauce yet, so it uses a heuristic estimate of 2 for the sauce. That estimate is below the true cheapest cost of 3, so it never overestimates.
- First pass. Option B costs 2 for the pasta plus 2 for the sauce estimate, which is 4. Option A costs 10. Option B is the current best plan, and the sauce is the unexplored part.
- Expand the sauce. Its two options cost 3 and 6, so the sauce’s cost becomes the cheaper one, 3. Option B now costs 2 + 3, which is 5.
- Check again. Option B (5) is still cheaper than Option A (10). Every part of the best plan is now explored, so AO* stops.
The answer is to cook the pasta and buy a jar of sauce, for a total cost of 5. The estimate for the sauce rose from 2 to 3 once AO* looked at the real options, but the plan stayed the same.
This example is simplified. Real AO* implementations have more detailed rules for choosing which node to expand, and they handle larger graphs.
How AO* differs from minimax
Both methods search a tree, but they solve different kinds of problems.
- Minimax has two opponents with opposing goals. Its levels alternate between maximizing and minimizing.
- AO* has one decision-maker. Its AND and OR nodes describe how a problem breaks into parts. They don’t describe who moves next.
Someone who knows minimax might compare OR nodes to MAX nodes and AND nodes to MIN nodes. The shapes look similar, but the math differs. AO* adds up costs at AND nodes, while minimax only compares scores.
Where AO* is used
AO* suits problems that break naturally into subgoals, such as some planning tasks. It’s also a common teaching example of heuristic search on AND-OR graphs. AO* belongs to the same family as A*, and it’s one of the heuristic search methods covered in types of heuristic search in artificial intelligence.