AI Unit 3 PDF
AI Unit 3 PDF
com
Acuity Educare
Artificial Intelligence
SEM : V
SEM V: UNIT 3
Answer:
1. Multiagent environments in an environment in which each agent needs to consider the actions of
other agents and how they affect its own welfare. The unpredictability of these other agents can
introduce contingencies into the agent’s problem-solving process. Competitive environments, in
which the agents goals are in conflict, giving rise to adversarial search problems—often known
as games.
2. Mathematical game theory, a branch of economics, 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.
3. In AI, the most common games are of a rather specialized kind—what game theorists call
deterministic, turn-taking, two-player, zero-sum games of perfect information (such as chess). In
our terminology, this means deterministic, fully observable environments in which two agents act
alternately and in which the utility values at the end of the game are always equal and opposite.
For example, if one player wins a game of chess, the other player necessarily loses. It is this
opposition between the agents’ utility functions that makes the situation adversarial.
4. The state of a game is easy to represent, and agents are usually restricted to a small number of
actions whose outcomes are defined by precise rules. Games are interesting because they are
too hard to solve. For example, chess has an average branching factor of about 35, and games
often go to 50 moves by each player, so the search tree has about 35100 or 10154 nodes
(although the search graph has ―only‖ about 1040 distinct nodes). Games, like the real world,
therefore require the ability to make some decision even when calculating the optimal decision
is infeasible. Games also penalize inefficiency severely. Whereas an implementation of A∗
search that is half as efficient will simply take twice as long to run to completion, a chess
program that is half as efficient in using its available time probably will be beaten into the
ground, other things being equal. Game-playing research has therefore spawned a number of
interesting ideas on how to make the best possible use of time.
5. Pruning allows us to ignore portions of the search tree that make no difference to the final choice,
and heuristic evaluation functions allow us to approximate the true utility of a state without doing a
complete search.
6. We first consider games with two players, whom we call MAX and MIN for reasons that will soon
become obvious. MAX moves first, and then they take turns moving until the game is over. At the
end of the game, points are awarded to the winning player and penalties are given to the loser. A
game can be formally defined as a kind of search problem with the following elements:
Page 1 of 11
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V AI: U 3
Answer:
1. In a normal search problem, the optimal solution would be a sequence of actions leading to a
goal state—a terminal state that is a win. In adversarial search, MIN has something to say about
it. MAX therefore must find a contingent strategy, which specifies MAX’s move in the initial state,
then MAX’s moves in the states resulting from every possible response by MIN, then MAX’s
moves in the states resulting from every possible response by MIN to those moves, and so on.
This is exactly analogous to the AND–OR search algorithm with MAX playing the role of OR and
MIN equivalent to AND. Roughly speaking, an optimal strategy leads to outcomes at least as
good as any other strategy when one is playing an infallible opponent.
2. Even a simple game like tic-tac-toe is too complex for us to draw the entire game tree on one
page, so we will switch to the trivial game in Figure 5.2. The possible moves for MAX at the root
node are labeled a1, a2, and a3. The possible replies to a1 for MIN are b1, b2, b3, and so on.
This particular game ends after one move each by MAX and MIN. (In game parlance, we say that
this tree is one move deep, consisting of two half-moves, each of which is called a ply.) The
utilities of PLY the terminal states in this game range from 2 to 14.
3. Given a game tree, the optimal strategy can be determined from the minimax value of each
node, which we write as MINIMAX(n). The minimax value of a node is the utility (for MAX) of
being in the corresponding state, assuming that both players play optimally from there to the end
of the game. Obviously, the minimax value of a terminal state is just its utility. Furthermore, given
a choice, MAX prefers to move to a state of maximum value, whereas MIN prefers a state of
minimum value. So we have the following:
Page 2 of 11
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V AI: U 3
Answer:
1. Many popular games allow more than two players. Let us examine how to extend the minimax
idea to multiplayer games. This is straightforward from the technical viewpoint, but raises some
interesting new conceptual issues.
2. First, we need to replace the single value for each node with a vector of values. For example, in
a three-player game with players A, B, and C, a vector (vA, vB, vC) is associated with each
node. For terminal states, this vector gives the utility of the state from each player’s viewpoint. (In
two- player, zero-sum games, the two-element vector can be reduced to a single value because
the values are always opposite.) The simplest way to implement this is to have the UTILITY
function return a vector of utilities.
3. Now we have to consider nonterminal states. Consider the node marked X in the game tree
shown in diagram. In that state, player C chooses what to do. The two choices lead to terminal
states with utility vectors (vA =1, vB =2, vC =6) and (vA =4, vB =2, vC =3). Since 6 is bigger than
3, C should choose the first move. This means that if state X is reached, subsequent play will
lead to a terminal state with utilities (vA =1, vB =2, vC =6). Hence, the backed-up value of X is
this vector. The backed-up value of a node n is always the utility
4. Now we have to consider nonterminal states. Consider the node marked X in the game tree
shown in Figure 5.4. In that state, player C chooses what to do. The two choices lead to terminal
states with utility vectors (vA =1, vB =2, vC =6) and (vA =4, vB =2, vC =3). Since 6 is bigger than
3, C should choose the first move. This means that if state X is reached, subsequent play will lead
to a terminal state with utilities (vA =1, vB =2, vC =6). Hence, the backed-up value of X is this
vector. The backed-up value of a node n is always the utility vector of the successor state with
the highest value for the player choosing at n
5. Multiplayer ALLIANCE games usually involve alliances, whether formal or informal, among the
players. Alliances are made and broken as the game proceeds. How are we to understand such
behavior? Are alliances a natural consequence of optimal strategies for each player in a
multiplayer game? It turns out that they can be. For example, suppose A and B are in weak
positions and C is in a stronger position. Then it is often optimal for both A and B to attack C
rather than each other, lest C destroy each of them individually. In this way, collaboration
emerges from purely selfish behavior. Of course, as soon as C weakens under the joint
onslaught, the alliance loses its value, and either A or B could violate the agreement.
6. If the game is not zero-sum, then collaboration can also occur with just two players. Suppose, for
example, that there is a terminal state with utilities (vA =1000, vB =1000) and that 1000 is the
highest possible utility for each player. Then the optimal strategy is for both players to do
everything possible to reach this state—that is, the players will automatically cooperate to
achieve a mutually desirable goal.
Page 3 of 11
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V AI: U 3
Answer:
1. The problem with minimax search is that the number of game states it has to examine is
exponential in the depth of the tree. Unfortunately, we can’t eliminate the exponent, but it turns
out we can effectively cut it in half. The trick is that it is possible to compute the correct minimax
decision without looking at every node in the game tree. That is, we can borrow the idea of
pruning to eliminate large parts of the tree from consideration. The particular technique we
examine is called alpha–beta pruning. When applied to a standard minimax tree, it returns the
same move as minimax would, but prunes away branches that cannot possibly influence the
final decision.
2. Consider again the two-ply game tree. Let’s go through the calculation of the optimal decision
once more, this time paying careful attention to what we know at each point in the process.
The outcome is that we can identify the minimax decision without ever evaluating two of the
leaf nodes. Another way to look at this is as a simplification of the formula for MINIMAX. Let
the two unevaluated successors of node C in following diagram have values x and y. Then
the value of the root node is given by
3. In other words, the value of the root and hence the minimax decision are independent of the
values of the pruned leaves x and y. Alpha–beta pruning can be applied to trees of any depth,
and it is often possible to prune entire subtrees rather than just leaves. The general principle is
this: consider a node n somewhere in the tree such that Player has a choice of moving to that
node.
4. Remember that minimax search is depth-first, so at any one time we just have to consider the
nodes along a single path in the tree. Alpha–beta pruning gets its name from the following two
parameters that describe bounds on the backed-up values that appear anywhere along the
path:
Page 4 of 11
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V AI: U 3
Answer:
1. In real life, many unpredictable external events can put us into unforeseen situations. Many
games mirror this unpredictability by including a random element, such as the throwing of dice.
We call these stochastic games. Backgammon is a typical game that combines luck and skill.
Dice are rolled at the beginning of a player’s turn to determine the legal moves.
2. Although White knows what his or her own legal moves are, White does not know what Black is
going to roll and thus does not know what Black’s legal moves will be. That means White cannot
construct a standard game tree of the sort we saw in chess and tic-tac-toe. A game tree in
backgammon must include chance nodes in addition to MAX and MIN nodes.
3. The next step is to understand how to make correct decisions. Obviously, we still want to pick
the move that leads to the best position. However, positions do not have definite minimax values.
Instead, we can only calculate the expected value of a position: the average over all possible
outcomes of the chance nodes.
4. This leads us to generalize the minimax value for deterministic games to an expecti- minimax
value for games with chance nodes. Terminal nodes and MAX and MIN nodes (for which the
dice roll is known) work exactly the same way as before. For chance nodes we compute the
expected value, which is the sum of the value over all outcomes, weighted by the probability of
each chance action:
5. The branches leading from each chance node denote the possible dice rolls; each branch is
labeled with the roll and its probability. There are 36 ways to roll two dice, each equally likely;
but because a 6–5 is the same as a 5–6, there are only 21 distinct rolls. The six doubles (1–1
through 6–6) each have a probability of 1/36, so we say P(1–1) = 1/36. The other 15 distinct
rolls each have a 1/18 probability.
Page 5 of 11
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V AI: U 3
Answer:
1. Chess:
IBM’s DEEP BLUE chess program, now retired, is well known for defeating world
champion Garry Kasparov in a widely publicized exhibition match. Deep Blue ran on a
parallel computer with 30 IBM RS/6000 processors doing alpha–beta search. The unique
part was a configuration of 480 custom VLSI chess processors that performed move
generation and move ordering for the last few levels of the tree, and evaluated the leaf
nodes. Deep Blue searched up to 30 billion positions per move, reaching depth 14
routinely. HYDRA can be seen as the successor to DEEP BLUE. HYDRA runs on a 64-
processor cluster with 1 gigabyte per processor and with custom hardware in the form of
FPGA (Field Programmable Gate Array) chips. HYDRA reaches 200 million evaluations
per second, about the same as Deep Blue.
2. Checkers:
Jonathan Schaeffer and colleagues developed CHINOOK, which runs on regular PCs
and uses alpha–beta search. Chinook defeated the long-running human champion in an
abbreviated match in 1990, and since 2007 CHINOOK has been able to play perfectly by
using alpha–beta search combined with a database of 39 trillion endgame positions.
3. Othello :
Othello, also called Reversi, is probably more popular as a computer game than as a
board game. It has a smaller search space than chess, usually 5 to 15 legal moves, but
evaluation expertise had to be developed from scratch. In 1997, the LOGISTELLO
program (Buro, 2002) defeated the human world champion, TakeshiMurakami, by six
games to none. It is generally acknowledged that humans are no match for computers at
Othello.
4. Backgammon:
The inclusion of uncertainty from dice rolls makes deep search an expensive luxury. Most
work on backgammon has gone into improving the evaluation function. Gerry Tesauro
(1992) combined reinforcement learning with neural networks to develop a remarkably
accurate evaluator that is used with a search to depth 2 or 3. After playing more than a
million training games against itself, Tesauro’s program, TD-GAMMON, is competitive
with top human players. The program’s opinions on the opening moves of the game have
in some cases radically altered the received wisdom.
5. Bridge :
Bridge is a card game of imperfect information: a player’s cards are hidden from the
other players. Bridge is also a multiplayer game with four players instead of two,
although the players are paired into two teams. As in Section 5.6, optimal play in partially
observable games like bridge can include elements of information gathering,
communication, and careful weighing of probabilities. Many of these techniques are used
in the Bridge Baron program (Smith et al., 1998), which won the 1997 computer bridge
championship. While it does not play optimally, Bridge Baron is one of the few successful
game-playing systems to use complex, hierarchical plans
6. Scrabble:
Most people think the hard part about Scrabble is coming up with good words, but given the official
Page 6 of 11
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V AI: U 3
dictionary, it turns out to be rather easy to program a move generator to find the highest- scoring
move (Gordon, 1994). That doesn’t mean the game is solved, however: merely taking the top-
scoring move each turn results in a good but not expert player. The problem is that Scrabble is both
partially observable and stochastic: you don’t know what letters the other player has or what letters
you will draw next. So playing Scrabble well combines the difficulties of backgammon and bridge.
Answer:
1. Humans, it seems, know things; and what they know helps them do things. These are not empty
statements. They make strong claims about how the intelligence of humans is achieved—not by
purely reflex mechanisms but by processes of reasoning that operate on internal representations
of knowledge. In AI, this approach to intelligence is embodied in knowledge-based agents.
2. The problem-solving agents know things, but only in a very limited, inflexible sense. For
example, the transition model for the 8-puzzle—knowledge of what the actions do—is hidden
inside the domain-specific code of the RESULT function.
3. The idea of representing states as assignments of values to variables; this is a step in the right
direction, enabling some parts of the agent to work in a domain-independent way and allowing
for more efficient algorithms. We develop logic as a general class of representations to
support knowledge-based agents.
4. Such agents can combine and recombine information to suit myriad purposes. Often, this
process can be quite far removed from the needs of the moment—as when a mathematician
proves a theorem or an astronomer calculates the earth’s life expectancy. Knowledge-based
agents can accept new tasks in the form of explicitly described goals; they can achieve
competence quickly by being told or learning new knowledge about the environment; and they
can adapt to changes in the environment by updating the relevant knowledge.
Answer:
1. The central component of a knowledge-based agent is its knowledge base, or KB. A knowledge
base is a set of sentences. (Here ―sentence‖ is used as a technical term. It is related but not
identical to the sentences of English and other natural languages.) Each sentence is expressed
in a language called a knowledge representation language and represents some assertion about
the world. Sometimes we dignify a sentence with the name axiom, when the sentence is taken
as given without being derived from other sentences.
2. There must be a way to add new sentences to the knowledge base and a way to query what is
known. The standard names for these operations are TELL and ASK, respectively. Both
operations may involve inference—that is, deriving new sentences from old. Inference must
obey the requirement that when one ASKs a question of the knowledge base, the answer should
followfrom what has been told (or TELLed) to the knowledge base previously.
3. Following diagram shows the outline of a knowledge-based agent program. Like all our agents, it
takes a percept as input and returns an action. The agent maintains a knowledge base, KB,
which may initially contain some background knowledge.
Page 7 of 11
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V AI: U 3
5. A knowledge-based agent can be built simply by TELLing it what it needs to know. Starting with an
empty knowledge base, the agent designer can TELL sentences one by one until the agent knows
how to operate in its environment. This is called the declarative approach to system building. In
contrast, the procedural approach encodes desired behaviors directly as program code. We now
understand that a successful agent often combines both declarative and procedural elements in its
design, and that declarative knowledge can often be compiled into more efficient procedural code.
We can also provide a knowledge-based agent with mechanisms that allow it to learn for itself.
Answer
A 4×4 grid of rooms. The agent always starts in the square labeled [1,1], facing to
the right. The locations of the gold and the wumpus are chosen randomly, with a
uniform distribution, from the squares other than the start square. In addition, each
square other than the start can be a pit, with probability 0.2.
c) Actuators:
The agent can move Forward, TurnLeft by 90◦, or TurnRight by 90◦. The agent dies a
miserable death if it enters a square containing a pit or a live wumpus. (It is safe, albeit smelly,
to enter a square with a dead wumpus.) If an agent tries to move forward and bumps into a
wall, then the agent does not move. The action Grab can be used to pick up the gold if it is in
the same square as the agent. The action Shoot can be used to fire an arrow in a straight line
in the direction the agent is facing. The arrow continues until it either hits (and hence kills) the
wumpus or hits a wall. The agent has only one arrow, so only the first Shoot action has any
effect. Finally, the action Climb can be used to climb out of the cave, but only from square [1,1].
d) Sensors: The agent has five sensors, each of which gives a single bit of information
In the square containing the wumpus and in the directly (not diagonally) adjacent squares,
the agent will perceive a Stench.
In the squares directly adjacent to a pit, the agent will perceive a Breeze.
In the square where the gold is, the agent will perceive a Glitter.
When an agent walks into a wall, it will perceive a Bump.
When the wumpus is killed, it emits a woeful Scream that can be perceived anywhere in the
cave.
3. Steps:
a) The agent’s initial knowledge base contains the rules of the environment, as described
previously; in particular, it knows that it is in [1,1] and that [1,1] is a safe square; we denote that
with an ―A‖ and ―OK,‖ respectively, in square [1,1].
b) The first percept is [None, None, None, None, None], from which the agent can conclude that its
neighboring squares, [1,2] and [2,1], are free of dangers—they are OK.
c) A cautious agent will move only into a square that it knows to be OK. Let us suppose the agent
decides to move forward to [2,1]. The agent perceives a breeze (denoted by ―B‖) in [2,1], so
there must be a pit in a neighboring square. The pit cannot be in [1,1], by the rules of the game,
so there must be a pit in [2,2] or [3,1] or both. The notation ―P?‖ indicates a possible pit in those
squares. At this point, there is only one known square that is OK and that has not yet been
visited. So the prudent agent will turn around, go back to [1,1], and then proceed to [1,2].
d) The agent perceives a stench in [1,2], resulting in the state of knowledge . The stench in [1,2]
means that there must be a wumpus nearby. But the wumpus cannot be in [1,1], by the rules of
the game, and it cannot be in [2,2] (or the agent would have detected a stench when it was in
[2,1]). Therefore, the agent can infer that the wumpus is in [1,3]. The notation W! indicates this
inference. Moreover, the lack of a breeze in [1,2] implies that there is no pit in [2,2]. Yet the
agent has already inferred that there must be a pit in either [2,2] or [3,1], so this means it must
be in [3,1]. This is a fairly difficult inference, because it combines knowledge gained at different
times in different places and relies on the lack of a percept to make one crucial step.
e) The agent has now proved to itself that there is neither a pit nor a wumpus in [2,2], so it is OK to
move there.
Page 9 of 11
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V AI: U 3
Answer:
1. Knowledge bases consist of sentences. These sentences are expressed according to the syntax
of the representation language, which specifies all the sentences that are well formed. The notion
of syntax is clear enough in ordinary arithmetic: ―x + y = 4‖ is a well-formed sentence, whereas
―x4y+ =‖ is not.
2. A logic must also define the semantics or meaning of sentences. The semantics defines the truth
of each sentence with respect to each possible world. For example, the semantics for arithmetic
specifies that the sentence ―x + y =4‖ is true in a world where x is 2 and y is 2, but false in a world
where x is 1 and y is 1. In standard logics, every sentence must be either true or false in each
possible world—there is no ―in between.| 1
3. When we need to be precise, we use the term model in place of ―possible world.‖ Whereas
possible worlds might be thought of as (potentially) real environments that the agent might or
might not be in, models are mathematical abstractions, each of which simply fixes the truth or
falsehood of every relevant sentence.
4. Now that we have a notion of truth, we are ready to talk about logical reasoning. This involves
the relation of logical entailment between sentences—the idea that a sentence follows logically
from another sentence. In mathematical notation, we write α |= β to mean that the sentence α
entails the sentence β. The formal definition of entailment is this: α |= β if and only if, in every
model in which α is true, β is also true. Using the notation just introduced, we can write
α |= β if and only if M(α) ⊆ M(β) .
5. An inference algorithm that derives only entailed sentences is called sound or truth preserving.
Soundness is a highly desirable property. An unsound inference procedure essentially makes
things up as it goes along—it announces the discovery of nonexistent needles. It is easy to see
that model checking, when it is applicable is a sound procedure. The property of completeness is
also desirable: an inference algorithm is complete if it can derive any sentence that is entailed.
For real haystacks, which are finite in extent, it seems obvious that a systematic examination can
always decide whether the needle is in the haystack. For many knowledge bases, however, the
haystack of consequences is infinite, and completeness becomes an important issue.5
Fortunately, there are complete inference procedures for logics that are sufficiently expressive to
handle many knowledge bases.
6. The final issue to consider is grounding—the connection between logical reasoning processes
and the real environment in which the agent exists. In particular, how do we know that KB is true
in the real world? (After all, KB is just ―syntax‖ inside the agent’s head.) This is a philosophical
question. A simple answer is that the agent’s sensors create the connection. For example, our
wumpus-world agent has a smell sensor. The agent program creates a suitable sentence
whenever there is a smell. Then, whenever that sentence is in the knowledge base, it is true in
the real world.
Page 10 of 11
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V AI: U 3
Answer:
1. The syntax of propositional logic defines the allowable sentences. The atomic sentences consist
of a single proposition symbol. Each such symbol stands for a proposition that can be true or
false. We use symbols that start with an uppercase letter and may contain other letters or
subscripts, for example: P, Q, R, W 1,3 and North. The names are arbitrary but are often chosen
to have some mnemonic value—we use W1,3 to stand for the proposition that the wumpus is in
[1,3]. Remember that symbols such as W1,3 are atomic, i.e., W, 1, and 3 are not meaningful
parts of the symbol. There are two proposition symbols with fixed meanings: True is the always-
true proposition and False is the always-false proposition.
2. Complex sentences are constructed from simpler sentences, using parentheses and logical
connectives. There are five connectives in common use:
3. The BNF grammar by itself is ambiguous; a sentence with several operators can be parsed by
thegrammar in multiple ways. To eliminate the ambiguity we define a precedence for each
operator.
The ―not‖ operator (¬) has the highest precedence, which means that in the sentence ¬A ∧ B
the ¬ binds most tightly, giving us the equivalent of (¬A)∧B rather than ¬(A∧B).
(The notation for ordinary arithmetic is the same: −2+4 is 2, not –6.) When in doubt, use
parentheses to make sure of the right interpretation. Square brackets mean the same
thing as parentheses; the choice of square brackets or parentheses is solely to make it
easier for a human to read a sentence.
Page 11 of 11
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622