- We'll start out by thinking about a simple game.
- Games aren't what intelligence was developed for.
- But they are a representation of the kinds of reasoning & competitions we do in social domains.
- Often used traditionally in AI, somewhat controversial now (more about this at the end.)
- Good intuition pumps.
- Tic-tac-toe (noughts & crosses) draw

- Initial board is empty.
- First player can choose one of 9 places to go.
- Next player can choose one of 8 places to go
- Game can't take more than 9 steps.
- Object is to get three characters in a row --- many games no one wins.
- Web pages with pictures: http://www.ics.uci.edu/~eppstein/180a/970417.html,
http://www.gamasutra.com/features/20000626/brockington_pfv.htm

- Complexity is vaguely exponential!
- Think about chess -- that's really exponential...
- Most AI problems are in NP
- Non-polynomial --- essentially computationally intractable to find (best/optimal) solution.
- But
if you do find a solution, you can prove it's correct in polynomial
time.

- This makes NP different from EXP, for example.
- Complexity class fun for the masochists: The Complexity Zoo.
- Worse class of problems is when you can't recognize when you've happened to find a solution!
- Empirically, many problems we work on seem similar
- How long would it have taken you to invent quick sort?
- How long did it take you to understand that it would work?
- The answer to question 1 might actually be shorter than you think, or sometimes even shorter than question 2, see section on expertise below.
- If a problem is polynomial or easier, can usually write a conventional algorithm to solve the problem.

- Depth first search looks all the way down a tree's branches until
it finds a solution.

- start at the root
- look for your answer
- if not found
- for each child
- depth first search
- Breadth first search looks across the tree at one depth, and then on to the next level
- breadth-first-search (list) // initially list only contains the root
- for each thing in the list
- look for the answer
- if not found
- append item's children to the end of list
- Depth first search is faster, because it doesn't store as much state. But you can't know if you have the best answer (least amount of steps) unless you look at the whole tree!
- Breadth first search guarantees the shortest answer, but is impossible in cases like chess --- requires more memory than particles in the universe.
- But depth first has another problem --- may enter an infinite loop!
- e.g. in chess -- can move a rook back & forth forever.
- This is when you need AI --- when no algorithm can solve the problem.
- Here's a picture (from Ralph
Morelli's AI Lecture notes):
Consider the following graph:

**Depth First Search**examines the nodes in the following order:A, B, E, K, S, L, T, F, M, C, G, N, H, O, P, U, D, I, Q, R, S, T, U

**Breadth First Search**examines the nodes in the following order:A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U

- Want ways to prune the
tree -- make there be less branches.

- If you are playing an opponent, assume that each player will avoid losing games, ignore those branches.
- This is called "mini-max search" because you alternately
minimize
& maximize your own expected outcome as you go through the
tree. (demo on tic-tac-toe
tree).

- Estimate the value of branches & go down the ones that look most profitable.
- Estimates are based on heuristics, rules that are often but not always right.
- E.g. you might guess that the shortest way across town on the map is the fastest, but really the fastest way depends on traffic, width of streets, tourists, shops etc.
- In chess, a common heuristic is to count how many pieces you have left, giving extra value to more powerful pieces.
- A* search is kind of like breadth first search, but you keep sorting the list, & keep going down the shortest / cheapest path you've found so far.
- A*-search (list) // initially list only contains the root
- for the cheapest thing in the list
- check if you have the solution, if so use it

- take item off list, remembering the cost associated with it,
- estimate cost of all children, summing their cost with parent's cost.
- sort children into list
- If you can guarantee that your heuristic never underestimates the
cost of performing the action (overestimating is OK) then this will
find
the optimal solution.

- A* search is used in almost all VR computer games for navigation: choosing how to get to a goal location See the Game AI Page: Pathfinding.
- Unfortunately, search is still slow if you have to search too many things, even with pruning.
- Here's a real world example showing that some problems are even harder than NP -- like Air Travel Planning.
- That shows the type of analysis people do once they notice they have hit a hard problem, so they can understand exactly how hard it is, and try to work around it.
- Actually, the point of that talk was to excite & recruit
smart PhD students. ITA software (like Google) hires lisp
programmers.

- One way to solve the problem of combinatorics is to have the search run in parallel.
- Every time you have multiple options, have one thread take each option.
- Think of people exploring tunnels in Scooby Doo.

- If you could get enough threads, & you had some way to let all of them know when one of them found a solution, then you could turn all NP problems into P problems.
- Not something you can do on one PC -- threads share the same processor, no big win.
- Even massively parallel computers usually only have 1,000 processors, don't get you that far in chess.
- Solutions people are currently working on:
- Quantum computing :
- particles can be in many places at one time
- weird! but has really been done for a small number of bits.
- Biological computing:
- use genetics to create and & or gates in bacteria.
- Takes maybe 48 hours for one operation, BUT can be done billions of times in a single test tube.
- Again, people are really working on this (for example, Ron Weiss).
- Evolution / memetics:
- If a few members of a species or a culture find a good / winning solution, the entire species or culture may eventually adopt that solution.
- This works much faster in memetics (ideas) then genetics (requires waiting for children to grow up.)
- Trying to come up with good design rules is like memetics.

- This is why sometimes programmers can chance on the right answer to a question even sooner than they can understand how to solve the question.
- Languages like java are designed to give you a heavily pruned search space.
- Using good technique makes it likely you will find good answers!
- Using very limited search of known good strategies is the key to several other kinds of AI:
- Will talk about tomorrow!

- A lot of what we do (with our brains as well as our computers) can be thought of as search.
- Games are a "toy domain", but can help us understand why search is hard, and how we might be solving other problems.
- Real brains probably solve many things in parallel, but they are still combating combinatorics.

26 April 2005