Aiml Unit 1
Aiml Unit 1
LEARNING
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."
Artificial intelligence (AI) is a branch of computer science concerned with building smart intelligent
machines capable of performing tasks that typically behave like humans, think like humans, and are able to
make decisions.
To create the AI first we should know how intelligence is composed, so the Intelligence is an intangible part
of our brain which is a combination of Reasoning, learning, problem- solving perception, language
understanding, etc.
1
To achieve the above factors for a machine or software Artificial Intelligence requires the following
discipline:
● Mathematics
● Biology
● Psychology
● Sociology
● Computer Science
● Neurons Study ● Statistics
High Accuracy with fewer errors: AI machines or systems are prone to fewer errors and high accuracy as it
takes decisions as per pre-experience or information.
High-Speed: AI systems can be of very high-speed and fast-decision making; because of that AI systems
can beat a chess champion in the Chess game.
High reliability: AI machines are highly reliable and can perform the same action multiple times with high
accuracy.
Useful for risky areas: AI machines can be helpful in situations such as defusing a bomb, exploring the ocean
floor, where employing a human can be risky.
Digital Assistant: AI can be very useful to provide digital assistance to the users such as AI technology is
currently used by various E-commerce websites to show the products as per customer requirement.
Useful as a public utility: AI can be very useful for public utilities such as a self-driving car which can make
our journey safer and hassle-free, facial recognition for security purposes, Natural language processing to
communicate with the human in human-language, etc.
High Cost: The hardware and software requirement of AI is very costly as it requires lots of maintenance to
meet current world requirements.
Can’t think out of the box: Even though we are making smarter machines with AI, still they cannot work out
of the box, as the robot will only do that work for which they are trained, or programmed.
No feelings and emotions: AI machines can be an outstanding performer, but still it does not have the feeling
so it cannot make any kind of emotional attachment with humans, and may sometimes be harmful for users if
the proper care is not taken.
Increase dependency on machines: With the increment of technology, people are getting more dependent on
devices and hence they are losing their mental capabilities.
No Original Creativity: As humans are so creative and can imagine some new ideas but still AI machines
cannot beat this power of human intelligence and cannot be creative and imaginative.
*************************************************************************
Application of AI:
1. AI in Astronomy: Artificial Intelligence can be very useful to solve complex universe problems.
AI technology can be helpful for understanding the universe such as how it works, origin, etc.
2. AI in Healthcare:
In the last five to ten years, AI is becoming more advantageous for the healthcare industry and going to have
a significant impact on this industry.
2
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 the patient before
hospitalization.
3. AI in Gaming: 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: 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: 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: 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, hashtags, and requirements
of different users.
7. AI in Travel & Transport : AI is becoming highly demanding for travel industries. AI is capable of
doing various travel related works such as from making travel arrangements to suggesting the hotels, flights,
and best routes to the customers. Travel industries are using AI- powered chatbots which can make human-
like interaction with customers for better and fast response.
8. AI in Automotive Industry:
3
Some Automotive industries are using AI to provide virtual assistant to their user for better performance.
Such as Tesla has introduced TeslaBot, an intelligent virtual assistant.
Various Industries are currently working for developing self-driven cars which can make your journey more
safe and secure.
9. AI in Robotics:
Artificial Intelligence has a remarkable role in Robotics. Usually, general robots are programmed
such that they can perform some repetitive task, but with the help of AI, we can create intelligent robots
which can perform tasks with their own experiences without being pre- programmed.
Humanoid Robots are the best examples for AI in robotics, recently the intelligent Humanoid robot named
Erica and Sophia has been developed which can talk and behave like humans.
10. AI in Entertainment: 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: Agriculture is an area which requires various resources, labor, money, and time for
best results. Nowadays 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: AI is providing a competitive edge to the e-commerce industry, and it is becoming
more demanding in the e-commerce business. AI is helping shoppers to discover associated products with
recommended size, color, or even brand.
13. AI in education:
AI can automate grading so that the tutor can have more time to teach. AI chatbot can communicate with
students as a teaching assistant.
AI in the future can work as a personal virtual tutor for students, which will be accessible easily at any time
and any place.
4
At that time high-level computer languages such as FORTRAN, LISP, or COBOL were invented. And the
enthusiasm for AI was very high at that time. The golden years-Early enthusiasm (1956-1974) o Year 1966:
The researchers emphasized developing algorithms which can solve mathematical problems. Joseph
Weizenbaum created the first chatbot in 1966, which was named ELIZA.
o Year 1972: The first intelligent humanoid robot was built in Japan which was named as WABOT-1.
The first AI winter (1974-1980)
o The duration between 1974 to 1980 was the first AI winter duration. AI winter refers to the time period
where computer scientists dealt with a severe shortage of funding from the government for AI research.
o During AI winters, an interest of publicity on artificial intelligence was decreased. A boom of AI
(1980-1987) o Year 1980: After AI winter duration, AI came back with "Expert System". Expert systems
were programmed that emulate the decision-making ability of a human expert.
o In 1980, the first national conference of the American Association of Artificial Intelligence was held
at Stanford University. The second AI winter (1987-1993) o The duration between the years 1987 to 1993
was the second AI Winter duration.
o Again Investors and government stopped funding for AI research due to high cost but not efficient
result. The expert system such as XCON was very cost effective. The emergence of intelligent agents (1993-
2011)
o Year 1997: In the year 1997, IBM Deep Blue beat world chess champion Gary Kasparov, and became
the first computer to beat a world chess champion.
5
o Year 2002: for the first time, AI entered the home in the form of Roomba, a vacuum cleaner.
o Year 2006: AI came in the Business world till the year 2006. Companies like Facebook, Twitter, and
Netflix also started using AI.
Deep learning, big data and artificial general intelligence (2011-present)
o Year 2011: In the year 2011, IBM's Watson won jeopardy, a quiz show, where it had to solve complex
questions as well as riddles. Watson had proved that it could understand natural language and can solve tricky
questions quickly.
o Year 2012: Google has launched an Android app feature "Google now", which was able to provide
information to the user as a prediction.
o Year 2014: In the year 2014, Chatbot "Eugene Goostman" won a competition in the infamous
"Turing test."
o Year 2018: The "Project Debater" from IBM debated on complex topics with two master debaters and
also performed extremely well.
o Google has demonstrated an AI program "Duplex" which was a virtual assistant and which had taken
hairdresser appointments on call, and the lady on the other side didn't notice that she was talking with the
machine.
Now AI has developed to a remarkable level. The concept of Deep learning, big data, and data science are
now trending like a boom. Nowadays companies like Google, Facebook, IBM, and Amazon are working with
AI and creating amazing devices. The future of Artificial Intelligence is inspiring and will come with high
intelligence.
Artificial Intelligence can be divided in to two types based on capabilities and functionally.
7
● 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
● Limited memory machines can store past experiences or some data for a short period of time.
● These machines can use stored data for a limited time period only.
● Self-driving cars are one of the best examples of Limited Memory systems. These cars can store the
recent speed of nearby cars, the distance of other cars, speed limit, and other information to navigate the road.
3. Theory of Mind
● Theory of Mind AI should understand human emotions, people, beliefs, and be able to interact socially
like humans.
● These types of AI machines are still not developed, but researchers are making lots of efforts and
improvements for developing such AI machines.
4. Self-Awareness
● 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.
● These machines will be smarter than the human mind.
● Self-Awareness AI does not exist in reality still and it is a hypothetical concept.
************************************************************************
Rule 1: An AI agent must have the ability to perceive the environment. Rule 2: The observation must be used
to make decisions.
Rule 3: Decision should result in an action.
Rule 4: The action taken by an AI agent must be a rational action
Types of AI Agents:
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 time. These are given below:
● Simple Reflex Agent
● Model-based reflex agent
● Goal-based agents
● Utility-based agent
● Learning agent
1.Simple Reflex 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.
● These agents only succeed in the fully observable environment.
● The Simple reflex agent does not consider any part of perceived history during their decision and action
process.
● The Simple reflex agent works on Condition-action rule, which means it maps the current state to
action. Such as a Room Cleaner agent, it works only if there is dirt in the room.
● Problems for the simple reflex agent design approach: They have very limited intelligence
They do not have knowledge of non-perceptual parts of the current state Mostly too big to generate and to
store.
Not adaptive to changes in the environment.
9
● A model-based agent has two important factors:
● Model: It is knowledge about "how things happen in the world," so it is called a Model-based agent.
● Internal State: It is a representation of the current state based on percept history.
● These agents have the model, "which is knowledge of the world" and based on the model they perform
actions.
Updating the agent state requires information about: How the world evolves How the
agent's action affects the world.
3.Goal-based agents
● The knowledge of the current state environment is not always sufficient to decide for an agent what to
do.
● The agent needs to know its goal which describes desirable situations.
● Goal-based agents expand the capabilities of the model-based agent by having the "goal" information.
● They choose an action, so that they can achieve the goal.
● 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.
10
4.Utility-based agents:
● 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.
● Utility-based agent act based not only goals but also the best way to achieve the goal.
● 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.
● The utility function maps each state to a real number to check how efficiently each action achieves the
goals.
5.Learning Agents
A learning agent in AI is the type of agent which can learn from its past experiences, or it has learning
capabilities.
It starts to act with basic knowledge and then able to act and adapt automatically through learning. A
learning agent has mainly four conceptual components, which are:
1. Learning element: It is responsible for making improvements by learning from environment
11
2. Critic: Learning element takes feedback from critic which describes that how well the agent is doing
with respect to a fixed performance standard.
3. Performance element: It is responsible for selecting external action
4. Problem generator: This component is responsible for suggesting actions that will lead to new and
informative experiences.
Hence, learning agents are able to learn, analyze performance, and look for new ways to improve the
performance.
6.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 the AI reinforcement learning
algorithm, for each best possible action, the 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:
● Performance measure which defines the success criterion. Agent prior knowledge of its environment.
● Best possible actions that an agent can perform. The sequence of percepts.
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:
P:Performance measure E: Environment
A:Actuators S: Sensors
Here performance measure is the objective for the success of an agent's behavior. PEAS for self-driving cars:
12
Let's suppose a self-driving car then PEAS representation will be:
Performance: Safety, time, legal drive, comfort Environment: Roads, other vehicles, road signs, pedestrian
Actuators: Steering, accelerator, brake, signal, horn Sensors: Camera, GPS, speedometer, odometer,
accelerometer, sonar.
Environment in AI:
An environment is everything in the world which surrounds the agent, but it is not a part of an agent itself.
An environment can be described as a situation in which an agent is present.
The environment is where agent lives, operate and provide the agent with something to sense and act upon it.
An environment is mostly said to be non-feministic.
Features of Environment
An environment can have various features from the point of view of an agent:
1. Fully observable vs Partially Observable
2. Static vs Dynamic
3. Discrete vs Continuous
4. Deterministic vs Stochastic
5. Single-agent vs Multi-agent
6. Episodic vs sequential
7. Known vs Unknown
8. Accessible vs Inaccessible
14
Turing Test was introduced by Turing in his 1950 paper, "Computing Machinery and Intelligence," which
considered the question, "Can Machine think?"
The Turing test is based on a party game "Imitation game," with some modifications. This game involves
three players in which one player is Computer, another player is human responder, and the third player is a
human Interrogator, who is isolated from other two players and his job is to find that which player is machine
among two of them.
Consider, Player A is a computer, Player B is human, and Player C is an interrogator. Interrogator is aware
that one of them is machine, but he needs to identify this on the basis of questions and their responses.
he conversation between all players is via keyboard and screen so the result would not depend on the
machine's ability to convert words as speech.
The test result does not depend on each correct answer, but only how closely its responses like a human
answer. The computer is permitted to do everything possible to force a wrong identification by the interrogator.
The questions and answers can be like:
Interrogator: Are you a computer? PlayerA (Computer): No
Interrogator: Multiply two large numbers such as (256896489*456725896) Player A: Long pause and give
the wrong answer.
In this game, if an interrogator would not be able to identify which is a machine and which is human, then
the computer passes the test successfully, and the machine is said to be intelligent and can think like a human.
Chatbots to attempt the Turing test:
ELIZA: ELIZA was a Natural language processing computer program created by Joseph Weizenbaum. It was
created to demonstrate the ability of communication between machine and humans. It was one of the first
chatterbots, which has attempted the Turing Test.
Parry: Parry was a chatterbot created by Kenneth Colby in 1972. Parry was designed to simulate a person
with Paranoid schizophrenia(most common chronic mental disorder). Parry was described as
"ELIZA with attitude." Parry was tested using a variation of the Turing Test in the early 1970s.
Eugene Goostman: Eugene Goostman was a chatbot developed in Saint Petersburg in 2001. This bot
has competed in the various number of Turing Test. In June 2012, at an event,
15
Goostman won the competition promoted as largest-ever Turing test content, in which it has convinced 29%
of judges that it was a human.Goostman resembled as a 13-year old virtual boy.
The Chinese Room Argument:
There were many philosophers who really disagreed with the complete concept of Artificial
Intelligence. The most famous argument in this list was "Chinese Room."
In the year 1980, John Searle presented "Chinese Room" thought experiment, in his paper "Mind, Brains, and
Program," which was against the validity of Turing's Test. According to his argument, "Programming a
computer may make it to understand a language, but it will not produce a real understanding of language or
consciousness in a computer."
He argued that Machine such as ELIZA and Parry could easily pass the Turing test by manipulating
keywords and symbol, but they had no real understanding of language. So it cannot be described as
"thinking" capability of a machine such as a human.
16
Properties of Search Algorithms:
Completeness: A search algorithm is said to be complete if it guarantees to return a solution if at least
any solution exists for any random input.
Optimality: If a solution found for an algorithm is guaranteed to be the best solution (lowest path cost)
among all other solutions, then such a solution for is said to be an optimal solution. Time Complexity: Time
complexity is a measure of time for an algorithm to complete its task.
Space Complexity: It is the maximum storage space required at any point during the search, as the
complexity of the problem.
*******************************************************************
Uninformed search/Blind Search:
Uninformed search is a class of general-purpose search algorithms which operates in brute force-way.
The uninformed search does not contain any domain knowledge such as closeness, the location of the goal. It
operates in a brute-force way as it only includes information about how to traverse the tree and how to identify
leaf and goal nodes. Uninformed search applies a way in which search tree is searched without any information
about the search space like initial state operators and test for the goal, so it is also called blind search. It
examines each node of the tree until it achieves the goal node.
Uninformed search/Blind Search can be divided as
1. Breadth-first Search
2. Depth-first Search
3. Depth-limited Search
4. Iterative deepening depth-first search
5. Uniform cost search
17
6. Bidirectional Search
Time Complexity: Time Complexity of BFS algorithm can be obtained by the number of nodes traversed in
BFS until the shallowest Node. Where the d= depth of shallowest solution and b is a node at every state.
T (b) = 1+b2+b3+ + bd= O (bd)
18
Space Complexity: Space complexity of BFS algorithm is given by the Memory size of frontier which is
O(bd).
Completeness: BFS is complete, which means if the shallowest goal node is at some finite depth, then
BFS will find a solution.
Optimality: BFS is optimal if path cost is a non-decreasing function of the depth of the node.
Advantages of BFS:
● BFS will provide a solution if any solution exists.
● If there are more than one solution for a given problem, then BFS will provide the minimal solution
which requires the least number of steps.
Disadvantages of BFS:
● It requires lots of memory since each level of the tree must be saved into memory to expand the next
level.
● BFS needs lots of time if the solution is far away from the root node
19
The DFS algorithm works as follows:
1. Start by putting any one of the graph's vertices on top of a stack.
2. Take the top item of the stack and add it to the visited list.
3. Create a list of that vertex's adjacent nodes. Add the ones which aren't in the visited list to the top of
the stack.
4. Keep repeating steps 2 and 3 until the stack is empty.
Completeness: DFS search algorithm is complete within finite state space as it will expand every node within
a limited search tree.
Time Complexity: Time complexity of DFS will be equivalent to the node traversed by the algorithm. It is
given by:
T(n)= 1+ n2+ n3 + + nm=O(nm)
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).
Optimal: DFS search algorithm is non-optimal, as it may generate a large number of steps or high cost to
reach to the goal node.
Advantage:
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.
It takes less time to reach to the goal node than BFS algorithm (if it traverses in the right path).
Disadvantage:
20
There is the possibility that many states keep reoccurring, and there is no guarantee of finding the
solution.
DFS algorithm goes for deep down searching and sometime it may go to the infinite loop.
A depth-limited search algorithm is similar to depth-first search with a predetermined limit. Depth-limited
search can solve the drawback of the infinite path in the Depth-first search. In this algorithm, the node at the
depth limit will treat as it has no successor nodes further.
o Standard failure value: It indicates that problem does not have any solution. o Cutoff
failure value: It defines no solution for the problem within a given depth limit.
Advantages:
Disadvantages:
o Depth-limited search also has a disadvantage of incompleteness. o It may not be optimal if the
problem has more than one solution.
Example:
21
Completeness: DLS search algorithm is complete if the solution is above the depth-limit.
Uniform-cost search is a searching algorithm used for traversing a weighted tree or graph. This algorithm
comes into play when a different cost is available for each edge. The primary goal of the uniform-cost search
is to find a path to the goal node which has the lowest cumulative cost. Uniform-cost search expands nodes
according to their path costs form the root node. It can be used to solve any graph/tree where the optimal cost
is in demand. A uniform-cost search algorithm is implemented by the priority queue. It gives maximum priority
to the lowest cumulative cost. Uniform cost search is equivalent to BFS algorithm if the path cost of all edges
is the same.
Advantages:
1.Uniform cost search is optimal because at every state the path with the least cost is chosen.
Disadvantages:
2.It does not care about the number of steps involve in searching and only concerned about path
cost. Due to which this algorithm may be stuck in an infinite loop.
Example:
22
Completeness:
Uniform-cost search is complete, such as if there is a solution, UCS will find it.
Time Complexity:
Let C* is Cost of the optimal solution, and ε is each step to get closer to the goal node. Then the number of
steps is = C*/ε+1. Here we have taken +1, as we start from state 0 and end to C*/ε.
Space Complexity:
The same logic is for space complexity so, the worst-case space complexity of Uniform-cost search
is O(b1 + [C*/ε]).
Optimal:
Uniform-cost search is always optimal as it only selects a path with the lowest path cost.
The iterative deepening algorithm is a combination of DFS and BFS algorithms. This search algorithm finds
out the best depth limit and does it by gradually increasing the limit until a goal is found.
23
This algorithm performs depth-first search up to a certain "depth limit", and it keeps increasing the depth
limit after each iteration until the goal node is found.
This Search algorithm combines the benefits of Breadth-first search's fast search and depth-first search's
memory efficiency.
The iterative search algorithm is useful uninformed search when search space is large, and depth of goal node
is unknown.
Advantages:
1.It combines the benefits of BFS and DFS search algorithm in terms of fast search and memory efficiency.
Disadvantages:
2.The main drawback of IDDFS is that it repeats all the work of the previous phase.
Example:
Following tree structure is showing the iterative deepening depth-first search. IDDFS algorithm performs
various iterations until it does not find the goal node. The iteration performed by the algorithm is given as:
1'stIteration----->A
2'ndIteration---->A,B,C
3'rdIteration------>A,B,D,E,C,F,G
4'thIteration------>A,B,D,H,I,E,C,F,K,G
In the fourth iteration, the algorithm will find the goal node.
Completeness:
24
This algorithm is complete if the branching factor is finite.
Time Complexity:
Let's suppose b is the branching factor and depth is d then the worst-case time complexity is O(bd).
Space Complexity:
Optimal:
IDDFS algorithm is optimal if path cost is a non- decreasing function of the depth of the node.
Bidirectional search algorithm runs two simultaneous searches, one form initial state called as forward-search
and other from goal node called as backward-search, to find the goal node. Bidirectional search replaces one
single search graph with two small subgraphs in which one starts the search from an initial vertex and other
starts from goal vertex. The search stops when these two graphs intersect each other.
Bidirectional search can use search techniques such as BFS, DFS, DLS, etc.
Advantages:
Disadvantages:
Example:
In the below search tree, bidirectional search algorithm is applied. This algorithm divides one graph/tree into
two sub-graphs. It starts traversing from node 1 in the forward direction and starts from goal node 16 in the
backward direction.
25
Completeness: Bidirectional Search is complete if we use BFS in both searches.
*******************************************************************
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.
Heuristics function: Heuristic is a function which is used in Informed Search, and it finds the most promising
path. It takes the current state of the agent as its input and produces the estimation of how close agent is from
the goal. The heuristic method, however, might not always give the best solution, but it guaranteed to find a
good solution in reasonable time. Heuristic function estimates how close a state is to the goal. It is represented
26
by h(n), and it calculates the cost of an optimal path between the pair of states. The value of the heuristic
function is always positive.
Admissibility of the heuristic function is given as:
Here h(n) is heuristic cost, and h*(n) is the estimated cost. Hence heuristic cost should be less than or equal
to the estimated cost.
Pure heuristic search is the simplest form of heuristic search algorithms. It expands nodes based on their
heuristic value h(n). It maintains two lists, OPEN and CLOSED list. In the CLOSED list, it places those nodes
which have already expanded and in the OPEN list, it places nodes which have yet not been expanded.
On each iteration, each node n with the lowest heuristic value is expanded and generates all its successors
and n is placed to the closed list. The algorithm continues unit a goal state is found.
In the informed search we will discuss two main algorithms which are given below:
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.
f(n)= g(n).
27
● Step 6: For each successor node, algorithm checks for evaluation function f(n), and then check if the
node has been in either OPEN or CLOSED list. If the node has not been in both list, then add it to the OPEN
list.
● Step 7: Return to Step 2.
Advantages:
● Best first search can switch between BFS and DFS by gaining the advantages of both the algorithms.
● This algorithm is more efficient than BFS and DFS algorithms.
Disadvantages:
Example:
Consider the below search problem, and we will traverse it using greedy best-first search. At each iteration,
each node is expanded using evaluation function f(n)=h(n) , which is given in the below table.
In this search example, we are using two lists which are OPEN and CLOSED Lists. Following are the iteration
for traversing the above example.
28
Expand the nodes of S and put in the CLOSED list
Time Complexity: The worst case time complexity of Greedy best first search is O(b m).
Space Complexity: The worst case space complexity of Greedy best first search is O(b m). Where, m is the
maximum depth of the search space.
Complete: Greedy best-first search is also incomplete, even if the given state space is finite.
A* Search Algorithm:
A* search is the most commonly known form of best-first search. It uses heuristic function h(n), and cost to
reach the node n from the start state g(n). It has combined features of UCS and greedy best-first search, by
which it solve the problem efficiently. A* search algorithm finds the shortest path through the search space
29
using the heuristic function. This search algorithm expands less search tree and provides optimal result faster.
A* algorithm is similar to UCS except that it uses g(n)+h(n) instead of g(n).
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.
At each point in the search space, only those node is expanded which have the lowest value of f(n), and the
algorithm terminates when the goal node is found.
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:
● It does not always produce the shortest path as it mostly based on heuristics and approximation.
● A* search algorithm has some complexity issues.
● 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:
30
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.
Solution:
31
Initialization: {(S, 5)}
Iteration2: {(S--> A-->C, 4), (S--> A-->B, 7), (S-->G, 10)} 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.
Points to remember:
● A* algorithm returns the path which occurred first, and it does not search for all remaining paths.
● The efficiency of A* algorithm depends on the quality of heuristic. ● A* algorithm expands all
nodes which satisfy the condition f(n) <="" li="">
● Admissible: the first condition requires for optimality is that h(n) should be an admissible heuristic for
A* tree search. An admissible heuristic is optimistic in nature.
● Consistency: Second required condition is consistency for only A* graph-search.
If the heuristic function is admissible, then A* tree search will always find the least cost path.
Time Complexity: The time complexity of A* search algorithm depends on heuristic function, and the number
of nodes expanded is exponential to the depth of solution d. So the time complexity is O(b^d), where b is the
branching factor.
SMA*( Simplified Memory Bounded A*) is a shortest path algorithm that is based on the A* algorithm. The
difference between SMA* and A* is that SMA* uses a bounded memory, while the A* algorithm might need
exponential memory.
Like the A*, it expands the most promising branches according to the heuristic. What sets SMA* apart is that
it prunes nodes whose expansion has revealed less promising than expected.
SMA*, just like A* evaluates nodes by combining g(n), the cost to reach the node, and h(n), the cost to get
from the node to the goal: f(n) = g(n) + h(n).
Since g(n) gives the path cost from the start node to node n, and h(n) is the estimated cost of the cheapest
path from n to the goal, we have f(n) = estimated cost of the cheapest solution through n. The lower the f value
is, the higher priority the node will have.
32
The difference from A* is that the f value of the parent node will be updated to reflect changes to this estimate
when its children are expanded. A fully expanded node will have an f value at least as high as that of its
successors.
In addition, the node stores the f value of the best forgotten successor (or best forgotten child). This value is
restored if the forgotten successor is revealed to be the most promising successor.
Before continuing reading this post, we suggest you read our post on the A* algorithm. Understanding how
A* works will help you a lot in understanding how SMA* works.
33
Image 2: Generating Children in SMA* Algorithm
Image 3: Handling Long Paths i.e. Too Many Nodes In The Memory
Problem
34
On Image 5 we have the problem we are about to solve. Our requirement is to find the shortest path starting
from node “S” to node “G”. We can see the graph and how the nodes are connected. Also, we can see the table,
containing the heuristic values for each of the nodes.
On Image 6 we can see how the algorithm evaluates the children. Firstly it added the “A” and “B” nodes
(starting alphabetically). On the right of the node in blue color is the f value, on the left is the g value or the
cost to reach that node(in green color), and the h value or the heuristic (in red color).
35
Image 7: Full Memory While Evaluation
On Image 7 we can see what happens when you want to evaluate more nodes than what the memory allows.
The already evaluated children with the highest f value get removed, but its value is remembered in its
parent(the number in purple color on the right of the “S” node).
On Image 8 we can see that if all accessible children nodes are visited or explored we adjust the parent’s f
value to the value of the children with the lowest f value.
36
Image 9: Memory Full Evaluate Through The Lowest f Value Child
On Image 9 we can see how the algorithm evaluates the children of the “A” node. The only children is the
“G” node which is the goal, which means there is now a way for exploring further.
Now we remove the “C” node, since it has the highest f value but we don’t remember it, since the “B” node
has a lower value. Now we update the f value of the “A” node to 6 because all the children accessible are
explored.
Image 10: Update The Root Value (“S” node) To The Remembered Value
Just because we’ve reached the goal node, doesn’t mean that the algorithms are finished. As we can see the
remembered f value of the “B” node is lower than the f value of the “G” node explored through the “A” node.
37
This gives hope that we might reach the goal node again for a lower f value or lower total cost. We also update
the f value of the “S” node to 5 since there is no more child node with value 4.
As we can see on Image 11 we will remove the “A” node since it has already discovered the goal and has the
same f value as the “C” node so we will remember this node in the parent “S” node.
38
Image 12: Reaching The Goal For The Lowest Total Cost
On Image 12 we can see that we’ve reached the goal again, this time through the “B” node. This time cost is
lower than through the “A” node.
The memory is full, which means we need to remove the “C” node, because it has the highest f value, and it
means that if we eventually reach the goal from this node the total cost at best case scenario will be equal to
6, which is worse than we already have.
At this stage, the algorithm terminates, and we have found the shortest path from the “S” node to the “G”
node.
Conclusion
SMA* (Simplified Memory Bounded A Star) is a very popular graph path finding algorithm, mainly because
it is based on the A* algorithm, which already does a very good job of exploring the shortest path in graphs.
This algorithm is better than A* because it is memory-optimized.
As in the A* post, we cannot end this post without saying how important is the understanding of this algorithm
if you want to continue to learn about more complex graph searching algorithms.
*****************************************************************
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.
o Generate and Test variant: Hill Climbing is the variant of Generate and Test method. The Generate and
Test method produce feedback which helps to decide which direction to move in the search space.
o Greedy approach: Hill-climbing algorithm search moves in the direction which optimizes the cost.
o No backtracking: It does not backtrack the search space, as it does not remember the previous states.
The state-space landscape is a graphical representation of the hill-climbing algorithm which is showing a
graph between various states of algorithm and Objective function/Cost.
On Y-axis we have taken the function which can be an objective function or cost function, and state-space on
the x-axis. If the function on Y-axis is cost then, the goal of search is to find the global minimum and local
minimum. If the function of Y-axis is Objective function, then the goal of the search is to find the global
maximum and local maximum.
40
Different regions in the state space landscape:
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.
Working Process
This algorithm works on the following steps in order to find an optimal solution.
1. It tries to define the current state as the state of starting or the initial state.
2. It generalizes the solution to the current state and tries to find an optimal solution. The solution obtained
may not be the best.
3. It compares the solution which is generated to the final state also known as the goal state.
4. It will check whether the final state is achieved or not. If not achieved, it will try to find another
solution.
Types of Hill Climbing
Simple Hill Climbing is one of the easiest methods. It performs evaluation taking one state of a neighbor
node at a time, looks into the current cost and declares its current state. It tries to check the status of the next
neighbor state. If it finds the rate of success more than the previous state, it tries to move or else it stays in
the same position. It is advantageous as it consumes less time but it does not guarantee the best optimal
solution as it gets affected by the local optima.
Algorithm:
Condition:
a) If it is found to be final state, stop and return success
b) If it is not found to be the final state, make it a current state.
1. A state which is not applied should be selected as the current state and with the help of this state,
produce a new state.
2. Evaluate the new state produced.
Conditions:
1. If it is found to be final state, stop and return success.
2. If it is found better compared to current state, then declare itself as a current state and proceed.
3. If it is not better, perform looping until it reaches a solution.
This algorithm selects the next node by performing an evaluation of all the neighbor nodes. The node that
gives the best solution is selected as the next node.
Algorithm:
Condition:
a) If it reaches the goal state, stop the process
b) If it fails to reach the final state, the current state should be declared as the initial state.
Step 2: Repeat the state if the current state fails to change or a solution is found.
42
Step 3: Exit
Stochastic Hill Climbing
This algorithm is different from the other two algorithms, as it selects neighbor nodes randomly and makes
a decision to move or choose another randomly. This algorithm is very less used compared to the other two
algorithms.
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.
43
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.
Features:
1. It uses a greedy approach as it goes on finding those states which are capable of reducing the cost
function irrespective of any direction.
2. It is considered as a variant in generating expected solutions and the test algorithm. It first tries to
generate solutions that are optimal and evaluates whether it is expected or not. If it is found the same as
expected, it stops; else it again goes to find a solution.
3. It does not perform a backtracking approach because it does not contain a memory to rememberthe
previous space.
Genetic Algorithm
A genetic algorithm is an adaptive heuristic search algorithm inspired by "Darwin's theory of evolution in
Nature." It is used to solve optimization problems in machine learning. It is one of the important algorithms
as it helps solve complex problems that would take a long time to solve.
genetic Algorithms are being widely used in different real-world applications, for example, Designing
electronic circuits, code-breaking, image processing, and artificial creativity.
In this topic, we will explain Genetic algorithm in detail, including basic terminologies used in Genetic
algorithm, how it works, advantages and limitations of genetic algorithm, etc.
What is a Genetic Algorithm?
44
Before understanding the Genetic algorithm, let's first understand basic terminologies to better understand
this algorithm:
o Population: Population is the subset of all possible or probable solutions, which can solve the
given problem.
o Chromosomes: A chromosome is one of the solutions in the population for the given problem, and the
collection of gene generate a chromosome. o Gene: A chromosome is divided into a different gene, or it is
an element of the chromosome.
o Allele: Allele is the value provided to the gene within a particular chromosome.
o Fitness Function: The fitness function is used to determine the individual's fitness level in the
population. It means the ability of an individual to compete with other individuals. In every iteration,
individuals are evaluated based on their fitness function.
o Genetic Operators: In a genetic algorithm, the best individual mate to regenerate offspring better than
parents. Here genetic operators play a role in changing the genetic composition of the next generation.
o Selection
After calculating the fitness of every existent in the population, a selection process is used to determine which
of the individualities in the population will get to reproduce and produce the seed that will form the coming
generation.
The genetic algorithm works on the evolutionary generational cycle to generate high-quality solutions. These
algorithms use different operations that either enhance or replace the population to give an improved fit
solution.
It basically involves five phases to solve the complex optimization problems, which are given as below:
1. Initialization
The process of a genetic algorithm starts by generating the set of individuals, which is called population. Here
each individual is the solution for the given problem. An individual contains or is characterized by a set of
parameters called Genes. Genes are combined into a string and generate chromosomes, which is the solution
to the problem. One of the most popular techniques for initialization is the use of random binary strings.
45
2. Fitness Assignment
Fitness function is used to determine how fit an individual is? It means the ability of an individual to compete
with other individuals. In every iteration, individuals are evaluated based on their fitness function. The fitness
function provides a fitness score to each individual. This score further determines the probability of being
selected for reproduction. The high the fitness score, the more chances of getting selected for reproduction.
3. Selection
The selection phase involves the selection of individuals for the reproduction of offspring. All the selected
individuals are then arranged in a pair of two to increase reproduction. Then these individuals transfer their
genes to the next generation.
4. Reproduction
After the selection process, the creation of a child occurs in the reproduction step. In this step, the genetic
algorithm uses two variation operators that are applied to the parent population. The two operators involved
in the reproduction phase are given below:
46
The genes of parents are exchanged among themselves until the crossover point is met. These newly generated
offspring are added to the population. This process is also called or crossover. Types of crossover styles
available:
o One point crossover o Two-point crossover o Livery crossover
o Inheritable Algorithms crossover o Mutation
The mutation operator inserts random genes in the offspring (new child) to maintain the diversity in the
population. It can be done by flipping some bits in the chromosomes.
Mutation helps in solving the issue of premature convergence and enhances diversification. The below image
shows the mutation process:
Types of mutation styles available, o
Flip bit mutation o
Gaussian mutation o
Exchange/Swap mutation
5. Termination
After the reproduction phase, a stopping criterion is applied as a base for termination. The algorithm
terminates after the threshold fitness solution is reached. It will identify the final solution as the best solution
in the population.
47
Advantages of Genetic Algorithm o The parallel capabilities of
genetic algorithms are best.
o It helps in optimizing various problems such as discrete functions, multi-objective problems, and
continuous functions. o It provides a solution for a problem that
improves over time. o A genetic algorithm does not need
derivative information.
Limitations of Genetic Algorithms o Genetic algorithms are not efficient algorithms for
solving simple problems. o It does not guarantee the quality of the final solution to a problem.
o Repetitive calculation of fitness values may generate some computational challenges.
Figure 4.6(a) shows a population of four 8-digit strings, each representing a state of the 8- queens puzzle: the
-th digit represents the row number of the queen in column . In (b), each state is rated by the fitness function.
Higher fitness values are better, so for the 8- queens problem we use the number of nonattacking pairs of
queens, which has a value of 8 × 7/2 = 28 for a solution. The values of the four states in (b) are 24, 23, 20, and
11. The fitness scores are then normalized to probabilities, and the resulting values are shown next to the
fitness values in (b).
48
In (c), two pairs of parents are selected, in accordance with the probabilities in (b). Notice that one individual
is selected twice and one not at all. For each selected pair, a crossover point (dotted line) is chosen randomly.
In (d), we cross over the parent strings at the crossover points, yielding new offspring. For example, the first
child of the first pair gets the first three digits (327) from the first parent and the remaining digits (48552) from
the second parent. The 8-queens states involved in this recombination step are shown in Figure 4.7.
Finally, in (e), each location in each string 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
Finally, in (e), each location in each string 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. It is often the case that the
population is diverse early on in the process, so crossover frequently takes large steps in the state space early
49
in the search process (as in simulated annealing). After many generations of selection towards higher fitness,
the population becomes less diverse, and smaller steps are typical. Figure 4.8 describes an algorithm that
implements all these steps.
*******************************************************************
ADVERSARIAL SEARCH
Game Playing
• Game theory views any multiagent environment as a game, provided that the impact of each agent on
the others is “ significant” regardless of whether the agents are cooperative or competitive.
• Games, like the real world, therefore require the ability to make some decision even when calculating
the optimal decision is infeasible.
• Pruning allows us to ignore portions of the search tree that make no difference to the final choice A
game can be formally defined as a kind of search problem with the following elements:
50
Initial state – Empty squares
Players – X O
Utility – final numeric value for a game that ends in terminal state – O 1,
X0
The initial state, action function, and result function define the game tree for the game - a tree where the
nodes are game states and the edges are moves.
Mini-max 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
51
● 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
● The working of the minimax algorithm can be easily described using an example. Below we have taken
an example of game-tree which is representing the two-player game.
● In this example, there are two players one is called Maximizer and other is called Minimizer.
● Maximizer will try to get the Maximum possible score, and Minimizer will try to get the minimum
possible score.
● This algorithm applies DFS, so in this game-tree, we have to go all the way through the leaves to reach
the terminal nodes.
● 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.
52
o For node D max(-1,- -∞) => max(-1,4)= 4 o For Node E max(2, -∞) => max(2, 6)= 6 o
For Node F max(-3, -∞) => max(-3,-5) = -3 o 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.
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.
53
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.
Alpha-Beta Pruning
o Alpha-beta pruning is a modified version of the minimax algorithm. It is an optimization technique for
the minimax algorithm.
o As we have seen in the minimax search algorithm that the number of game states it has to examine are
exponential in depth of the tree. Since we cannot eliminate the exponent, but we can cut it to half. Hence there
is a technique by which without checking each node of the game tree we can compute the correct minimax
decision, and this technique is called pruning. This involves two threshold parameter Alpha and beta for future
expansion, so it is called alpha-beta pruning. It is also called as Alpha-Beta Algorithm. o Alpha-beta
pruning can be applied at any depth of a tree, and sometimes it not only prune the tree leaves but also entire
sub-tree. o The two-parameter can be defined as:
1. Alpha: The best (highest-value) choice we have found so far at any point along the path of
Maximizer. The initial value of alpha is -∞.
54
2. Beta: The best (lowest-value) choice we have found so far at any point along the path of
Minimizer. The initial value of beta is +∞.
o The Alpha-beta pruning to a standard minimax algorithm returns the same move as the standard
algorithm does, but it removes all the nodes which are not really affecting the final decision but making
algorithm slow. Hence by pruning these nodes, it makes the algorithm fast.
α>=β
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.
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.
55
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.
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.
56
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.
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.
57
Move Ordering in Alpha-Beta pruning:
The effectiveness of alpha-beta pruning is highly dependent on the order in which each node is examined.
Move order is an important aspect of alpha-beta pruning.
It can be of two types:
o Worst ordering: In some cases, alpha-beta pruning algorithm does not prune any of the leaves
of the tree, and works exactly as minimax algorithm. In this case, it also consumes more time because of
alpha-beta factors, such a move of pruning is called worst ordering. In this case, the best move occurs on the
right side of the tree. The time complexity for such an order is O(bm).
o Ideal ordering: The ideal ordering for alpha-beta pruning occurs when lots of pruning happens in the
tree, and best moves occur at the left side of the tree. We apply DFS hence it first search left of the tree and
go deep twice as minimax algorithm in the same amount of time. Complexity in ideal ordering is O(bm/2).
58
Artificial Intelligence (AI) is the simulation of human intelligence driven into machines.
Several applications of AI have developed within a short period. With that, the world has been
observing a faster growth of this simulation and structures of several applications that were built
on AI. With such rapid adaptability to this growth, one must learn the ‘Ethics of AI’ before laying
the foundation.
59
ensuring equitable treatment for all individuals regardless of their race, gender,
ethnicity, age, sexual orientation, or any other characteristic.
4. Responsibility: AI must ensure accountability for any inherent biases or errors.
The developers and deployers must ensure responsibility for its training or
design. The users must be responsible for their actions and implementations
using AI.
5. Safety: Since AI is integrated to our lives in every aspect, the development of
AI must be carried out by prioritizing safety and evaluation, such that, there is
no harm to any factors. The stakeholders and users must be responsible for its
safe use.
What are the ethical challenges of AI?
1. Opacity: Opacity is a key ethical challenge in AI, as AI systems often operate as
black boxes, making it difficult for users and stakeholders to understand how
decisions are made or why certain outcomes are produced. Lack of
transparency usually leads to other challenges such as bias, fairness, etc.
2. Attacks and breaches: AI is prone to adversarial attacks and since AI solely
relies on data, there is a high scope for cyber-attack leads and data breaches.
To prevent these, a secure mechanism is cyber-attack leads required to
safeguard the sensitive data and to promote a secure AI.
3. Algorithmic biases: Biases present in training data or algorithmic decision-
making processes can result in unfair or discriminatory outcomes. Such biased
data leads to underrepresentation or overrepresentation which in turn
concludes an unethical AI.
4. Ethical Accountability: A minor crept or error in an AI technology can lead to
problems such as biases, discrimination, privacy violations, and safety hazards,
it is required for a user, stakeholder, deployer or a developer to take the
responsibility that involves addressing the ethical dilemmas, concerns, and
issues that arise from the development, deployment, and use of AI
technologies.
5. Risk Management: Various risks rise during the development, deployment of
AI such as system failures, errors, or unintended consequences and addressing
these challenges requires careful consideration of safety risks, robust risk
management strategies, and the implementation of safety measures to
promote the safe use of AI technologies.
What is the AI Code of Ethics?
1. Openness and Disclosure: Transparency in AI refers to a sense of openness of
the actions and operations performed by the machine. As per ‘Code of Ethics’ ,
the provisions of transparency helps the user or developer to understand the
actions and decisions taken by the AI internally.
60
2. Data Security Standards: A secure AI leads to integrity, confidentiality, and
availability of AI systems and data. The ‘Code of Ethics’ provisions include
access control and authentication mechanisms to enable security. By
prioritizing security in AI, stakeholders can mitigate risks, safeguard user
privacy, and ensure the trustworthiness and reliability of AI systems.
3. Equity and Unbiased Decision-Making: Addressing bias and promoting
fairness is essential to ensure that AI technologies are developed, deployed,
and used in an ethical and responsible manner. The ‘Code of
Ethics’ emphasizes the importance of mitigating biases in AI algorithms and
data to prevent unfair or discriminatory outcomes.
4. Ethical Responsibilities: Responsibility refers to the ethical and legal
obligations of individuals, organizations, and stakeholders involved in the
development, deployment, and use of AI technologies. It refers to the
importance of taking accountability for the outcomes and impacts of AI
systems.
5. Safety and Well-being: The ‘Code of Ethics‘ emphasizes the importance of
assessing and mitigating potential risks and hazards associated with AI
systems, such as system failures, errors, or unintended consequences, to
minimize harm and ensure safety of AI technologies.
61