unit 1
unit 1
Unit – I
PROBLEM SOLVING
Introduction to AI - AI Applications - Problem solving agents – search algorithms uninformed search strategies –
Heuristic search strategies – Local search and optimization problems – adversarial search – constraint satisfaction
problems (CSP)
Part-A
1. Define A.I or what is A.I? CO1 May 2023
Artificial intelligence is the branch of computer science that deals with the automation of
intelligent behavior. AI gives basis for developing human like programs which can be
useful to solve real life problems and thereby become useful to mankind.
planning
17. When a heuristic function h is said to be admissible? Give an admissible heuristic CO1
function for TSP?
Admissible heuristic function is that function which never over estimates the cost to reach the
goal state. It means that h(n) gives true cost to reach the goal state ‘n’. The admissible
heuristic for TSP is
a. Minimum spanning tree.
b. Minimum assignment problem
18. What do you mean by local maxima with respect to search technique? CO1
Local maximum is the peak that is higher than each of its neighbour states, but lowers than the
global maximum i.e. a local maximum is a tiny hill on the surface whose peak is not as high
as the main peak (which is a optimal solution). Hill climbing fails to find optimum solution
when it encounters local maxima. Any small move, from here also makes things worse
(temporarily). At local maxima all the search procedure turns out to be wasted here. It is like
a dead end.
19. What is CSP? CO1
CSP are problems whose state and goal test conform to a standard structure and very simple
representation. CSPs are defined using set of variables and a set of constraints on those
variables. The variables have some allowed values from specified domain. For example –
Graph coloring problem.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
20. How can mini-max also be extended for game of chance? CO1
In a game of chance, we can add extra level of chance nodes in game search tree. These nodes
have successors which are the outcomes of random element. The mini-max algorithm uses
probability P attached with chance node di based on this value. Successor function S(N,di)
give moves from position N for outcome di
21. Differentiate BFS and DFS CO1 May
BFS DFS 2022
BFS finds the shortest path to the DFS goes to the bottom of a sub-tree,
destination. then backtracks.
The full form of BFS is Breadth- The full form of DFS is Depth First
First Search. Search.
It uses a queue to keep track of the It uses a stack to keep track of the next
next location to visit. location to visit.
BFS traverses according to tree DFS traverses according to tree depth.
level.
It is implemented using FIFO list. It is implemented using LIFO list.
It requires more memory as compare It requires less memory as compare to
to DFS. BFS.
This algorithm gives the shallowest This algorithm doesn’t guarantee the
path solution. shallowest path solution.
There is no need of backtracking in There is a need of backtracking in
BFS. DFS.
Part-B
1. Explain the various applications of Artificial Intelligence. CO1
Following are some sectors which have the application of Artificial Intelligence:
1. AI in Astronomy
o In the last, five to ten years, AI becoming more advantageous for the healthcare
industry and going to have a significant impact on this industry.
o Healthcare Industries are applying AI to make a better and faster diagnosis than
humans. AI can help doctors with diagnoses and can inform when patients are
worsening so that medical help can reach to the patient before hospitalization.
3. AI in Gaming
o AI can be used for gaming purpose. The AI machines can play strategic games
like chess, where the machine needs to think of a large number of possible
places.
4. AI in Finance
o AI and finance industries are the best matches for each other. The finance
industry is implementing automation, chatbot, adaptive intelligence, algorithm
trading, and machine learning into financial processes.
5. AI in Data Security
o The security of data is crucial for every company and cyber-attacks are growing
very rapidly in the digital world. AI can be used to make your data more safe
and secure. Some examples such as AEG bot, AI2 Platform,are used to
determine software bug and cyber-attacks in a better way.
6. AI in Social Media
o Social Media sites such as Facebook, Twitter, and Snapchat contain billions of
user profiles, which need to be stored and managed in a very efficient way. AI
can organize and manage massive amounts of data. AI can analyze lots of data
to identify the latest trends, hashtag, and requirement of different users.
8. AI in Automotive Industry
o Various Industries are currently working for developing self-driven cars which
can make your journey more safe and secure.
9. AI in Robotics:
10. AI in Entertainment
o We are currently using some AI based applications in our daily life with some
entertainment services such as Netflix or Amazon. With the help of ML/AI
algorithms, these services show the recommendations for programs or shows.
11. AI in Agriculture
o Agriculture is an area which requires various resources, labor, money, and time
for best result. Now a day's agriculture is becoming digital, and AI is emerging
in this field. Agriculture is applying AI as agriculture robotics, solid and crop
monitoring, predictive analysis. AI in agriculture can be very helpful for
farmers.
12. AI in E-commerce
13. AI in education:
o AI can automate grading so that the tutor can have more time to teach. AI chat-
bot can communicate with students as a teaching assistant.
o AI in the future can be work as a personal virtual tutor for students, which will
be accessible easily at any time and any place.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
2. Outline the uninformed search strategies like breadth-first search and depth-first CO1 May 23
search with examples.
1. BREADTH-FIRST SEARCH:
o Breadth-first search is the most common search strategy for traversing a tree
or graph. This algorithm searches breadthwise in a tree or graph, so it is
called breadth-first search.
o BFS algorithm starts searching from the root node of the tree and expands all
successor node at the current level before moving to nodes of next level.
Advantages:
o If there are more than one solutions for a given problem, then BFS will
provide the minimal solution which requires the least number of steps.
Disadvantages:
o It requires lots of memory since each level of the tree must be saved into
memory to expand the next level.
o BFS needs lots of time if the solution is far away from the root node.
Example:
In the below tree structure, we have shown the traversing of the tree using BFS
algorithm from the root node S to goal node K. BFS search algorithm traverse in
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
layers, so it will follow the path which is shown by the dotted arrow, and the
traversed path will be:
1. S---> A--->B---->C--->D---->G--->H--->E---->F---->I ----------->K
o It is called the depth-first search because it starts from the root node and
follows each path to its greatest depth node before moving to the next
path.
o DFS requires very less memory as it only needs to store a stack of the
nodes on the path from root node to the current node.
o It takes less time to reach to the goal node than BFS algorithm (if it
traverses in the right path).
Disadvantage:
o There is the possibility that many states keep re-occurring, and there is no
guarantee of finding the solution.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
o DFS algorithm goes for deep down searching and sometime it may go to
the infinite loop.
Example:
In the below search tree, we have shown the flow of depth-first search, and it will
follow the order as:
It will start searching from root node S, and traverse A, then B, then D and E, after
traversing E, it will backtrack the tree as E has no other successor and still goal
node is not found. After backtracking it will traverse node C and then G, and here
it will terminate as it found goal node.
Where, m= maximum depth of any node and this can be much larger than d
(Shallowest solution depth)
Space Complexity: DFS algorithm needs to store only single path from the root
node, hence space complexity of DFS is equivalent to the size of the fringe set,
which is O(bm).
3. Discuss about depth limited search and uniform cost search CO1
Depth Limited Search:
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
• A depth-limited Search algorithm is similar to depth-first search with a
predetermined limit.
• Depth-limited search can solve the drawback of infinite path in the Depth-first
search.
• Depth-limited search can be terminated with two conditions of failure:
• Standard failure value: It indicates that problem does not have any
solution
• Cutoff failure value: It defines no solution for the problem within a
given depth limit.
• Advantages
• Depth-limited search is Memory efficient.
• Disadvantages
• Depth-limited search also has a disadvantage of incompleteness.
• It may not be optimal if the problem has more than one solution.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
Uniform Cost Search
α>=β
Let's take an example of two-player search tree to understand the working of Alpha-beta
pruning
Step 1: At the first step the, Max player will start first move from node A where α= -∞
and β= +∞, these value of alpha and beta passed down to node B where again α= -∞ and
β= +∞, and Node B passes the same value to its child D.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
Step 2: At Node D, the value of α will be calculated as its turn for Max. The value of α
is compared with firstly 2 and then 3, and the max (2, 3) = 3 will be the value of α at
node D and node value will also 3.
Step 3: Now algorithm backtrack to node B, where the value of β will change as this is a
turn of Min, Now β= +∞, will compare with the available subsequent nodes value, i.e. min
(∞, 3) = 3, hence at node B now α= -∞, and β= 3.
In the next step, algorithm traverse the next successor of Node B which is node E, and the
values of α= -∞, and β= 3 will also be passed.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
Step 4: At node E, Max will take its turn, and the value of alpha will change. The current
value of alpha will be compared with 5, so max (-∞, 5) = 5, hence at node E α= 5 and β=
3, where α>=β, so the right successor of E will be pruned, and algorithm will not traverse
it, and the value at node E will be 5.
Step 5: At next step, algorithm again backtrack the tree, from node B to node A. At node
A, the value of alpha will be changed the maximum available value is 3 as max (-∞, 3)=
3, and β= +∞, these two values now passes to right successor of A which is Node C.
At node C, α=3 and β= +∞, and the same values will be passed on to node F.
Step 6: At node F, again the value of α will be compared with left child which is 0, and
max(3,0)= 3, and then compared with right child which is 1, and max(3,1)= 3 still α
remains 3, but the node value of F will become 1.
Step 7: Node F returns the node value 1 to node C, at C α= 3 and β= +∞, here the value
of beta will be changed, it will compare with 1 so min (∞, 1) = 1. Now at C, α=3 and β=
1, and again it satisfies the condition α>=β, so the next child of C which is G will be
pruned, and the algorithm will not compute the entire sub-tree G.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
Step 8: C now returns the value of 1 to A here the best value for A is max (3, 1) = 3.
Following is the final game tree which is the showing the nodes which are computed and
nodes which has never computed. Hence the optimal value for the maximizer is 3 for this
example.
5. Define constraint satisfaction problems and explain it with an example. CO1 May 23
CONSTRAINT SATISFACTION PROBLEM May 22
The goal is to discover some problem state that satisfies a given set of constraints.
1. Propagate available constraints. To do this, first set OPEN to the set of all
objects that must have values assigned to them in a complete solution.
Then do until an inconsistency is detected or until OPEN is empty:
a. Select an object OB from OPEN. Strengthen as much as
possible the set of constraints that apply to OB
b. If this is different from the set that was assigned the last
time OB was examined or if it this is the first time OB has
been examined, then add to OPEN all objects that share
any constraints with OB.
c. Remove OB from OPEN.
2. If the union of the constraints discovered above defines a solution, then quit
and report the solution.
3. If the solution of the constraints discovered above defines a contradiction,
then return failure.
4. If neither of the above occurs, then it is necessary to make a guess at
something in order to proceed. To do this, loop until a solution is found or
all possible solutions have been eliminated:
Example :
Cryptarithmatic puzzles,
Algorithm Working :
Problem:
SEND
+MORE
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
…………
MONEY
Assign decimal digit to each of the letters in such a way that the
answer to the problem is correct to the same letter occurs more than once,
it must be assign the same digit each time. No two different letters may be assigned
the same digit. Consider the crypt arithmetic problem.
Constraints:-
D=? E=? Y=? N=? R=? O=? S=? M=? C1=? C2=?
Goal State: the digits to the letters must be assigned in such a manner so that the
sum is satisfied.
M=1
S=8 or 9
O=0 or 1 O→0
E=2
N=3
R=8 or 9
C1=0 C1=1
2+D=Y
N+R=10+E
6. CO1
Explain informed search strategies in detail
So far we have talked about the uninformed search algorithms which looked
through search space for all possible solutions of the problem without having any
additional knowledge about search space. But informed search algorithm contains
an array of knowledge such as how far we are from the goal, path cost, how to reach
to goal node, etc. This knowledge help agents to explore less to the search space and
find more efficiently the goal node.
The informed search algorithm is more useful for large search space.
Informed search algorithm uses the idea of heuristic, so it is also called Heuristic
search.
o A* Search Algorithm
1.) BEST-FIRST SEARCH ALGORITHM (GREEDY SEARCH):
Greedy best-first search algorithm always selects the path which appears best at
that moment. It is the combination of depth-first search and breadth-first search algorithms.
It uses the heuristic function and search. Best-first search allows us to take the advantages
of both algorithms. With the help of best-first search, at each step, we can choose the most
promising node. In the best first search algorithm, we expand the node which is closest to
the goal node and the closest cost is estimated by heuristic function, i.e.
1. f(n)= g(n).
The greedy best first algorithm is implemented by the priority queue. Best first search
algorithm:
Step 3: Remove the node n, from the OPEN list which has the lowest value of
h(n), and places it in the CLOSED list.
Step 5: Check each successor of node n, and find whether any node is a
goal node or not. If any successor node is goal node, then return success
and terminate the search, else proceed to Step 6.
o Best first search can switch between BFS and DFS by gaining the
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
advantages of both the algorithms.
Disadvantages:
In A* search algorithm, we use search heuristic as well as the cost to reach the node. Hence we
can combine both costs as following, and this sum is called as a fitness number.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
Algorithm of A* search:
Step 2: Check if the OPEN list is empty or not, if the list is empty then return failure and stops.
Step 3: Select the node from the OPEN list which has the smallest value of evaluation function
(g+h), if node n is goal node then return success and stop, otherwise
Step 4: Expand node n and generate all of its successors, and put n into the closed list. For each
successor n', check whether n' is already in the OPEN or CLOSED list, if not then compute
evaluation function for n' and place into Open list.
Step 5: Else if node n' is already in OPEN and CLOSED, then it should be attached to the back
pointer which reflects the lowest g(n') value.
Advantages:
Disadvantages:
o It does not always produce the shortest path as it mostly based on heuristics and
approximation.
o A* search algorithm has some complexity issues.
o The main drawback of A* is memory requirement as it keeps all generated nodes in the
memory, so it is not practical for various large-scale problems.
Example:
In this example, we will traverse the given graph using the A* algorithm. The heuristic value
of all states is given in the below table so we will calculate the f(n) of each state using the
formula f(n)= g(n) + h(n), where g(n) is the cost to reach any node from start state.
Here we will use OPEN and CLOSED list.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
Solution:
Iteration3: {(S--> A-->C--->G, 6), (S--> A-->C--->D, 11), (S--> A-->B, 7), (S-->G, 10)}
Iteration 4 will give the final result, as S--->A--->C--->G it provides the optimal path with cost
6.
7. Describe in detail about Hill Climbing Algorithm. CO1
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
o Hill climbing algorithm is a local search algorithm which continuously moves in the
direction of increasing elevation/value to find the peak of the mountain or best solution
to the problem. It terminates when it reaches a peak value where no neighbor has a higher
value.
o Hill climbing algorithm is a technique which is used for optimizing the mathematical
problems. One of the widely discussed examples of Hill climbing algorithm is Traveling-
salesman Problem in which we need to minimize the distance traveled by the salesman.
o It is also called greedy local search as it only looks to its good immediate neighbor state
and not beyond that.
o A node of hill climbing algorithm has two components which are state and value.
o Hill Climbing is mostly used when a good heuristic is available.
o In this algorithm, we don't need to maintain and handle the search tree or graph as it only
keeps a single current state.
Local Maximum: Local maximum is a state which is better than its neighbor states, but there is
also another state which is higher than it.
Global Maximum: Global maximum is the best possible state of state space landscape. It has the
highest value of objective function.
Flat local maximum: It is a flat space in the landscape where all the neighbor states of current
states have the same value.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
Shoulder: It is a plateau region which has an uphill edge.
Simple hill climbing is the simplest way to implement a hill climbing algorithm. It only evaluates
the neighbor node state at a time and selects the first one which optimizes current cost and
set it as a current state. It only checks it's one successor state, and if it finds better than the
current state, then move else be in the same state. This algorithm has the following features:
o Step 1: Evaluate the initial state, if it is goal state then return success and Stop.
o Step 2: Loop Until a solution is found or there is no new operator left to apply.
o Step 3: Select and apply an operator to the current state.
o Step 4: Check new state:
a. If it is goal state, then return success and quit.
b. Else if it is better than the current state then assign new state as a current state.
c. Else if not better than the current state, then return to step2.
o Step 5: Exit.
The steepest-Ascent algorithm is a variation of simple hill climbing algorithm. This algorithm
examines all the neighboring nodes of the current state and selects one neighbor node which is
closest to the goal state. This algorithm consumes more time as it searches for multiple neighbors
o Step 1: Evaluate the initial state, if it is goal state then return success and stop, else make
current state as initial state.
o Step 2: Loop until a solution is found or the current state does not change.
a. Let SUCC be a state such that any successor of the current state will be better
than it.
b. For each operator that applies to the current state:
a. Apply the new operator and generate a new state.
b. Evaluate the new state.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
c. If it is goal state, then return it and quit, else compare it to the SUCC.
d. If it is better than SUCC, then set new state as SUCC.
e. If the SUCC is better than the current state, then set current state to
SUCC.
o Step 5: Exit.
Stochastic hill climbing does not examine for all its neighbor before moving. Rather, this search
algorithm selects one neighbor node at random and decides whether to choose it as a current state
or examine another state.
1. Local Maximum: A local maximum is a peak state in the landscape which is better than each
of its neighboring states, but there is another state also present which is higher than the local
maximum.
Solution: Backtracking technique can be a solution of the local maximum in state space
landscape. Create a list of the promising path so that the algorithm can backtrack the search space
and explore other paths as well.
2. Plateau: A plateau is the flat area of the search space in which all the neighbor states of the
current state contains the same value, because of this algorithm does not find any best direction
to move. A hill-climbing search might be lost in the plateau area.
Solution: The solution for the plateau is to take big steps or very little steps while searching, to
solve the problem. Randomly select a state which is far away from the current state so it is possible
that the algorithm could find non-plateau region.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
3. Ridges: A ridge is a special form of the local maximum. It has an area which is higher than its
surrounding areas, but itself has a slope, and cannot be reached in a single move.
Solution: With the use of bidirectional search, or by moving in different directions, we can
improve this problem.
ADVERTISEMENT
ADVERTISEMENT
Simulated Annealing:
A hill-climbing algorithm which never makes a move towards a lower value guaranteed to be
incomplete because it can get stuck on a local maximum. And if algorithm applies a random walk,
by moving a successor, then it may complete but not efficient. Simulated Annealing is an
algorithm which yields both efficiency and completeness.
3. Goal-based agents
o The knowledge of the current state environment is not always sufficient to decide for an
agent to what to do.
o The agent needs to know its goal which describes desirable situations.
o Goal-based agents expand the capabilities of the model-based agent by having the "goal"
information.
o They choose an action, so that they can achieve the goal.
o These agents may have to consider a long sequence of possible actions before deciding
whether the goal is achieved or not. Such considerations of different scenario are called
searching and planning, which makes an agent proactive.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
4. Utility-based agents
o These agents are similar to the goal-based agent but provide an extra component of utility
measurement which makes them different by providing a measure of success at a given
state.
o Utility-based agent act based not only goals but also the best way to achieve the goal.
o The Utility-based agent is useful when there are multiple possible alternatives, and an
agent has to choose in order to perform the best action.
o The utility function maps each state to a real number to check how efficiently each action
achieves the goals.
5. Learning Agents
o A learning agent in AI is the type of agent which can learn from its past experiences, or
it has learning capabilities.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
o It starts to act with basic knowledge and then able to act and adapt automatically through
learning.
o A learning agent has mainly four conceptual components, which are:
a. Learning element: It is responsible for making improvements by learning from
environment
b. Critic: Learning element takes feedback from critic which describes that how
well the agent is doing with respect to a fixed performance standard.
c. Performance element: It is responsible for selecting external action
d. Problem generator: This component is responsible for suggesting actions that
will lead to new and informative experiences.
o Hence, learning agents are able to learn, analyze performance, and look for new ways to
improve the performance.
o Both the players fight it as the opponent player gets the minimum benefit while they get
the maximum benefit.
o Both Players of the game are opponent of each other, where MAX will select the
maximized value and MIN will select the minimized value.
o The minimax algorithm performs a depth-first search algorithm for the exploration of the
complete game tree.
o The minimax algorithm proceeds all the way down to the terminal node of the tree, then
backtrack the tree as the recursion.
Initial call:
Minimax(node, 3, true)
o This algorithm applies DFS, so in this game-tree, we have to go all the way through the
leaves to reach the terminal nodes.
o At the terminal node, the terminal values are given so we will compare those value and
backtrack the tree until the initial state occurs. Following are the main steps involved in
solving the two-player game tree:
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.
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.
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.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
o For node A max(4, -3)= 4
That was the complete workflow of the minimax two player game.
The main drawback of the 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 which we have discussed in the next topic.
10. How to define a problem as state space search? Discuss it with the help of an example CO1
The reflex agents are known as the simplest agents because they directly map
states into actions. Unfortunately, these agents fail to operate in an environment where the
mapping is too large to store and learn. Goal-based agent, on the other hand, considers
future actions and the desired outcomes.
Problem-solving agent
PROBLEM DEFINITION
To build a system to solve a particular problem, we need to do four things:
(i) Define the problem precisely. This definition must include specification
of the initial situations and also final situations which constitute (i.e) acceptable solution to
the problem.
(ii) Analyze the problem (i.e) important features have an immense (i.e) huge
impact on the appropriateness of various techniques for solving the problems.
(iii) Isolate and represent the knowledge to solve the problem.
(iv) Choose the best problem – solving techniques and apply it to the
particular problem.
Steps performed by Problem-solving agent
Search: It identifies all the best possible sequence of actions to reach the goal state from
the current state. It takes a problem as an input and returns solution as its output.
Solution: It finds the best algorithm out of various algorithms, which may be proven as
the best optimal solution.
Execution: It executes the best optimal solution from the searching algorithms to reach
the goal state from the current state.
11. Explain the types of control strategy is used in 8 puzzle problem. CO1
Toy Problem: It is a concise and exact description of the problem which is used by the
researchers to compare the performance of algorithms.
Real-world Problem: It is real-world based problems which require solutions. Unlike a toy
problem, it does not depend on descriptions, but we can have a general formulation of the
problem.
8 Puzzle Problem: Here, we have a 3×3 matrix with movable tiles numbered from
1 to 8 with a blank space. The tile adjacent to the blank space can slide into that space.
The objective is to reach a specified goal state similar to the goal state, as shown in
the below figure.
In the figure, our task is to convert the current state into goal state by
sliding digits into the blank space.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
In the above figure, our task is to convert the current (Start) state into goal state by sliding
digits into the blank space.
States: It describes the location of each numbered tiles and the blank tile.
Initial State: We can start from any state as the initial state.
Actions: Here, actions of the blank space is defined, i.e., either left, right, up or down
Transition Model: It returns the resulting state as per the given state and actions.
Goal test: It identifies whether we have reached the correct goal-state.
Path cost: The path cost is the number of steps in the path where the cost of each step
is 1. Note: The 8-puzzle problem is a type of sliding-block problem which is used
for testing new search algorithms in artificial intelligence.
8-queens problem: The aim of this problem is to place eight queens on a chessboard
in an order where no queen may attack another. A queen can attack other queens either
diagonally or in same row and column.
From the following figure, we can understand the problem as well as its correct
solution.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
It is noticed from the above figure that each queen is set into the chessboard in a position
where no other queen is placed diagonally, in same row or column. Therefore, it is one
right approach to the 8-queens problem.
2. Complete-state formulation: It starts with all the 8-queens on the chessboard and moves
them around, saving from the attacks.
States: Arrangement of all the 8 queens one per column with no queen attacking the
other queen.
Actions: Move the queen at the location where it is safe from the attacks.
This formulation is better than the incremental formulation as it reduces the state space from
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.
Zero-Sum Game
o Zero-sum games are adversarial search which involves pure competition.
o 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.
o One player of the game try to maximize one single value, while other player tries to
minimize it.
o Each move by one player in the game is called as ply.
o Chess and tic-tac-toe are examples of a Zero-sum game.
The Zero-sum game involved embedded thinking in which one agent or player is trying to figure
out:
o What to do.
o How to decide the move
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
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.
A game can be defined as a type of search in AI which can be formalized of the following
elements:
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.
The following figure is showing part of the game-tree for tic-tac-toe game. Following are some
key points of the game:
Example Explanation:
o 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.
o Both players will compute each node, minimax, the minimax value which is the best
achievable utility against an optimal adversary.
o 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.
o 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.
o 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.
o It aims to find the optimal strategy for MAX to win the game.
o It follows the approach of Depth-first search.
o In the game tree, optimal leaf node could appear at any depth of the tree.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
o 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:
2. Deterministic vs Stochastic:
o If an agent's current state and selected action can completely determine the next state of
the environment, then such environment is called a deterministic environment.
o A stochastic environment is random in nature and cannot be determined completely by
an agent.
o In a deterministic, fully observable environment, agent does not need to worry about
uncertainty.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
3. Episodic vs Sequential:
o In an episodic environment, there is a series of one-shot actions, and only the current
percept is required for the action.
o However, in Sequential environment, an agent requires memory of past actions to
determine the next best actions.
4. Single-agent vs Multi-agent
o If only one agent is involved in an environment, and operating by itself then such an
environment is called single agent environment.
o However, if multiple agents are operating in an environment, then such an environment
is called a multi-agent environment.
o The agent design problems in the multi-agent environment are different from single
agent environment.
5. Static vs Dynamic:
o If the environment can change itself while an agent is deliberating then such
environment is called a dynamic environment else it is called a static environment.
o Static environments are easy to deal because an agent does not need to continue looking
at the world while deciding for an action.
o However for dynamic environment, agents need to keep looking at the world at each
action.
o Taxi driving is an example of a dynamic environment whereas Crossword puzzles are
an example of a static environment.
6. Discrete vs Continuous:
o If in an environment there are a finite number of percepts and actions that can be
performed within it, then such an environment is called a discrete environment else it is
called continuous environment.
o A chess gamecomes under discrete environment as there is a finite number of moves
that can be performed.
o A self-driving car is an example of a continuous environment.
7. Known vs Unknown
o Known and unknown are not actually a feature of an environment, but it is an agent's
state of knowledge to perform an action.
o In a known environment, the results for all actions are known to the agent. While in
unknown environment, agent needs to learn how it works in order to perform an action.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
8. Accessible vs Inaccessible
o If an agent can obtain complete and accurate information about the state's environment,
then such an environment is called an Accessible environment else it is called
inaccessible.
o An empty room whose state can be defined by its temperature is an example of an
accessible environment.
o Information about an event on earth is an example of Inaccessible environment
What is an Agent?
An agent can be anything that perceiveits 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.
AKSHAYA COLLEGE OF ENGINEERING AND TECHNOLOGY
Intelligent Agents:
Key Points
1. A fitness function should return higher values for better states, so, for the 8-queens problem we
use the number of non attacking pairs of queens, which has a value of 28 for a solution.
2. In (c), two pairs are selected at random for reproduction, in accordance with the
probabilities in (b).
3. Notice that one individual is selected twice and one not at all.
4. For each pair to be mated, a crossover point is chosen randomly from the positions in the string.
The crossover points are after the third digit in the first pair and after the fifth digit in the second
pair.
5. In (d), the offspring themselves are created by crossing over the parent strings at the crossover
point.
6. Finally, in (e), each location is subject to random mutation with a small independent probability.
One digit was mutated in the first, third, and fourth offspring. In the 8-queens problem, this
corresponds to choosing a queen at random and moving it to a random square in its column