CS50’s Introduction to Artificial Intelligence with Python
April 18, 2024About 1 min
CS50’s Introduction to Artificial Intelligence with Python
Search
Search problems involve 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. A navigator app uses a typical search process, where the agent (the thinking part of the program) receives as input your current location and your desired destination, and, based on a search algorithm, returns a suggested path. However, there are many other forms of search problems, like puzzles or mazes.

Finding a solution to a 15 puzzle would require the use of a search algorithm.
- Agent: An entity that perceives its environment and acts upon that environment. In a navigator app, for example, the agent would be a representation of a car that needs to decide on which actions to take to arrive at the destination.
- State: A configuration of an agent in its environment. For example, in a 15 puzzle, a state is any one way that all the numbers are arranged on the board.
- Initial State: The state from which the search algorithm starts. In a navigator app, that would be the current location.
- Actions: Choices that can be made in a state. More precisely, actions can be defined as a function. Upon receiving state
s
as input,Actions(s)
returns as output the set of actions that can be executed in states
. For example, in a 15 puzzle, the actions of a given state are the ways you can slide squares in the current configuration (4 if the empty square is in the middle, 3 if next to a side, 2 if in the corner - Transition Model: A description of what state results from performing any applicable action in any state. More precisely, the transition model can be defined as a function. Upon receiving state
s
and actiona
as input,Results(s, a)
returns the state resulting from performing actiona
in states
. For example, given a certain configuration of a 15 puzzle (states
), moving a square in any direction (actiona
) will bring to a new configuration of the puzzle (the new state). - State Space: The set of all states reachable from the initial state by any sequence of actions.
- Goal Test: Way to determine whether a given state is a goal state.
- Path Cost: Numerical cost associated with a given path.