Artificial Intelligence Unit 1
Artificial Intelligence Unit 1
INTELLIGENCE
Unit 1
CONTENT
Introduction to AI: What is AI?
Intelligent Agents and environment;
Rationality; the nature of environment; the structure of agents.
Problem solving: Problem-solving agents; Example problems; Searching for
solution; Uninformed search strategies. Informed Search, Exploration,
Constraint Satisfaction
Adversial Search: Informed search strategies; Heuristic functions; On-line search
agents and unknown environment.
Constraint satisfaction problems; Backtracking search for CSPs.
Adversial search: Games; Optimal decisions in games; Alpha-Beta pruning.
INTRODUCTION TO AI
It is a branch of computer science by which intelligent machines is created
which can behave like a human, think like humans, and able to make
decisions."
OR
According to the father of Artificial Intelligence, John McCarthy, it is “The
science and engineering of making intelligent machines, especially intelligent
computer programs”.
Artificial Intelligence is composed of two words Artificial and Intelligence, where
Artificial defines "man-made," and intelligence defines "thinking power", hence
AI means "a man-made thinking power."
Components of Intelligence or What is Intelligence composed of?
1) Learning
2)Reasoning
3)Linguistic Intelligence
4)Perception
5) Problem solving
Learning:
It is the activity of gaining knowledge or skill by studying, practicing, being taught, or
experiencing something. Learning enhances the awareness of the subjects of the study.
The ability of learning is possessed by humans, some animals, and AI-enabled systems.
Reasoning : It is the set of processes that enables us to provide basis for judgement,
making decisions, and prediction.
Problem Solving :
It is the process in which one perceives and tries to arrive at a desired solution from a
present situation by taking some path, which is blocked by known or unknown hurdles.
Problem solving also includes decision making, which is the process of selecting the best
suitable alternative out of multiple alternatives to reach the desired goal are available
Perception:
It is the process of acquiring, interpreting, selecting, and organizing sensory
information. Perception presumes sensing. In humans, perception is aided by
sensory organs. In the domain of AI, perception mechanism puts the data
acquired by the sensors together in a meaningful manner.
Linguistic Intelligence : It is one’s ability to use, comprehend, speak, and
write the verbal and written language. It is important in interpersonal
communication.
Spatial Learning : It is learning through visual stimuli such as images, colors,
maps, etc. For Example, A person can create roadmap in mind before actually
following the road.
Stimulus-Response Learning : It is learning to perform a particular behavior
when a certain stimulus is present. For example, a dog raises its ear on hearing
do
AI DISCIPLINES
TYPES OF AI
Artificial Intelligence can be divided in various types, there are mainly two types of main categorization
which are based on capabilities and based on functionally of AI.
AI TYPE 1: BASED ON
CAPABILITY
Weak AI or Narrow AI:
Narrow AI is a type of AI which is able to perform a dedicated task with
intelligence. The most common and currently available AI is Narrow AI in the
world of Artificial Intelligence.
Narrow AI cannot perform beyond its field or limitations, as it is only trained
for one specific task. Hence it is also termed as weak AI. Narrow AI can fail in
unpredictable ways if it goes beyond its limits.
Apple Siri is a good example of Narrow AI, but it operates with a limited pre-
defined range of functions.
Some Examples of Narrow AI are playing chess, purchasing suggestions on e-
commerce site, self-driving cars, speech recognition, and image recognition
General AI:
General AI is a type of intelligence which could perform any intellectual task with
efficiency like a human.
The idea behind the general AI to make such a system which could be smarter and
think like a human by its own.
Currently, there is no such system exist which could come under general AI and can
perform any task as perfect as a human.
The worldwide researchers are now focused on developing machines with General AI.
As systems with general AI are still under research and it will take lots of efforts and
time to develop such systems.
Super AI:
Super AI is a level of Intelligence of Systems at which machines could surpass human
intelligence and can perform any task better than human with cognitive properties. It
is an outcome of general AI.
Some key characteristics of strong AI include capability include the ability to think, to
reason, solve the puzzle, make judgments, plan, learn, and communicate by its own.
Super AI is still a hypothetical concept of Artificial Intelligence. Development of such
systems in real is still world changing task.
AI TYPE 2: BASED ON
FUNCTIONALITY
1.Reactive Machines
Purely reactive machines are the most basic types of Artificial
Intelligence.
Such AI systems do not store memories or past experiences for future
actions.
These machines only focus on current scenarios and react on it as per
possible best action.
IBM's Deep Blue system is an example of reactive machines.
Google's AlphaGo is also an example of reactive machines.
2. Limited Memory
o Limited memory machines can store past experiences or some data for a
short period of time.
o These machines can use stored data for a limited time period only.
o Self-driving cars are one of the best examples of Limited Memory systems.
These cars can store recent speed of nearby cars, the distance of other
cars, speed limit, and other information to navigate the road.
3.Theory of Mind
o Theory of Mind AI should understand the human emotions, people,
beliefs, and be able to interact socially like humans.
o This type of AI machines is still not developed, but researchers are
making lots of efforts and improvement for developing such AI
machines.
4.Self-Awareness
o Self-awareness AI is the future of Artificial Intelligence. These
machines will be super intelligent, and will have their own
consciousness, sentiments, and self-awareness.
o These machines will be smarter than human mind.
o Self-Awareness AI does not exist in reality still and it is a hypothetical
concept.
TYPES OF INTELLIGENCE
1)Linguistic Intelligence
It is the ability to speak, recognize and use the mechanism of grammar,
semantic and phonology, It is an ability to think and express the scenario easily
as user understands
Ex: Novelist, Journalist.
2)Musical Intelligence
It is an ability to analyses pitch, rhythm and tone.
This enables us to recognize, create, reproduce and reflect it on the music.
2. Procedural Knowledge
It is also known as imperative knowledge.
Procedural knowledge is a type of knowledge which is responsible for knowing
how to do something.
It can be directly applied to any task.
It includes rules, strategies, procedures, agendas, etc.
Procedural knowledge depends on the task on which it can be applied.
3. Meta-knowledge: Knowledge about the other types of knowledge is called
Meta-knowledge.
4. Heuristic knowledge:
Heuristic knowledge is representing knowledge of some experts in a filed or
subject. Heuristic knowledge is rules of thumb based on previous experiences,
awareness of approaches, and which are good to work but not guaranteed.
5. Structural knowledge
Structural knowledge is basic knowledge to problem-solving.
It describes relationships between various concepts such as kind of, part of,
and grouping of something.
It describes the relationship that exists between concepts or objects.
DIFFERENCE BETWEEN
PROGRAMMING WITH AI
AND PROGRAMMING
WITHOUT AI
APPLICATIONS OF AI
Gaming − AI plays crucial role in strategic games such as chess, poker, tic-tac-toe, etc., where
machine can think of large number of possible positions based on heuristic knowledge.
Natural Language Processing − It is possible to interact with the computer that understands
natural language spoken by humans.
Expert Systems − There are some applications which integrate machine, software, and special
information to impart reasoning and advising. They provide explanation and advice to the users.
Vision Systems − These systems understand, interpret, and comprehend visual input on the
computer
Speech Recognition − Some intelligent systems are capable of hearing and comprehending the
language in terms of sentences and their meanings while a human talk to it. It can handle different
accents, slang words, noise in the background, change in human’s noise due to cold, etc.
Handwriting Recognition − The handwriting recognition software reads the text written on paper
by a pen or on screen by a stylus. It can recognize the shapes of the letters and convert it into
editable text.
Intelligent Robots − Robots are able to perform the tasks given by a human. They have sensors to
detect physical data from the real world such as light, heat, temperature, movement, sound, bump,
and pressure. They have efficient processors, multiple sensors and huge memory, to exhibit
intelligence. In addition, they are capable of learning from their mistakes and they can adapt to the
new environment
AGENT
The AI system consists of the agent and environment; the agents will acts up on the
environment.
Agent: An agent is anything that can be viewed as perceiving its environment through
sensors and acting upon that environment through actuators.
An Agent runs in the cycle of perceiving, thinking, and acting.
The agent receives the information from the environment from sensors and store and
process the information in the agent program do the actions by using the effectors.
The agent consists of the following terms
1. Sensors: Sensor is a device which detects the change in the environment and sends
the information to other electronic devices. Sensors can be camera, infrared ray’s
devices, keyboard, eye, ear etc.
2. Effectors: Effectors are the devices which affect the environment. Effectors can be
legs, wheels, arms, fingers, wings, fins, and display screen.
3. 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
INTELLIGENT AGENTS
An intelligent agent (IA) is an entity that makes a decision, that enables artificial intelligence to be put
into action. It can also be described as a software entity that conducts operations in the place of users or
programs after sensing the environment. It uses actuators to initiate action in that environment.
This agent has some level of autonomy that allows it to perform specific, predictable, and repetitive tasks
for users or applications.
It’s also termed as ‘intelligent’ because of its ability to learn during the process of performing tasks.
The two main functions of intelligent agents include perception and action. Perception is done through
sensors while actions are initiated through actuators.
Intelligent agents consist of sub-agents that form a hierarchical structure. Lower-level tasks are
performed by these sub-agents.
The higher-level agents and lower-level agents form a complete system that can solve difficult problems
through intelligent behaviors or responses.
AGENTS AND ENVIRONMENT
Rationality is status of being reasonable, sensible, and having good sense of judgment.
Rationality is concerned with expected actions and results depending upon what the agent has perceived. Performing actions
with the aim of obtaining useful information is an important part of rationality.
Rationality of an agent depends on the following −
• The performance measures, which determine the degree of success.
Adversarial search is a search, where we examine the problem which arises when
we try to plan ahead of the world and other agents are planning against us.
we have studied the search strategies which are only associated with a single agent that
aims to find the solution which often expressed in the form of a sequence of actions.
But, there might be some situations where more than one agent is searching for the solution
in the same search space, and this situation usually occurs in game playing.
The environment with more than one agent is termed as multi-agent environment, in which
each agent is an opponent of other agent and playing against each other. Each agent needs
to consider the action of other agent and effect of that action on their performance.
So, Searches in which two or more players with conflicting goals are trying to explore the
same search space for the solution, are called adversarial searches, often known as Games.
Games are modeled as a Search problem and heuristic evaluation function, and these are
the two main factors which help to model and solve games in AI.
TYPES OF GAMES IN AI:
• 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.
• 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.
• 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.
• 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.
ZERO SUM GAME
Zero-sum games are adversarial search which involves pure competition.
In Zero-sum game each agent's gain or loss of utility is exactly balanced by the losses or gains
of utility of another agent.
One player of the game try to maximize one single value, while other player tries to minimize it.
Each of the players is trying to find out the response of his opponent to their actions. This
requires embedded thinking or backward reasoning to solve the game problems in AI.
FORMALIZATION OF THE PROBLEM:
A game can be defined as a type of search in AI which can be
formalized of the following elements:
• Initial state: It specifies how the game is set up at the start.
• Player(s): It specifies which player has moved in the state space.
• Action(s): It returns the set of legal moves in state space.
• Result(s, a): It is the transition model, which specifies the result of moves in
the state space.
• Terminal-Test(s): Terminal test is true if the game is over, else it is false at any
case. The state where the game ends is called terminal states.
• Utility(s, p): A utility function gives the final numeric value for a game that
ends in 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 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.
Example: Tic-Tac-Toe game tree:
The following figure is showing part
of the game-tree for tic-tac-toe
game. Following are some key
points of the game:
• There are two players MAX and
MIN.
• Players have an alternate turn and
start with MAX.
• MAX maximizes the result of the
game tree
• MIN minimizes the result.
EXAMPLE
• From the initial state, MAX has 9 possible moves as he starts first. MAX place x
and MIN place o, and both player plays alternatively until we reach a leaf node
where one player has three in a row or all squares are filled.
• Both players will compute each node, minimax, the minimax value which is the
best achievable utility against an optimal adversary.
• Suppose both the players are well aware of the tic-tac-toe and playing the best
play. Each player is doing his best to prevent another one from winning. MIN is
acting against Max in the game.
• So in the game tree, we have a layer of Max, a layer of MIN, and each layer is
called as Ply. Max place x, then MIN puts o to prevent Max from winning, and
this game continues until the terminal node.
• In this either MIN wins, MAX wins, or it's a draw. This game-tree is the whole
search space of possibilities that MIN and MAX are playing tic-tac-toe and
taking turns alternately.
Hence adversarial Search for the minimax procedure works as follows:
• It aims to find the optimal strategy for MAX to win the game.
• It follows the approach of Depth-first search.
• In the game tree, optimal leaf node could appear at any depth of the tree.
• Propagate the minimax values up to the tree until the terminal node discovered.
In a given game tree, the optimal strategy can be determined from the minimax
value of each node, which can be written as MINIMAX(n). MAX prefer to move to
a state of maximum value and MIN prefer to move to a state of minimum value
then:
TYPES OF ALGORITHM IN
ADVERSARIAL SEARCH
Here the results depends on the players which will decide the result of the
game
Types of adversarial search algorithm
1. Minmax Algorithm
2. Alpha-Beta Algorithm
MINMAX ALGORITHM
• 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.
• Mini-Max algorithm uses recursion to search through the game-tree.
• 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.
• In this algorithm two players play the game, one is called MAX and other is called MIN.
• Both the players fight it as the opponent player gets the minimum benefit while they
get the maximum benefit.
• Both Players of the game are opponent of each other, where MAX will select the
maximized value and MIN will select the minimized value.
• The minimax algorithm performs a depth-first search algorithm for the exploration of
the complete game tree.
• The minimax algorithm proceeds all the way down to the terminal node of the tree, then
backtrack the tree as the recursion.
WORKING OF MIN-MAX ALGORITHM:
Step-1: In the first step, the algorithm generates the entire game-tree and apply
the utility function to get the utility values for the terminal states. In the below
tree diagram, let's take A is the initial state of the tree. Suppose maximizer takes
first turn which has worst-case initial value =- infinity, and minimizer will take
next turn which has worst-case initial value = +infinity
Step 2: Now, first we find the utilities value for the Maximizer, its initial value is -
∞, so we will compare each value in terminal state with initial value of Maximizer
and determines the higher nodes values. It will find the maximum among the all.
• For node D max(-1,- -∞) => max(-1,4)= 4
• For Node E max(2, -∞) => max(2, 6)= 6
• For Node F max(-3, -∞) => max(-3,-5) = -3
• For node G max(0, -∞) = max(0, 7) = 7
Step 3: In the next step, it's a turn for minimizer, so it will compare all nodes
value with +∞, and will find the 3rd layer node values.
• For node B= min(4,6) = 4
• For node C= min (-3, 7) = -3
Step 4: Now it's a turn for Maximizer, and it will again choose the maximum of all
nodes value and find the maximum value for the root node. In this game tree,
there are only 4 layers, hence we reach immediately to the root node, but in real
games, there will be more than 4 layers.
• For node A max(4, -3)= 4
PROPERTIES OF MINI-MAX ALGORITHM:
• Complete- Min-Max algorithm is Complete. It will definitely find a solution (if
exist), in the finite search tree.
• Optimal- Min-Max algorithm is optimal if both opponents are playing optimally.
• 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.
• Space Complexity- Space complexity of Mini-max algorithm is also similar to
DFS which is O(bm).
Disadvantage of minimax algorithm is that it gets really slow for complex
games such as Chess, go, etc. This type of games has a huge branching factor,
and the player has lots of choices to decide. This limitation of the minimax
algorithm can be improved from alpha-beta pruning
ALPHA-BETA ALGORITHM
CONSTRAINT SATISFACTION PROBLEM (CSP)
Constraint Satisfaction Problem (CSP) is a fundamental topic in artificial
intelligence (AI) that deals with solving problems by identifying constraints and
finding solutions that satisfy those constraints.
CSP has a wide range of applications, including scheduling, resource allocation,
and automated reasoning.
The goal of AI is to create intelligent machines that can perform tasks that
usually require human intelligence, such as reasoning, learning, and problem-
solving. One of the key approaches in AI is the use of constraint satisfaction
techniques to solve complex problems.
CSP is a specific type of problem-solving approach that involves identifying
constraints that must be satisfied and finding a solution that satisfies all the
constraints. CSP has been used in a variety of applications, including scheduling,
planning, resource allocation, and automated reasoning.
CONSTRAINT SATISFACTION
A Constraint Satisfaction Problem in artificial intelligence involves a set of variables, each of
which has a domain of possible values, and a set of constraints that define the allowable
combinations of values for the variables. The goal is to find a value for each variable such that all
the constraints are satisfied.
More formally, a CSP is defined as a triple (X,D,C), where:
Generic heuristics
Reduce complexity
Path cost:
(i.e., the difference in the values assigned to Vi and Vj can’t be equal to the difference between i and j.
ONLINE SEARCH AGENTS AND
UNKNOWN ENVIRONMENTS
Online Search Agents
1. previous state
2. Action
3. resulting state (only known afterwards)
Goal test for state
Sometimes, agent has a heuristic telling it approximately how far from the goal it
is
Simple maze problem
• Competitive Ratio
Path cost over path costs if agent were to know the environment
• Often infinite: Agent can end up in a dead-end state because of an irreversible
action
•While exploring, jump down a cliff