CS3361 Spring 1996
Introduction to Artificial Intelligence
Lecture Notes for Search: 3/29/96, 4/1/96
A:
Accessing audio links
V:
Accessing video links
A
V
8 puzzle demo (11:00:00)
A
V
3/29/96 lecture starts (11:05:55)
A
V
8 puzzle program demo (4/1/96 11:00:00)
A
V
4/1/96 lecture starts (4/1/96 11:01:53)
Assignment 2
Due Friday April 5, 1996 at 11am.
See
CS2360 Fall 95: Assignment 5
See also
CS2360 Fall 95: Assignment 5 update
And see
CS2360 Fall 95: Coding guidelines
Readings (useful for assignment):
Relevant stuff in previous courses:
Example solutions from http://www.gamelan.com/
(some with example code, be sure to credit these
authors if you base your solution on their code). Java Applets can
be run in some versions of Netscape 2.0.
-
Eight Puzzle Solver Applet (Java applet)
This applet animates the A* search method for solving the Eight Puzzle,
dynamically displaying the search tree as it is built.
(Note that it has some problems
running on platforms that are not pre-emptive.)
Author: Chris Waterson (waterson@eecs.umich.edu)
Source Code Included
Supports API: Beta
Entered: 24-Feb-96
-
EightPuzzle (Java applet)
Solves the 8-puzzle using the A* algorithm. The A* is implemented as a general
library.
Author: Geert-Jan van Opdorp (geert@aie.nl)
Source Code Included
Supports API: Beta
Entered: 16-Feb-96
More 8 puzzle programs and related materials:
A C example (K&R C)
Elements of Search Problems:
- States/Situations
- Actions/Operators
- Opponent Models
States/Situations
In puzzles the state of the puzzle is usually easy to
define. In real life things are more subtle, but we
will get to that later.
Actions/Operators
In each state there are a set of
actions that could be taken.
These actions can be described in a
number of ways. For example, in
the 8-puzzle:
- We could indicate a square to move and a direction to move it.
8 squares X 4 directions = 32 actions/state.
- We don't need to consider blocked squares.
- Actually the direction to move is forced, so ignore that too.
- In fact, it is useful to think about moving the hole:
- Hole in center -> 4 actions.
- Hole in corner -> 2 actions.
- Otherwise, hole on edge -> 3 actions.
Opponent Models
In the 8-puzzle and in most puzzles
there is no opponent and nothing happens
unless the searcher takes an action,
so opponent models are not an issue.
Possible ways to do the assignment:
Random Search:
-
Choose a legal move randomly, and keep moving until the puzzle is solved.
-
This means you need to generate legal moves (hopefully all of them).
-
You need to be able to detect when the puzzle is solved.
-
You need to be able to make moves (actually you are simulating moves).
Exhaustive Search (Breadth First):
-
Build a tree of possible moves,
-
adding a new move to each leaf of the tree
on each cycle.
-
The search is terminated the first time a leaf contains a solved state.
-
How would you represent the search tree?
Heuristic Search I:
-
Invent/learn an evaluation function that ranks moves:
f(current_state, move) -> goodness
-
Search, considering on each step the N best moves.
-
So, what is goodness?
(An estimate of steps to go?)
Heuristic Search II:
-
Invent/learn an evaluation function that ranks states:
f(state) -> goodness
-
Search, considering on each step the moves which lead to the N best next
states.
Heuristic Search III:
-
Invent/learn an evaluation function that ranks states:
f(state) -> goodness
-
Search ahead D steps,
considering on each step the moves which lead to the N best next
states.
-
Make a single move.
-
Goto 2
Use a Database of "End Games"
-
As you are doing any of the above methods, build a database
of states and the number of steps to solution.
-
Whenever you are evaluating a state, if it is in the database,
use that value instead of any evaluation function.