Lec 0 | Search Flashcards
Covers a range of techniques that appear as sentient behavior by the computer
Artificial Intelligence (AI)
Finding a solution to a problem, like a navigator app that finds the best route from your origin to the destination, or like playing a game and figuring out the next move.
Search
Representing information and drawing inferences from it.
Knowledge
Dealing with uncertain events using probability.
Uncertainty
Finding not only a correct way to solve a problem, but a better—or the best—way to solve it.
Optimization
Improving performance based on access to data and experience. For example, your email is able to distinguish spam from non-spam mail based on past experience.
Learning
A program structure inspired by the human brain that is able to perform tasks effectively.
Neural Networks
Processing natural language, which is produced and understood by humans.
Language
Involves an agent that is given an initial state and a goal state, and it returns a solution of how to get from the former to the latter.
Search Problems
An entity that perceives its environment and acts upon that environment. In a navigator app, for example, it could be a representation of a car that needs to decide on which actions to take to arrive at the destination.
Agent
A configuration of an agent in its environment.
State
The state from which the search algorithm starts. In a navigator app, that would be the current location.
Initial State
Choices that can be made in a state.
Actions
The function for action that returns as output the set of actions that can be executed in state s.
Actions(s)
A description of what state results from performing any applicable action in any state.
Transition Model
Upon receiving state s and action a as input, the function of the transition model returns the state resulting from performing action a in state s.
Results(s, a)
The set of all states reachable from the initial state by any sequence of actions
State Space
It can be visualized as a directed graph with states, represented as nodes, and actions, represented as arrows between nodes.
State Space
The condition that determines whether a given state is a goal state. The current location of the agent is at the destination.
Goal Test
A numerical cost associated with a given path.
Path Cost
A sequence of actions that leads from the initial state to the goal state.
Solution
A solution that has the lowest path cost among all solutions.
Optimal Solution
a data structure that contains the following data:
- A state
- Parent ______
- The action that was applied to the state of the parent to get to the current _______
- The path cost from the initial state to this ______
Node
What is the Approach?
Start with a frontier that contains the initial state.
Repeat:
* If the frontier is empty, then no solution.
* Remove a node from the frontier.
* If node contains goal state, return the solution.
*Expand node, add resulting nodes to the frontier.
What is the Revised Approach?
Start with a frontier that contains the initial state.
* Start with an empty explored set.
Repeat:
* If the frontier is empty, then no solution.
* Remove a node from the frontier.
* If node contains goal state, return the solution.
* Add the node to the explored set.
*Expand node, add resulting nodes to the frontier if they aren’t already in the frontier or the explored set.
What is Stack?
last-in first-out data type
Which search algorithm uses stack?
Depth-First Search (DFS)
A search algorithm that always expands the deepest node in the frontier. It exhausts each one direction before trying another direction.
Depth-first search (DFS)
What are the Pros of using DFS?
At best, this algorithm is the fastest. If it “lucks out” and always chooses the right path to the solution (by chance), then depth-first search takes the least possible time to get to a solution.
What are the cons of using DFS?
- It is possible that the found solution is not optimal.
- At worst, this algorithm will explore every possible path before finding the solution, thus taking the longest possible time before reaching the solution.
A search algorithm that always expands the shallowest node in the frontier. It will follow multiple directions at the same time, taking one step in each possible direction before taking the second step in each direction.
Breadth-first search (BFS)
What is queue?
first-in first-out data type
Which search algorithm uses Queue?
Breadth-First Search (BFS)
What are the Pros of using BFS?
This algorithm is guaranteed to find the optimal solution.
What are the cons of using BFS?
- This algorithm is almost guaranteed to take longer than the minimal time to run.
- At worst, this algorithm takes the longest possible time to run.
A search strategy that uses no problem specific knowledge. It does not utilize any knowledge about the problem that they did not acquire through their own exploration.
Uninformed Search Algorithms
A search strategy that uses problem-specific knowledge to find solutions more efficiently. It considers additional knowledge to try to improve its performance.
Informed Search Algorithms
A search algorithm that expands the node that is closest to the goal, as estimated by a heuristic function h(n)
Greedy Best-First Search
It is a function that estimates how close to the goal the next node is.
heuristic function h(n)
An algorithm can use a heuristic function that relies on the ______________________ between the possible nodes and the end of the maze. It ignores walls and counts how many steps up, down, or to the sides it would take to get from one location to the goal location.
Manhattan distance
A search algorithm that expands node with lowest value of g(n) + h(n)
- g(n) = cost to reach node
- h(n) = estimated cost to goal
A* Search
How will the A* Search be optimal?
- h(n) is admissible (never overestimates the true cost), and
- h(n) is consistent (for every node n and successor n’ with step cost c, h(n) ≤ h(n’) + c)
The algorithm faces an opponent that tries to achieve the opposite goal.
Adversarial Search
A type of algorithm in adversarial search, it represents winning conditions as (-1) for one side and (+) for the other side.
Minimax
MAX (X) aims to?
Maximize score
MIN (O) aims to?
Minimize score
In a Tic-Tac-Toe game,
What does the following do?
* S0
* Player(s)
* Action(s)
* Results(s,a)
* Terminal(s)
* Utility(s)
gitapol kog gama new cards maong giusa
very skippable bc niagi nanis search problems
- S₀: Initial state (in our case, an empty 3X3 board)
- Players(s): a function that, given a state s, returns which player’s turn it is (X or O).
- Actions(s): a function that, given a state s, return all the legal moves in this state (what spots are free on the board).
- Result(s, a): a function that, given a state s and action a, returns a new state. This is the board that resulted from performing the action a on state s (making a move in the game).
- Terminal(s): a function that, given a state s, checks whether this is the last step in the game, i.e. if someone won or there is a tie. Returns True if the game has ended, False otherwise.
- Utility(s): a function that, given a terminal state s, returns the utility value of the state: -1, 0, or 1.
How does minimax work?
- Recursively, the algorithm simulates all possible games that can take place beginning at the current state and until a terminal state is reached.
- Each terminal state is valued as either (-1), 0, or (+1).
In Minimax,
Given state s, how does MAX and MIN work?
- MAX picks action a in ACTIONS(s) that produces highest value of MIN-VALUE(RESULT(s, a))
- MIN picks action a in ACTIONS(s) that produces smallest value of MAX-VALUE(RESULT(s, a)
function MAX-VALUE(s) code?
di pud dagay sir huhuhuhhuhu
function MAX-VALUE(state): if TERMINAL(state): return UTILITY(state) v = -∞ for action in ACTIONS(state): v = MAX(v, MIN-VALUE(RESULT(state, action))) return v
function MIN-VALUE(s) code?
di pud dagay sir(2) huhuhuhuhuhu
function MIN-VALUE(state): if TERMINAL(state): return UTILITY(state) v = ∞ for action in ACTIONS(state): v = MIN(v, MAX-VALUE(RESULT(state, action))) return v
How to Optimize minimax?
ambot lang optimizations ra ang naas slide
Alpha-Beta Pruning
This skips some of the recursive computations that are decidely unfavorable
apilon pa ba ni?
Alpha-Beta Pruning
It considers only a pre-defined number of moves before it stops, without ever getting to a terminal state.
mao ray definition nga nakita nako para ani
Depth-limited Minimax
A function that estimates the expected utility of the game from a given state, or, in other words, assigns values to states.
Evaluation function
Depth-limited Minimax relies on ?
evaluation function
trivia ata
How many possible games are there in:
* Tic Tac Toe?
* Chess games after 4 moves?
* chess games (lower bound)?
apil pa ba ni
apilon nalang
There is a total of 255,168 possible Tic Tac Toe games, 280,000,000,000 possible chess games after 4 moves, and 10²⁹⁰⁰⁰ possible games in Chess(lower bound)
CS50 QUIZ
Between depth first search (DFS) and breadth first search (BFS), which will find a shorter path through a maze?
A. DFS will always find a shorter path than BFS
B. BFS will always find a shorter path than DFS
C. DFS will sometimes, but not always, find a shorter path than BFS
D. BFS will sometimes, but not always, find a shorter path than DFS
E. Both algorithms will always find paths of the same length
D. BFS will sometimes, but not always, find a shorter path than DFS
CS50 QUIZ
Why is depth-limited minimax sometimes preferable to minimax without a depth limit?
A. Depth-limited minimax can arrive at a decision more quickly because it explores fewer states
B. Depth-limited minimax will achieve the same output as minimax without a depth limit, but can sometimes use less memory
C. Depth-limited minimax can make a more optimal decision by not exploring states known to be suboptimal
D. Depth-limited minimax is never preferable to minimax without a depth limit
A. Depth-limited minimax can arrive at a decision more quickly because it explores fewer states