Module III
Module III
• Adversarial Search:
– Game- mini max algorithms.
– AO * Search .
• Logic Agents:
– Knowledge based agents,
– Wampus world, logics.
Adversarial search
• Adversarial search is a search, where we examine the problem which arises when
we try to plan ahead of the world and other agents are planning against us.
• In previous topics, we have studied the search strategies which are only associated
with a single agent that aims to find the solution which often expressed in the form
of a sequence of actions.
• But, there might be some situations where more than one agent is searching for
the solution in the same search space, and this situation usually occurs in game
playing.
• The environment with more than one agent is termed as multi-agent environment,
in which each agent is an opponent of other agent and playing against each other.
Each agent needs to consider the action of other agent and effect of that action on
their performance.
• So, Searches in which two or more players with conflicting goals are trying to
explore the same search space for the solution, are called adversarial searches,
often known as Games.
• Games are modeled as a Search problem and heuristic evaluation function, and
these are the two main factors which help to model and solve games in AI.
Types of games
• Perfect information: A game with the perfect information is that in which
agents can look into the complete board. Agents have all the information
about the game, and they can see each other moves also. Examples are
Chess, Checkers, Go, etc.
• Imperfect information: If in a game agents do not have all information about
the game and not aware with what's going on, such type of games are called
the game with imperfect information, such as tic-tac-toe, Battleship, blind,
Bridge, etc.
• Deterministic games: Deterministic games are those games which follow a
strict pattern and set of rules for the games, and there is no randomness
associated with them. Examples are chess, Checkers, Go, tic-tac-toe, etc.
• Non-deterministic games: Non-deterministic are those games which have
various unpredictable events and has a factor of chance or luck. This factor
of chance or luck is introduced by either dice or cards. These are random,
and each action response is not fixed. Such games are also called as
stochastic games.
Example: Backgammon, Monopoly, Poker, etc.
Formalization of the problem
• A game can be defined as a type of search in AI which can be formalized of the
following elements:
– Initial state: It specifies how the game is set up at the start.
– Player(s): It specifies which player has moved in the state space.
– Action(s): It returns the set of legal moves in state space.
– Result(s, a): It is the transition model, which specifies the result of
moves in the state space.
– Terminal-Test(s): Terminal test is true if the game is over, else it is
false at any case. The state where the game ends is called terminal
states.
– Utility(s, p): A utility function gives the final numeric value for a
game that ends in terminal states s for player p. It is also called
payoff function. For Chess, the outcomes are a win, loss, or draw
and its payoff values are +1, 0, ½. And for tic-tac-toe, utility values
are +1, -1, and 0.
Game tree
• A game tree is a tree where nodes of the tree are the game states and Edges
of the tree are the moves by players. Game tree involves initial state, actions
function, and result Function.
AND-OR Graph
– Node in the graph will point both down to its successors and up to its parent
nodes.
– Each Node in the graph will also have a heuristic value associated with it.
f(n)=g(n)+h(n)
f(n): Cost function. g(n): Actual cost or Edge value h(n): Heuristic/ Estimated
value of the node
• AO* Algorithm
1. Initialise the graph to start node
2. Traverse the graph following the current path accumulating nodes
that have not yet been expanded or solved
3. Pick any of these nodes and expand it and if it has no successors
call this value FUTILITY otherwise calculate only f` for each of the
successors.
4. If f` is 0 then mark the node as SOLVED
5. Change the value of f` for the newly created node to reflect its
successors by back propagation.
6. Wherever possible use the most promising routes and if a node is
marked as SOLVED then mark the parent node as SOLVED.
7. If starting node is SOLVED or value greater than FUTILITY, stop, else
repeat from 2
Ch-II: Knowledge representation issues
What is knowledge representation?
Humans are best at understanding, reasoning, and interpreting knowledge. Human knows
things, which is knowledge and as per their knowledge they perform various actions in the
real world. But how machines do all these things comes under knowledge representation and
reasoning.
• In order to solve complex problems encountered in artificial intelligence, one needs both a large
amount of knowledge and some mechanism for manipulating that knowledge to create solutions.
• Knowledge and Representation are two distinct entities. They play central but distinguishable
roles in the intelligent system.
• Knowledge is a description of the world. It determines a system’s competence by what it
knows.
• Moreover, Representation is the way knowledge is encoded. It defines a system’s performance
in doing something.
• Different types of knowledge require different kinds of representation.
Representation & Mapping:
A variety of ways of representing knowledge (facts) have been exploited in AI programs. In all
variety of knowledge representations , we deal with two kinds of entities.
A. Facts: Truths in some relevant world. These are the things we want to represent.
B. Representations : Things we can manipulate.
Example:
sky is blue sky(blue)
The facts and representations are linked with two-way mappings. This link is called
representation mappings.
The backward representation mapping goes the other way, from representations to facts.
• Forward and backward representation are elaborated below:
1 4
2 3
• Example:
Is a Class
Crickter
Is a Is a
values Middle
opener
order
– Inferential knowledge:
• Represent knowledge in the form of formal logic.
• Logic can predicate or propositional logic.
• At what level of details the knowledge should be presented & what should be our
primitive.
4. Representing set of objects:
• There are certain properties of an object which are true as member of set but not as
individual.
• Ex: a person is very strict at a company but he is very calm at his home.
5. Finding right structure as needed:
• The structure of knowledge refers to how the information is organized, linked, and
represented so that it can be stored, accessed, and reasoned with effectively.
Ch-III: Logic Agents
Knowledge based agents:
What is agents?
An agent is anything that can perceive its environment through sensor
and acts upon that environment through effectors.
Intelligent agent?
An intelligent agent is one that is capable of flexible autonomous action
in order to meet its design objectives, where flexible means three things:
• Reactivity: agents are able to perceive their environment, & respond in a
timely.
• Pro-activeness: intelligent agents are able to exhibits goal-directed behavior
by taking the initiative in order to satisfy their design objectives.
• Social ability: agents capable of interacting with other agents in order to
satisfy their design objectives.
• knowledge-based agents are composed of two main parts:
– Knowledge-base and
– Inference system.
• Knowledge-base and
A knowledge-based agent must able to do the following:
– An agent should be able to represent states, actions, etc.
– An agent Should be able to incorporate new percepts
– An agent can update the internal representation of the world
– An agent can work out the internal representation of the world
– An agent can deduce appropriate actions.
• Inference system
– Inference means deriving new sentences from old. Inference system allows us to add a new
sentence to the knowledge base. A sentence is a proposition about the world. Inference
system applies logical rules to the KB to deduce new information.
– Inference system generates new facts so that an agent can update the KB. An inference
system works mainly in two rules which are given as:
• Forward chaining
• Backward chaining
Inference in AI: Inference is the process of deriving new information from known facts and rules.
We typically use rules in the format:
IF condition THEN action/conclusion
Forward Chaining (Data-driven reasoning): Starts with known facts and applies rules to infer
new facts, continuing until a goal is reached or no more rules apply.
How it works:
• Match known facts with IF conditions of rules.
• Set the rules whose conditions are satisfied.
• Add the THEN part (conclusion) to the fact base.
• Repeat until the desired goal is derived (or nothing more can be inferred).
Backward Chaining: Starts with a goal or hypothesis and works backwards to see if known facts
support it.
How it works:
• Start with the goal.
• Look for rules whose THEN part matches the goal.
• Try to prove the IF conditions of those rules.
• Repeat the process until you reach known facts.
Forward Chaining Example:
Rules:
• IF sky is cloudy THEN it might rain
• IF it might rain THEN take umbrella
Facts:
Sky is cloudy
• Forward chaining result: → It might rain
→ Take umbrella
• Suitable for diagnostic systems, prediction, etc.