0% found this document useful (0 votes)
17 views98 pages

Unit 5 Notes

Uploaded by

SURIYA VARSHAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views98 pages

Unit 5 Notes

Uploaded by

SURIYA VARSHAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 98

UNIT V APPLICATIONS(9 Hrs)

Applications and Game Playing: Prolog


Programming - Natural Language Processing -
Speech Recognition – Robot – Hardware –
Perception - Game Playing - Optimal Decisions in
Games – Alpha - Beta Pruning - Stochastic Games
- Case study in AI Applications
Q.What is Prolog?

• Prolog stands for Programming in logic. It is used in artificial


intelligence programming.
• Prolog is a declarative programming language.
For example: While implementing the solution for a given problem,
instead of specifying the ways to achieve a certain goal in a specific
situation, user needs to specify about the situation (rules and facts)
and the goal (query). After these stages, Prolog interpreter derives
the solution.
• Prolog is useful in AI, NLP, databases but useless in other areas such
as graphics or numerical algorithms.
• Prolog facts
• A fact is something that seems to be true.
For example: It's raining.
• In Prolog, facts are used to form the statements. Facts consist of a
specific item or relation between two or more items.
How to convert English to prolog facts using facts and rules?
It is very simple to convert English sentence into Prolog facts. Some examples
are explained in the following table.

English Statements Prolog Facts


Dog is barking barking(dog)
Jaya likes food if it is delicious. likes( Jaya, Food):-delicious(Food)

In the above table, the statement 'Dog is barking' is a fact, while the
statement 'Jaya likes food if it is delicious' is called rule. In this statement,
variable like 'Food' has a first letter in capital, because its value came from
previous fact. The symbol ':-' is used to denote that “Jaya likes delicious food”.
Arithmetic Operations in Prolog

• Prolog provides the facility for arithmetic operations.


• As per the requirement of the user, arithmetic operations can be
divided into some special purpose integer predicates and a series of
general predicates for integer, floating point and rational arithmetic.
• The general arithmetic predicates are handled by the expressions.
• An expression is either a function or a simple number.
• Prolog arithmetic is slightly different than other programming
languages.
For example:
?- X is 2 + 1.
X=3?
yes
• In the above example, 'is' is used as a special predefined operator.

• The basic arithmetic operators are given in the following table:


• Sr. No Operator Explanation
• 1 X+Y The sum of 'X' and 'Y'
• 2 X-Y the difference of 'X' and 'Y'
• 3 X*Y The product of 'X' and 'Y'
• 4 X/Y The quotient of 'X' and 'Y'
• 5 X^Y 'X' to the power of 'Y'
• 6 -X Negation of 'X'
• 7 abs(X) Absolute value of 'X'
• 8 sqrt(X) The square root of X
• 9 sin(X) The sine of X
• 10 cos(X) The cos of X
• Operator precedence
• If there is more than one operator in the arithmetic expression such as A-B*C+D, then the prolog
decides an order in which the operator should be applied.
• Prolog gives numerical value for each operator, operators with high precedence like '*' and '/' are
applied before operators with relatively low precedence values like '+' and '-'.
• Operator with same precedence value ('*' or '/') and ('+' or '-') should be applied from left to right.
• So, the expression A-B*C+D can be written as A-(B*C)+D
• Matching and Unification in Prolog
• Definition: The two terms are said to be matched, if they are equal or if they consist of variables
representing the resulting equal terms.
Prolog matches expressions in structural way. So,
?- 3 + 2= 5
no
Note: In prolog '=' means matches with.
Consider the following example,?- X + 3 = 2 * Y
But the following expressions will match because they have same structure.
• Expression 1:
?- X + Y = 2 + 3
X=2
Y=3

Expression 2:
?- 2 + Y = X + 3
X=2
Y=3
• Prolog Lists:
• Lists are the finite sequence of elements.
• Prolog uses *…+ to build a list.
• The notation [X|Y] represents that the first element is X and second element is Y (X is head and Y is tail).
• Prolog has some special notation for lists:
I) [a] [honda, maruti, renault]
ii) [a,b,c) [pen, pencil, notebook]
iii) [] represents the empty list.
• Example 1: Pattern Matching in Lists
?- [a,b] = [a,X]
X=b
but:
?- [a,b] = [X]
no
• Example 2:
Consider the following lists:
[a, b, c, d, e, f, g]
[apple, pear, bananas, breadfruit]
[ ] this is an empty list
Now, consider some comparisons of lists:
[a,b,c] matches with [Head|Tail] resulting in Head=a and
Tail=[b,c]
[a] matches with [H|T] resulting in H=a and T=[]
[a,b,c] matches with [a|T] resulting in T=[b,c]
[a,b,c] doesn't match with [b|T]
[] doesn't match with [H|T]
[] match with []. Hence, two empty lists get matched with
each other
Backtracking in Prolog

• What is backtracking?
• If a person reaches a point where a goal cannot be matched, so he can come back (backtrack) to
the last spot, where the choice of matching a specific fact or rule was formed. If this process fails, a
person again goes to the nearest previous place where a choice was made. So, this procedure is
followed until the goal is achieved.
Example:
Consider the following facts,
bird(type (sparrow) name (steve)))
bird(type (penguin) name (sweety)))
bird(type (penguin)name (jones)))
consider the following query:
?- bird(type (penguin)name(X)
So, prolog will try to match the first query, but this query will not match because sparrow doesn't
match with penguin. Then, it will try to find next query to match the fact and succeed with X =
sweety. Later, if the query or subgoals are failed, it will go to the saved option and look for more
solutions. For example: X = jones
Q.Natural Language Processing,
• What is NLP?

• NLP stands for Natural Language


Processing, which is a part of
Computer Science, Human language,
and Artificial Intelligence. It is the
technology that is used by machines to
understand, analyse, manipulate, and
interpret human's languages. It helps
developers to organize knowledge for
performing tasks such as translation,
automatic summarization, Named
Entity Recognition (NER), speech
recognition, relationship extraction,
and topic segmentation.
• Advantages of NLP
• NLP helps users to ask questions about any subject and get a direct response
within seconds.
• NLP offers exact answers to the question means it does not offer unnecessary and
unwanted information.
• NLP helps computers to communicate with humans in their languages.
• It is very time efficient.
• Most of the companies use NLP to improve the efficiency of documentation
processes, accuracy of documentation, and identify the information from large
databases.
• Disadvantages of NLP
• A list of disadvantages of NLP is given below:
• NLP may not show context.
• NLP is unpredictable
• NLP may require more keystrokes.
• NLP is unable to adapt to the new domain, and it has a limited function that's why
NLP is built for a single and specific task only.
Components of NLP

• There are the following two components of NLP -


• 1. Natural Language Understanding (NLU)
• Natural Language Understanding (NLU) helps the machine to understand
and analyse human language by extracting the metadata from content
such as concepts, entities, keywords, emotion, relations, and semantic
roles.
• NLU mainly used in Business applications to understand the customer's
problem in both spoken and written language.
• NLU involves the following tasks -
• It is used to map the given input into useful representation.
• It is used to analyze different aspects of the language.
• 2. Natural Language Generation (NLG)
• Natural Language Generation (NLG) acts as a translator that converts the
computerized data into natural language representation. It mainly involves
Text planning, Sentence planning, and Text Realization.
Applications of NLP

• There are the following applications of NLP -


• 1. Question Answering
• Question Answering focuses on building systems that automatically answer the
questions asked by humans in a natural language.
• 2. Spam Detection
• Spam detection is used to detect unwanted e-mails getting to a user's inbox.
• 3. Sentiment Analysis
• Sentiment Analysis is also known as opinion mining. It is used on the web to
analyse the attitude, behaviour, and emotional state of the sender. This application
is implemented through a combination of NLP (Natural Language Processing) and
statistics by assigning the values to the text (positive, negative, or natural), identify
the mood of the context (happy, sad, angry, etc.)
• 4. Machine Translation
• Machine translation is used to translate text or speech from one natural language
to another natural language.
• 5. Spelling correction
• Microsoft Corporation provides word processor software like MS-word, PowerPoint for the spelling
correction.
• 6. Speech Recognition
• Speech recognition is used for converting spoken words into text. It is used in applications, such as
mobile, home automation, video recovery, dictating to Microsoft Word, voice biometrics, voice user
interface, and so on.
• 7. Chatbot
• Implementing the Chatbot is one of the important applications of NLP. It is used by many
companies to provide the customer's chat services.
• 8. Information extraction
• Information extraction is one of the most important applications of NLP. It is used for extracting
structured information from unstructured or semi-structured machine-readable documents.
• 9. Natural Language Understanding (NLU)
• It converts a large set of text into more formal representations such as first-order logic structures
that are easier for the computer programs to manipulate notations of the natural language
processing.
Phases of NLP

• There are the following five phases of NLP:


• 1. Lexical Analysis and Morphological
• The first phase of NLP is the Lexical Analysis. This phase scans the source
code as a stream of characters and converts it into meaningful lexemes. It
divides the whole text into paragraphs, sentences, and words.
• 2. Syntactic Analysis (Parsing)
• Syntactic Analysis is used to check grammar, word arrangements, and shows
the relationship among the words.
• Example: Agra goes to the Poonam
• In the real world, Agra goes to the Poonam, does not make any sense, so this
sentence is rejected by the Syntactic analyzer.
• 3. Semantic Analysis
• Semantic analysis is concerned with the meaning representation. It mainly
focuses on the literal meaning of words, phrases, and sentences.
• 4. Discourse Integration
• Discourse Integration depends upon the sentences that proceeds it and also
invokes the meaning of the sentences that follow it.
• 5. Pragmatic Analysis
• Pragmatic is the fifth and last phase of NLP. It helps you to discover the
intended effect by applying a set of rules that characterize cooperative
dialogues.
• For Example: "Open the door" is interpreted as a request instead of an order.
LP Libraries

• NScikit-learn: It provides a wide range of algorithms for building


machine learning models in Python.
• Natural language Toolkit (NLTK): NLTK is a complete toolkit for all
NLP techniques.
• Pattern: It is a web mining module for NLP and machine learning.
• TextBlob: It provides an easy interface to learn basic NLP tasks like
sentiment analysis, noun phrase extraction, or pos-tagging.
• Quepy: Quepy is used to transform natural language questions into
queries in a database query language.
• SpaCy: SpaCy is an open-source NLP library which is used for Data
Extraction, Data Analysis, Sentiment Analysis, and Text
Summarization.
• Gensim: Gensim works with large datasets and processes data
streams.
Natural Language Processing

• Natural Language Processing (NLP) is the branch of Artificial Intelligence and Computational
Linguistics and helps in interaction between the computer and natural languages.
• The common NLP tasks included in the software are sentence segmentation, part-of-speech tagging
and parsing.
• The different logical steps in NLP are:
Morphological analysis:
In this step, the punctuations are separated from the sentences.
Syntax analysis (Parsing):
It basically involves the stages of lexical analysis and grammar. The linear sequence of words are
transformed into structures and further specifies how words relate to each other.
Semantic analysis:
In this step, the meanings are assigned to the structures which are initially created in parsing.
Pragmatic analysis:
It involves re-interpretation of language , verification and generation of final output result.
Q.AI for Speech Recognition


• What Is A Speech Recognition System?

• A speech recognition system is a type of software that allows the user to
have their spoken words converted into written text in a computer
application such as a word processor or spreadsheet. The computer can
also be controlled by the use of spoken commands.

• Speech recognition software can be installed on a personal
computer of appropriate specification. The user speaks into a microphone
(a headphone microphone is usually supplied with the product). The
software generally requires an initial training and enrolment process in
order to teach the software to recognise the voice of the user. A voice
profile is then produced that is unique to that individual. This procedure
also helps the user to learn how to ‘speak’ to a computer.
• About

• When you dial the telephone number of a big
company, you are likely to hear the sonorous voice of a
cultured lady who responds to your call with great courtesy
saying “welcome to company X. Please give me the
extension number you want” .You pronounce the extension
number, your name, and the name of the person you want
to contact. If the called person accepts the call, the
connection is given quickly. This is artificial intelligence
where an automatic call-handling system is used without
employing any telephone operator.
• Working Of The System

• The voice input to the microphone produces an analogue speech signal.
An analogue to digital converter (ADC) converts this speech signal into binary
words that are compatible with digital computer. The converted binary version is
then stored in the system and compared with previously stored binary
representation of words and phrases.

• What Software Is Available?

• There are a number of publishers of speech recognition software. New and
improved versions are regularly produced, and older versions are often sold at
greatly reduced prices. Invariably, the newest versions require the most modern
computers of well above average specification. Using the software on a computer
with a lower specification means that it will run very slowly and may well be
impossible to use. There are two main types of speech recognition software:
discrete speech and continuous speech.
Acceptance And Rejection


• When the recognition engine processes an utterance, it returns a
result. The result can be either of two states: acceptance or rejection. An
accepted utterance is one in which the engine returns recognized text.
Whatever the caller says, the speech recognition engine tries very hard to
match the utterance to a word or phrase in the active grammar.

• Sometimes the match may be poor because the caller said
something that the application was not expecting, or the caller spoke
indistinctly. In these cases, the speech engine returns the closest match,
which might be incorrect. Some engines also return a confidence score
along with the text to indicate the likelihood that the returned text is
correct. Not all utterances that are processed by the speech engine are
accepted. Acceptance or rejection is flagged by the engine with each
processed utterance.
• By understanding the cognitive processes sur-rounding human
“acoustic memory” and process-ing, interface designers may be able to
integrate speech more effectively and guide users more suc- cessfully. By
appreciating the differences between human-human interaction and
human-computer interaction, designers may then be able to choose
appropriate applications for human use of speech with computers.

• Conclusion

• Speech recognition will revolutionize the way people conduct
business over the Web and will, ultimately, differentiate world-class e-
businesses. VoiceXML ties speech recognition and telephony together and
provides the technology with which businesses can develop and deploy
voice-enabled Web solutions TODAY! These solutions can greatly expand
the accessibility of Web-based self-service transactions to customers who
would otherwise not have access, and, at the same time, leverage a
business’ existing Web investments.
The Limits Of Speech Recognition


• To improve speech recognition applications, designers must
understand acoustic memory and prosody. Continued research and
development should be able to improve certain speech input,
output, and dialogue applications. Speech recognition and gen-
eration is sometimes helpful for environments that are hands-busy,
eyes-busy, mobility-required, or hostile and shows promise for
telephone-based ser-vices.

• Dictation input is increasingly accurate, but adoption
outside the disabled-user community has been slow compared to
visual interfaces. Obvious physical problems include fatigue from
speaking continuously and the disruption in an office filled with
people speaking.

Q.Robotics and Artificial Intelligence

• Robotics is a separate entity in Artificial Intelligence that helps study the


creation of intelligent robots or machines. Robotics combines electrical
engineering, mechanical engineering and computer science & engineering
as they have mechanical construction, electrical component and
programmed with programming language. Although, Robotics and
Artificial Intelligence both have different objectives and applications, but
most people treat robotics as a subset of Artificial Intelligence (AI). Robot
machines look very similar to humans, and also, they can perform like
humans, if enabled with AI.
• What is Artificial Intelligence?
• Artificial Intelligence is defined as the branch of Computer Science &
Engineering, which deals with creating intelligent machines that perform
like humans. Artificial Intelligence helps to enable machines to sense,
comprehend, act and learn human like activities. There are mainly 4 types
of Artificial Intelligence: reactive machines, limited memory, theory of
mind, and self-awareness.
What is a robot?
Components of Robot
• A robot is a machine that looks like a human, and
is capable of performing out of box actions and
replicating certain human movements
automatically by means of commands given to it
using programming. Examples: Drug Compounding
Robot, Automotive Industry Robots, Order Picking
Robots, Industrial Floor Scrubbers and Sage
Automation Gantry Robots, etc.
• Components of Robot
• Several components construct a robot, these
components are as follows:
• to achieve physical movements by converting
energy like electrical, hydraulic and air, etc.
Actuators can create linear as well as rotary
motion.
• Power Supply: It is an electrical device that
supplies electrical power to an electrical load. The
primary function of the power supply is to convert
electrical current to power the load.
• Electric Motors: These are the devices that convert
electrical energy into mechanical energy and are
required for the rotational motion of the machines.
• Actuators: Actuators are the devices that are responsible for moving and controlling a system or
machine. It helps
• Pneumatic Air Muscles: Air Muscles are soft pneumatic devices that are ideally best fitted for
robotics. They can contract and extend and operate by pressurized air filling a pneumatic bladder.
Whenever air is introduced, it can contract up to 40%.
• Muscles wire: These are made up of nickel-titanium alloy called Nitinol and are very thin in shape.
It can also extend and contract when a specific amount of heat and electric current is supplied into
it. Also, it can be formed and bent into different shapes when it is in its martensitic form. They can
contract by 5% when electrical current passes through them.
• Piezo Motors and Ultrasonic Motors: Piezoelectric motors or Piezo motors are the electrical
devices that receive an electric signal and apply a directional force to an opposing ceramic plate. It
helps a robot to move in the desired direction. These are the best suited electrical motors for
industrial robots.
• Sensor: They provide the ability like see, hear, touch and movement like humans. Sensors are the
devices or machines which help to detect the events or changes in the environment and send data
to the computer processor. These devices are usually equipped with other electronic devices. Similar
to human organs, the electrical sensor also plays a crucial role in Artificial Intelligence & robotics. AI
algorithms control robots by sensing the environment, and it provides real-time information to
computer processors.
Applications of Robotics

• Robotics have different application areas. Some of the important applications domains of robotics are as follows:
• Robotics in defence sectors: The defence sector is undoubtedly the one of the main parts of any country. Each
country wants their defence system to be strong. Robots help to approach inaccessible and dangerous zone during
war. DRDO has developed a robot named Daksh to destroy life-threatening objects safely. They help soldiers to
remain safe and deployed by the military in combat scenarios. Besides combat support, robots are also deployed
in anti-submarine operations, fire support, battle damage management, strike missions, and laying machines.
• Robotics in Medical sectors: Robots also help in various medical fields such as laparoscopy, neurosurgery,
orthopaedic surgery, disinfecting rooms, dispensing medication, and various other medical domains.
• Robotics in Industrial Sector: Robots are used in various industrial manufacturing industries such as cutting,
welding, assembly, disassembly, pick and place for printed circuit boards, packaging & labelling, palletizing,
product inspection & testing, colour coating, drilling, polishing and handling the materials.
Moreover, Robotics technology increases productivity and profitability and reduces human efforts, resulting from
lower physical strain and injury. The industrial robot has some important advantages, which are as follows:
– Accuracy
– Flexibility
– Reduced labour charge
– Low noise operation
– Fewer production damages
– Increased productivity rate.
• Robotics in Entertainment: Over the last decade, use of robots is
continuously getting increased in entertainment areas. Robots are being
employed in entertainment sector, such as movies, animation, games and
cartoons. Robots are very helpful where repetitive actions are required. A
camera-wielding robot helps shoot a movie scene as many times as
needed without getting tired and frustrated. A big-name Disney has
launched hundreds of robots for the film industry.
• Robots in the mining industry: Robotics is very helpful for various mining
applications such as robotic dozing, excavation and haulage, robotic
mapping & surveying, robotic drilling and explosive handling, etc. A mining
robot can solely navigate flooded passages and use cameras and other
sensors to detect valuable minerals. Further, robots also help in excavation
to detect gases and other materials and keep humans safe from harm and
injuries. The robot rock climbers are used for space exploration, and
underwater drones are used for ocean exploration.
AI technology used in Robotics

• Computer Vision
• Robots can also see, and this is possible by one of the popular Artificial Intelligence technologies
named Computer vision. Computer Vision plays a crucial role in all industries like health,
entertainment, medical, military, mining, etc.
• Computer Vision is an important domain of Artificial Intelligence that helps in extracting meaningful
information from images, videos and visual inputs and take action accordingly.
• Natural Language Processing
• NLP (Natural Languages Processing) can be used to give voice commands to AI robots. It creates a
strong human-robot interaction. NLP is a specific area of Artificial Intelligence that enables the
communication between humans and robots. Through the NLP technique, the robot can
understand and reproduce human language. Some robots are equipped with NLP so that we can't
differentiate between humans and robots.
• Similarly, in the health care sector, robots powered by Natural Language Processing may help
physicians to observe the decease details and automatically fill in EHR. Besides recognizing human
language, it can learn common uses, such as learn the accent, and predict how humans speak.
• Edge Computing
• Edge computing in robots is defined as a service provider of robot integration, testing, design and
simulation. Edge computing in robotics provides better data management, lower connectivity cost,
better security practices, more reliable and uninterrupted connection.
• Complex Event Process
• Complex event processing (CEP) is a concept that helps us to understand the processing of multiple events in real time. An
event is described as a Change of State, and one or more events combine to define a Complex event. The complex event
process is most widely used term in various industries such as healthcare, finance, security, marketing, etc. It is primarily
used in credit card fraud detection and also in stock marketing field.
• For example, the deployment of an airbag in a car is a complex event based on the data from multiple sensors in real-time.
This idea is used in Robotics, for example, Event-Processing in Autonomous Robot Programming.
• Transfer Learning and AI
• This is the technique used to solve a problem with the help of another problem that is already solved. In Transfer learning
technique, knowledge gained from solving one problem can be implement to solve related problem. We can understand it
with an example such as the model used for identifying a circle shape can also be used to identify a square shape.
• Transfer learning reuses the pre-trained model for a related problem, and only the last layer of the model is trained, which is
relatively less time consuming and cheaper. In robotics, transfer learning can be used to train one machine with the help of
other machines.
• Reinforcement Learning
• Reinforcement learning is a feedback-based learning method in machine learning that enables an
AI agent to learn and explore the environment, perform actions and learn automatically from
experience or feedback for each action. Further, it is also having feature of autonomously learn to
behave optimally through hit-and-trail action while interacting with the environment. It is primarily
used to develop the sequence of decisions and achieve the goals in uncertain and potentially
complex environment. In robotics, robots explore the environment and learn about it through hit
and trial. For each action, he gets rewarded (positive or negative). Reinforcement learning provides
Robotics with a framework to design and simulate sophisticated and hard-to-engineer behaviours.
• Affective computing
• Affective computing is a field of study that deals with developing systems that can identify,
interpret, process, and simulate human emotions. Affective computing aims to endow robots with
emotional intelligence to hope that robots can be endowed with human-like capabilities of
observation, interpretation, and emotion expression.
• Mixed Reality
• Mixed Reality is also an emerging domain. It is mainly used in the field of programming by
demonstration (PbD). PbD creates a prototyping mechanism for algorithms using a combination of
physical and virtual objects.
What are Artificially Intelligent
Robots?
• Artificial intelligent robots connect AI with robotics. AI robots are
controlled by AI programs and use different AI technologies, such as
Machine learning, computer vision, RL learning, etc. Usually, most
robots are not AI robots, these robots are programmed to perform
repetitive series of movements, and they don't need any AI to
perform their task. However, these robots are limited in
functionality.
• AI algorithms are necessary when you want to allow the robot to
perform more complex tasks.
• A warehousing robot might use a path-finding algorithm to navigate
around the warehouse. A drone might use autonomous navigation
to return home when it is about to run out of battery. A self-driving
car might use a combination of AI algorithms to detect and avoid
potential hazards on the road. All these are the examples of
artificially intelligent robots.
What are the advantages of integrating
Artificial Intelligence into robotics?

• The major advantages of artificially intelligent robots are social


care. They can guide people, especially come to aid for older
people, with chatbot like social skills and advanced processors.
• Robotics also helps in Agricultural industry with the help of
developing AI based robots. These robots reduce the farmer's
workload.
• In Military industry, Military bots can spy through speech and vision
detectors, along with saving lives by replacing infantry
• Robotics also employed in volcanoes, deep oceans, extremely cold
places, or even in space where normally humans can't survive.
• Robotics is also used in medical and healthcare industry as it can
also perform complex surgeries that have a higher risk of a mistake
by humans, but with a pre-set of instructions and added
Intelligence. AI integrated robotics could reduce the number of
casualties greatly.
Difference in Robot System and AI
Programs
• Here is the difference between Artificial Intelligence and Robots:
• 1. AI Programs
• Usually, we use to operate them in computer-simulated worlds.
• Generally, input is given in the form of symbols and rules.
• To operate this, we need general-purpose/Special-purpose
computers.
• 2. Robots
• Generally, we use robots to operate in the real physical world.
• Inputs are given in the form of the analogue signal or in the form of
the speech waveform.
• Also, to operate this, special hardware with sensors and effectors
are needed.
Q.What is perception in AI?

• Perception is a process to interpret, acquire, select and


then organize the sensory information that is captured
from the real world.
For example: Human beings have sensory receptors such as
touch, taste, smell, sight and hearing. So, the information
received from these receptors is transmitted to human
brain to organize the received information.
• According to the received information, action is taken by
interacting with the environment to manipulate and
navigate the objects.
• Perception and action are very important concepts in the
field of Robotics. The following figures show the complete
autonomous robot.
• There is one important difference between the
artificial intelligence program and robot. The AI
program performs in a computer stimulated
environment, while the robot performs in the
physical world.
For example:
In chess, an AI program can be able to make a
move by searching different nodes and has no
facility to touch or sense the physical world.
However, the chess playing robot can make a
move and grasp the pieces by interacting with the
physical world.
Alpha-Beta Pruning

• Alpha-beta pruning is a modified version of the minimax algorithm.


It is an optimization technique for the minimax algorithm.
• 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.
• 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.
• 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. The two-parameter can be defined as:
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 -∞.
• 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 +∞.
• 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.
Condition for Alpha-beta pruning:

• The main condition which required for alpha-beta


pruning is:
• The Max player will only update the value of
alpha.
• The Min player will only update the value of beta.
• While backtracking the tree, the node values will
be passed to upper nodes instead of values of
alpha and beta.
• We will only pass the alpha, beta values to the
child nodes.
Pseudo-code for Alpha-beta Pruning:
• function minimax(node, depth, alpha, beta, maximizingPlayer) is
• if depth ==0 or node is a terminal node then
• return static evaluation of node

• if MaximizingPlayer then // for Maximizer Player
• maxEva= -infinity
• for each child of node do
• eva= minimax(child, depth-1, alpha, beta, False)
• maxEva= max(maxEva, eva)
• alpha= max(alpha, maxEva)
• if beta<=alpha
• break
• return maxEva

• else // for Minimizer player
• minEva= +infinity
• for each child of node do
• eva= minimax(child, depth-1, alpha, beta, true)
• minEva= min(minEva, eva)
• beta= min(beta, eva)
• if beta<=alpha
• break
• return minEva
Working of Alpha-Beta Pruning

• 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.
• 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.
• 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.
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:
• 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).
• 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).
Rules to find good ordering:

• Following are some rules to find good ordering in


alpha-beta pruning:
• Occur the best move from the shallowest node.
• Order the nodes in the tree such that the best nodes
are checked first.
• Use domain knowledge while finding the best move.
Ex: for Chess, try order: captures first, then threats,
then forward moves, backward moves.
• We can bookkeep the states, as there is a possibility
that states may repeat.
Game Playing

• Adversarial search, or game-tree search, is a technique for analyzing an


adversarial game in order to try to determine who can win the game and
what moves the players should make in order to win. Adversarial search is
one of the oldest topics in Artificial Intelligence. The original ideas for
adversarial search were developed by Shannon in 1950 and independently
by Turing in 1951, in the context of the game of chess—and their ideas still
form the basis for the techniques used today.
• Person Games:
– Players: We call them Max and Min.
– Initial State: Includes board position and whose turn it is.
– Operators: These correspond to legal moves.
– Terminal Test: A test applied to a board position which determines whether
the game is over. In chess, for example, this would be a checkmate or
stalemate situation.
– Utility Function: A function which assigns a numeric value to a terminalstate.
For example, in chess the outcome is win (+1), lose (-1) or draw (0). Note that
by convention, we always measure utility relative to Max.
MiniMax Algorithm:

• Generate the whole game tree.


• Apply the utility function to leaf nodes to get their
values.
• Use the utility of nodes at level n to derive the utility of
nodes at level n-1.
• Continue backing up values towards the root (one layer
at a time).
• Eventually the backed up values reach the top of the
tree, at which point Max chooses the move that yields
the highest value. This is called the minimax decision
because it maximises the utility for Max on the
assumption that Min will play perfectly to minimise it.
Exmple:
Properties of minimax:

Complete : Yes (if tree is finite)


Optimal : Yes (against an optimal
opponent)
Time complexity : O(bm)
Space complexity : O(bm) (depth-first
exploration)
For chess, b ≈ 35, m ≈100 for "reasonable" games
à exact solution completely infeasible.
Limitations
Not always feasible to traverse entire tree
Time limitations
A Case Study on Artificial Intelligence

You might also like