CS221: Introduction To Artificial Intelligence
CS221: Introduction To Artificial Intelligence
CS221: Introduction To Artificial Intelligence
Artificial Intelligence
http://cs221.stanford.edu/
Candy Policy
CS221 Staff
Programming (CS106)
Probability
Summertime?
Due Dates
• Due at 11:59P.M.
Exceeds requirements.
Post to Piazza
Email cs221-sum1213-
staff@lists.stanford.edu
10
Book
$78
Prime
Homework 1
12
Honor Code Rules
1952 1955
Early Optimism (1950s)
Underwhelming Results (1950 to 90s)
Model Uncertainty
Big Milestones
2005 Stanley
2011 Watson
Exciting Times!
CS221
Search
Machine
Learning
Variable
Based
Course Goals
Reason about goals: what will I get if I try this
sequence of actions?
Formal Problem
Apply an Algorithm
Evaluate Solution
Ready to dive in?
Footer Text 30
4/26/2019
Searching:
Using AI algorithms to find
solutions for you.
DNA Alignment
ATTGGGAAATGCCCCATTATTBBC
ATTGGAATCGACATATTATTBBC
DNA Alignment
CS221
Search
Machine
Learning
Variable
Based
CS221
Search
Model
Solvers
Determ. State Problems
Model
Solvers
Deterministic State Problems
No Uncertainty Discretized
Deterministic State Problems
Maze
Maze
Maze == Ghost Algorithm
Determ. State Problems
Model
Solvers
Determ. State Problems
Model
Solvers
The AI Pipeline
Formal Problem
Apply an Algorithm
Evaluate Solution
Deterministic State Space Models
State
• Position • PI (3.14)
• Direction • Price of gold
• Position of
other
Airplanes
Intuition
Intuition
http://vimeo.com/65042779
Spell Checking
Knight’s Tour
Model
Solvers
Determ. State Problems
Model
Solvers
The AI Pipeline
Formal Problem
Apply an Algorithm
Evaluate Solution
Exploration Algorithm
Start
Goal
Breadth First Search
Insight: Keep a
queue of states to
visit
Breadth First Search
queue = Queue()
queue.enqueue(startState)
visited = Set([])
while !queue.isEmpty():
currState = queue.dequeue()
if not currState in visited:
if isTerminal(currState) return currState
for nextState in getNextStates(currState)
queue.enqueue(nextState)
}
}
}
Breadth First Search
queue = Queue()
queue.enqueue(startState)
visited = Set([])
while !queue.isEmpty():
currState = queue.dequeue()
if not currState in visited:
if isTerminal(currState) return currState
for nextState in getNextStates(currState)
queue.enqueue(nextState)
}
}
}
Breadth First Search
queue = Queue()
queue.enqueue(startState)
visited = Set([])
while !queue.isEmpty():
currState = queue.dequeue()
if not currState in visited:
if isTerminal(currState) return currState
for nextState in getNextStates(currState)
queue.enqueue(nextState)
}
}
}
Breadth First Search
Front Back
Dequeue a state
Breadth First Search
Dequeue a path
Breadth First Search
queue = Queue()
queue.enqueue(startState)
visited = Set([])
while !queue.isEmpty():
currState = queue.dequeue()
if not currState in visited:
if isTerminal(currState) return currState
for nextState in getNextStates(currState)
queue.enqueue(nextState)
}
}
}
Depth First Search
stack = Stack()
stack.push(startNode)
visited = Set([])
while !stack.isEmpty():
currState = stack.pop()
if not currState in visited:
if isTerminal(currState) return currState
for nextState in getNextStates(currState)
stack.push(nextState)
}
}
}
Stack vs Queue
Stacks
LIFO
Dish metaphor
Depth First Search
Pop a path
Depth First Search
Bottom Top
Bottom Top
Pop a path
Depth First Search
Pop a path
Depth First Search
Demo
DNA Alignment
ATTGGGAAATGCCCCATTATTBBC
ATTGGAATCGACATATTATTBBC
Can We Do It?
We Broke BFS
Why AI?
Why AI?
Why AI?
Why AI?
Determ. State Problems
Model
Solvers
Computer
programs