2nd Unit and 3 RD Unit Also 1st Unit
2nd Unit and 3 RD Unit Also 1st Unit
Agents can be grouped into five classes based on their degree of perceived intelligence and capability. All these
agents can improve their performance and generate better action over the time.
These are given below:
1.Simple Reflex Agent 2.Model-based reflex agent 3. Goal-based agents 4. Utility-based agent 5. Learning agent
The Simple reflex agents are the simplest agents. These agents
take decisions on the basis of the current percepts and ignore the
rest of the percept history.
What is an Agent?
An agent can be anything that perceive its environment through sensors and act upon that environment through
actuators. An Agent runs in the cycle of perceiving, thinking, and acting. An agent can be:
o Human-Agent: A human agent has eyes, ears, and other organs which work for sensors and hand, legs,
vocal tract work for actuators.
o Robotic Agent: A robotic agent can have cameras, infrared range finder, NLP for sensors and various
motors for actuators.
o Software Agent: Software agent can have keystrokes, file contents as sensory input and act on those
inputs and display output on the screen.
Hence the world around us is full of agents such as thermostat, cellphone, camera, and even we are also agents.
Before moving forward, we should first know about sensors, effectors, and actuators.
Sensor: Sensor is a device which detects the change in the environment and sends the information to other
electronic devices. An agent observes its environment through sensors.
Actuators: Actuators are the component of machines that converts energy into motion. The actuators are only
responsible for moving and controlling a system. An actuator can be an electric motor, gears, rails, etc.
Effectors: Effectors are the devices which affect the environment. Effectors can be legs, wheels, arms, fingers,
wings, fins, and display screen.
Intelligent Agents:
An intelligent agent is an autonomous entity which act upon an environment using sensors and
actuators for achieving goals. An intelligent agent may learn from the environment to achieve
their goals. A thermostat is an example of an intelligent agent.
Following are the main four rules for an AI agent:
o Rule 1: An AI agent must have the ability to perceive the environment.
o Rule 2: The observation must be used to make decisions.
o Rule 3: Decision should result in an action.
o Rule 4: The action taken by an AI agent must be a rational action.
Rational Agent:
A rational agent is an agent which has clear preference, models uncertainty, and acts in a way to
maximize its performance measure with all possible actions.
A rational agent is said to perform the right things. AI is about creating rational agents to use for
game theory and decision theory for various real-world scenarios.
For an AI agent, the rational action is most important because in AI reinforcement learning
algorithm, for each best possible action, agent gets the positive reward and for each wrong
action, an agent gets a negative reward.
Note: Rational agents in AI are very similar to intelligent agents.
Rationality:
The rationality of an agent is measured by its performance measure. Rationality can be
judged on the basis of following points:
1 Performance measure which defines the success criterion. 2 Agent prior knowledge of its
environment.
2 Best possible actions that an agent can perform. 4 The sequence of percepts.
Note: Rationality differs from Omniscience because an Omniscient agent knows the actual
outcome of its action and act accordingly, which is not possible in reality.
Structure of an AI Agent
The task of AI is to design an agent program which implements the agent
function. The structure of an intelligent agent is a combination of architecture
and agent program. It can be viewed as:
1. Agent = Architecture + Agent program
Following are the main three terms involved in the structure of an AI agent:
Architecture: Architecture is machinery that an AI agent executes on.
Agent Function: Agent function is used to map a percept to an action.
1. f:P* → A
Agent program: Agent program is an implementation of agent function. An agent program executes
on the physical architecture to produce function f.
PEAS Representation
PEAS is a type of model on which an AI agent works upon. When we define an AI agent or
rational agent, then we can group its properties under PEAS representation model. It is
made up of four words:
o P: Performance measure E: Environment A: Actuators S: Sensors
Here performance measure is the objective for the success of an agent's behavior.
o Perfect information: A game with the perfect information is that in which agents can look into the
complete board. Agents have all the information about the game, and they can see each other moves also.
Examples are Chess, Checkers, Go, etc.
o Imperfect information: If in a game agents do not have all information about the game and not aware
with what's going on, such type of games are called the game with imperfect information, such as tic-tac-
toe, Battleship, blind, Bridge, etc.
o Deterministic games: Deterministic games are those games which follow a strict pattern and set of
rules for the games, and there is no randomness associated with them. Examples are chess, Checkers,
Go, tic-tac-toe, etc.
o Non-deterministic games: Non-deterministic are those games which have various unpredictable
events and has a factor of chance or luck. This factor of chance or luck is introduced by either dice or cards.
These are random, and each action response is not fixed. Such games are also called as stochastic games.
Example: Backgammon, Monopoly, Poker, etc.
Adversarial Search Formalization of the problem:
A game can be defined as a type of search in AI which can be formalized of the
following elements:
o Initial state: It specifies how the game is set up at the start.
o Result(s, a): It is the transition model, which specifies the result of moves in the state
space.
o Terminal-Test(s): Terminal test is true if the game is over, else it is false at any case.
terminal states s for player p. It is also called payoff function. For Chess, the
outcomes are a win, loss, or draw and its payoff values are +1, 0, ½. And for tic-tac-
toe, utility values are +1, -1, and 0.
Game tree:
A game tree is a tree where nodes of the tree are the game states and Edges of the tree are
the moves by players.
Game tree involves initial state, actions function, and result Function.
Mini-Max Algorithm in Artificial Intelligence
o Mini-max algorithm is a recursive or backtracking algorithm which is used in decision-
making and game theory. It provides an optimal move for the player assuming that
opponent is also playing optimally.
o Mini-Max algorithm uses recursion to search through the game-tree.
o Min-Max algorithm is mostly used for game playing in AI. Such as Chess, Checkers,
tic-tac-toe, go, and various tow-players game. This Algorithm computes the minimax
decision for the current state.
o In this algorithm two players play the game, one is called MAX and other is called MIN.
o Both the players fight it as the opponent player gets the minimum benefit while they
called Minimizer.
o Maximizer will try to get the Maximum possible score, and Minimizer will try to
value and backtrack the tree until the initial state occurs. Following are the
main steps involved in solving the two-player game tree:
Working of Min-Max Algorithm:
o The working of the minimax algorithm can be easily described using an
called Minimizer.
o Maximizer will try to get the Maximum possible score, and Minimizer will try to
value and backtrack the tree until the initial state occurs. Following are the
main steps involved in solving the two-player game tree:
Properties of Mini-Max algorithm:
o Complete- Min-Max algorithm is Complete. It will definitely find a solution (if exist), in
o Time complexity- As it performs DFS for the game-tree, so the time complexity of
Min-Max algorithm is O(bm), where b is branching factor of the game-tree, and m is the
maximum depth of the tree.
o Space Complexity- Space complexity of Mini-max algorithm is also similar to DFS
which is O(bm).
1. α>=β
Key points about alpha-beta pruning:
The cave has a room with a beast which is called Wumpus, who eats anyone who enters the room.
The Wumpus can be shot by the agent, but the agent has a single arrow.
In the Wumpus world, there are some Pits rooms which are bottomless, and if agent falls in Pits, then he
will be stuck there forever.
The exciting thing with this cave is that in one room there is a possibility of finding a heap of gold.
So the agent goal is to find the gold and climb out the cave without fallen into Pits or eaten by Wumpus.
The agent will get a reward if he comes out with gold, and he will get a penalty if eaten by Wumpus or falls
in the pit.
There are also some components which can help the agent to navigate the cave.
a. The rooms adjacent to the Wumpus room are smelly, so that it would have some stench.
b. The room adjacent to PITs has a breeze, so if the agent reaches near to PIT, then he will perceive the breeze.
c. There will be glitter in the room if and only if the room has gold.
d. The Wumpus can be killed by the agent if the agent is facing to it, and Wumpus will emit a horrible scream which
can be heard anywhere in the cave.
PEAS description of Wumpus world:
Performance measure:
o +1000 reward points if the agent comes out of the cave with the gold.
o -1000 points penalty for being eaten by the Wumpus or falling into the pit.
o -1 for each action, and -10 for using an arrow.
o The game ends if either agent dies or came out of the cave.
Environment:
Actuators:
o Left turn,
o Right turn
o Move forward
o Grab
o Release
o Shoot.
Sensors:
o The agent will perceive the stench if he is in the room adjacent to the Wumpus. (Not diagonally).
o The agent will perceive breeze if he is in the room directly adjacent to the Pit.
o The agent will perceive the glitter in the room where the gold is present.
o The agent will perceive the bump if he walks into a wall.
o When the Wumpus is shot, it emits a horrible scream which can be perceived anywhere in the cave.
o These percepts can be represented as five element list, in which we will have different indicators for each
sensor.
o Example if agent perceives stench, breeze, but no glitter, no bump, and no scream then it can be represented
as:
[Stench, Breeze, None, None, None].
o Partially observable: The Wumpus world is partially observable because the agent can only perceive the close
environment such as an adjacent room.
o Deterministic: It is deterministic, as the result and outcome of the world are already known.
o Sequential: The order is important, so it is sequential.
o Static: It is static as Wumpus and Pits are not moving.
o Discrete: The environment is discrete.
o One agent: The environment is a single agent as we have one agent only and Wumpus is not considered as
an agent.