0% found this document useful (0 votes)
29 views13 pages

Name Umer Hussain Qidwai REGNO 40274 Course Artifical Intelligence Theory DR - Aarij Mehmood

Uploaded by

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

Name Umer Hussain Qidwai REGNO 40274 Course Artifical Intelligence Theory DR - Aarij Mehmood

Uploaded by

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

NAME =UMER HUSSAIN QIDWAI

REGNO= 40274
COURSE = ARTIFICAL INTELLIGENCE
THEORY
DR.AARIJ MEHMOOD
QUESTION 1

1 .PEAS DESCRIPTION OF AN AGENT:

Find a path between the starting cell and the goal cell in as low of a cost as possible. However,
the grid has special cells marked as ‘W’ and ‘X’, if your agent moves to the ‘W’ cell, then the
agent will be teleported a cell (randomly selected) next to the goal state, but the cost will be
‘+7… the Environment of this grid is 7 x8 and start Cell And goal state with a low Cost Special
Cell Mark W and X.. User required moving the path from one cell to another cell to make the
best decision

1. DESCRIBE TASK ENVIRONMENT OF THE GIVEN SCENERIO:

ACCESIBLE / INACCESIBLE: All the possible states and moves are clearly in front of an
agent i.e the agent can see all the situation of the environment at all times. Therefore this
scenario is ACCESIBLE.

DETERMINISTIC / NON DETERMINISTIC: The given scenario is fully deterministic


because the next state of the grid is completely known by the move of the agent.

EPISODIC / NON EPISODIC: All the moves taken by an agent fully depends upon the moves
taken by the agent previously. Hence this scenario is non episodic / sequential.

STATIC / DYNAMIC: The given scenario is static because the grid remains same on every
move/step taken by the agent.

DISCRETE / CONTINOUS: The given problem is discrete as it contains a limited number of


states in its grid. Thus it is discrete.

3.MODEL THIS PROBLEM AS A SEARCH PROBLEM:?

The search strategy contains the evaluation of any given state until the agent does not move to
the goal state or there are no more states left to evaluate.

INITIAL STATE: The agent who is this problem must be fully aware of the starting / initial
state before it start its search so that is can keep track on all the moves it searches.

OPERATOR: An operator is a function taking an agent to one state to another via a cost
undertaken by the agent
GOAL TEST: It is very important to design a goal state while designing a problem. We have to
make sure that what we will get in order to make sure what kind of moves we are taking. We
should know that at which step we can have lowest possible cost to search for the goal state.

State: {(0.0)}
State Space:{(0,0),(0,1),……,(0,7)(1.0),……,(1,7),(2,0),……(2,7),…………….. ,(6,1),…….
…..,(6,7)}
Successor Function:{UP,DOWN,LEFT,RIGHT}
Goal state:{YES OR NO}
Goal Test:{(3,7)}

4.What is the branching factor of this problem?


The branching factor of the given problem is 56 at initial.
Answer

O(b^m)

7 x 8 = 56

10^56

5.Can we use BFS or Dfs on this problem?Explain your answer


Yes we can use BFS to solve this problem to find the best possible move.

REASON: BFS algorithm works bottom up without checking any nodes, it uses recursive
function to check whether the agent had reached the goal state or not. DFS can be used to solve
the given problem, but in this problem BFS will not be optimal because BFS is optimal when the
cost remain same at every possible action.

6.PATH DISCOVERED BY UCS:

Uniform Cost Search expands the state with the lowest path cost. The path discovered by USC in
this problem is:

(0,0) (1,0) (2,0) (3,0) (4,0) (4,1) (4,7) (3,7)


7.Write Down the path that will be discovered by UCS?

NO, BFS and UCS will not give the same answers because this problem contains different cost
value at every move, and BFS is optimal when all steps cost are equal. Because is always
expands the unexpected state. By a simple extension, we can find an algorithm that is optimal
with any step cost function. Instead of expanding the unexpected state, UCS expands the state
with the lowest path cost.

8. Will Euclidean distance be an admissible heuristic? Will Manhattan distance be an


admissible heuristic? Prove your answer.

Euclidean distance is an admissible heuristic for the given problem. Because it has the minimum
distance to travel between the initial state and goal point. Otherwise, if the goal is diagonally
away from the agent’s current position then the Euclidean distance will be less than the true
distance.

Manhattan distance is not an admissible heuristic for the given problem because it measure the
distance between two points along x axis.

9. Come up with your own admissible heuristic, and solve the problem above using your
heuristic and A* search?

Suppose g*(n) is the cost of the shortest path from the start state to n.

Suppose the h*(n) is the actual cost of the shortest path from the state n to the goal.

In general g(n) > g*(n).

If h(n) <= h*(n) for all states, than any evaluation function f using h(n) and BFS will result in an
A* algorithm.
ANSWER NO: 2

MODEL THIS PROBLEM AS A CSP PROBLEM

Sudoku is a puzzle played in a 9x9 matrix (standard sudoku) which, at the beginning, is partially
full. This matrix is composed of 3x3 submatrices denominated “regions”. The task is to complete
the empty cells so that each column, row and region contain numbers from 1 to 9 exactly once.
The CSP model consists of the following constraints:

∀i∈ {1, ..., 9} All different {xi1, xi2, ..., xi9} ------------ (1)

∀j ∈ {1, ..., 9} All different {x1j, x2j , ..., x9j} ------------- (2)

On the other hand, each cell in regions Skl with 0 <= k, l <= 2 must be different, which forces to
include in the model.

2.WHAT COULD BE THE TIME COMPLEXITY OF THIS PROBLEM IF WE SOLVE


THIS PROBLEM USING DFS?

The time complexity of this problem by using DFS will be:

Time Complexity: O(bm) = O(981)

3.APPLY VANILA BACKTRACKING ON THIS PROBLEM FOR AT-LEAST 10


ITERATIONS.

Function Backtracking.SEARCH (csp) returns a solution, or failure


return Backtrack ({}, csp)

function Backtrack (ass, scp)


return a solution, or failure
if ass is complete then return ass
var = SELECT.UNASSIGNED-VARIABLES (csp)
for each value in ORDER.DOMAIN_VALUES (var, ass, csp)
if value is consistent with ass then
add {var = value} to ass
result = BACTRACK (ass, csp)
if result != failure then return result
remove {var = value} from ass
return failure.

5.Apply arc-consistency and show the resulting domain of variable.


Procedure AC-1(CSP) returns a Boolean value:
repeat:
for (xi, xj) in CSP’s arcs:
Revise(xi, xj) and Revise(xj, xi)
if no values remain in either domain of xi or xj, return false
until no domain has changed
return true

Procedure AC-2(CSP) returns a Boolean value:


fori=0 until 81: // for the total squares in a sudoku puzzle
Q1 = empty queue
Q2 = empty queue
for j=0 until i:
push (CSP.variables[i], CSP.variables[j]) into Q1
push (CSP.variables[j], CSP.variables[i]) into Q2
while Q1 is not empty:
while Q1 is not empty:
pop (xi, xj) from Q1
if Revise(xi, xj):
if the domain of xi has no remaining values, return false
for j=0 until i:
ifxj≠CSP.variables[j], push (CSP.variables[j], xi) into Q2
Q1 = copy of Q2
clear Q2
6.What will be the complete -state formulation of problem?
1. Each column, each row and each box (3×33×3 subgrid) must have the numbers 11 to 99.

2. No column, row or box can have two squares with the same number.

Someone has replaced each number from 11 to 99 in the Sudoku puzzle above with a letter.
Given that the number at the end of a row or at the bottom of a column is the sum of the letters
shown in that row or column, can you find which letter corresponds to which number, and then
solve the Sudoku?

Altogether a set of 16 equations can be formed.

For example, in the first and second columns beginning from the left of the 9×99×9 grid, we can
form the following equations:

c+g+k=17,c+g+k=17,

f+g+a=19.f+g+a=19.

In the fourth and fifth rows beginning from the top of the 9×99×9 grid, the following equations
can be formed:

k+g+m+c=23,k+g+m+c=23,

g+p=11

7.SIMULATING ANNEALING:

Target = function (s) {


Tar = sum (apply (s, 1, duplicate) + apply (s,2,duplicate))
For (r in 1:9){
Bloa = (1:3) + 3*(r – 1) % 3
Blob = (1:3) + 3*trunc ((r - 1)/3)
Tar = tar + sum (duplicated (as.vector(s[bloa, blob])))
}
Return (tar)
}
After pruning out the deterministic entries, the R program uses the temperature sequence
lmax = 10^5 #/target (matrix(sample(1:9, 81, rep = T), ncol = 9))
temps = exp (sqrt(seq(1, log(lmax)^2, le = niter + 1)))

QUESTION 3:
1. Formulate the Problem As MDP??

Answer

Start State{(0,0)}

Action{( UP,DOWN,LEFT,RIGHT)}

Transaction Function {(T(0,0),Action,(0,4))}

Reward Function{(R(0,0),Action,(0,4))}=r €

Teriminal State{(T(0,4)—X), (T(0,1)—X), (T(0,2)—X), (T(0,3)—X),)}

The temporal difference of the given problem is defined as:

q(st,at)←q(st,at)+α(rt+1+γq(st+1,at+1)−q(st,at))

However the temporal difference defined in Q learning is:

q(st,at)←q(st,at)+α(rt+1+γmaxaq(st+1,a)−q(st,at))

2. Used Policy iteration to Find the optimal policy


In the given cliff walking environment there are two policies during the iteration. When choosing
the action at+1 from q(s,a) given st +1, Sarsa uses ϵ - greedy policy while Q learning uses greedy
policy. But both of them are choosing at with ϵ - greedy policy. Considering the given
problem,every transition in the environment will get −1 reward except next state is the cliff
which the agent will get −100 reward, Sarsa is more likely to choose the safe path while Q
learning tends to choose the optimal path with ϵ - greedy policy. But both of them can reach the
optimal policy if reducing the value of ϵ.
Episode 1

1. (1-1/2)(0)+1/2[-1+1(0)]= -0.5

2. (1-1/2)(0)+1/2[-1+1(-0.5)]= -0.75

3. (1-1/2)(-0.5)+1/2[-1+1(-0.5)]=-1

4. (1-1/2)(-1)+1/2[-1+1(-1)]=-1.5

5. (1-1/2)(-1.5)+1/2[-1+1(-0.75)]=-1.625

6. (1-1/2)(1-625)+1/2[-1+1(0)]=-1.3125

7. (1-1/2)(-1.3215)+1/2[-1+1(0)]=-1.5625

8. (1-1/2)(-1.5625)+1/2[-1+1(0)]=1.078125

9. (1-1/2)(-1.08125)+1/2[-1+1(0)]=-1.03906925

10. (1-1/2)(-1.03906)+1/2[-1+1(1)]=+0.5195

4. Use MDP code given to implement this scenario.

def position(self, action):


if action == "up":
position = (self.posi[0]-1, self.posi[1])
elif action == "down":
position = (self.posi[0]+1, self.posi[1])
elif action == "left":
position = (self.posi[0], self.posi[1]-1)
else:
position = (self.posi[0], self.posi[1]+1)
if position[0] >= 0 and position[0] <= 3:
if position[1] >= 0 and position[1] <= 11:
self.posi = position
if self.posi == G:
self.end = True
print("Goal Reached")
if self.board[self.pos] == -1:
self.end = True
print("Game ends fall off cliff")
return self.pos
def giveReward(self):
if self.posi == G:
return -1
if self.board[self.pos] == 0:
return -1
return -100

QUESTION 4
Consider the game of LUDO. For LUDO answer the following question.

1. Moel the LUDO games as an adversarial search.

ANSWER: Firstly the adversarial search is what we examine the problem that arises when we
try to plan ahead in a world where the other agents are planning against each other or like an
opponent

As we talk about to model the LUDO game in respective of adversarial search.Because


adversarial search usually consier or examine the problem arises when we try to plan against our
opponent in all over the world where other opponent can also make strategy or plan to down
them in that condition.So,in the same way in LUDO the adversarial search works like to players
are playing the game and when its your turn the you are trying to make plan to defeat the
opponent ,but on the other hand the opponent is also making strategies to make down us.So these
are the conflicting goals in the games which occurs from agents.

1. Unpredictable:

The unpredictable opponent in games is very common because any single move can make whole
the game in the favor or opponent or the player itself. So for that unpredictable move there can
be a usage of searches.

2. Time Limits:

Time limits means that we have to find the goal state which is approximate.
2. Would you use minimax or expectimax search to solve LUDO? Explain your reasoning?

Minimax is a kind of backtracking algorithm that is used in decision making and game theory to
find the optimal move for a player, assuming that your opponent also plays optimally. It is
widely used in 2 players turn-based games such as tic tac toe, mancala, chess etc.

In minimax the two players are called maximizer an minimizer. The maximizer tries to get the
highest score possible while the minimizer tries to do the opposite and get the lowest score
possible.

Every board state have a value associated with it. In a given state if the maximizer has upper
hand then, then the score of the board will tend to be some positive value. If the minimizer have
the upper hand in that board state then it will tend to be some negative value. The values of the
board are calculated by some heuristic which are unique for every type.

3. What will be the complexity of adversarial search for LUDO?

Answer: The complexity of adversarial search for LUDO is that when your are playing the game
and the turn is to the opponent side so now opponent can make every possible move which make
the user state in danger positions.It means that opponent move to those state where the user don't
want to go because from this user cannot take advantage to beat the opponent.Along with the
LUDO game , these complexity also come games likes Chess , and some business tracks.So this
will be the complexity which occurs to the adversarial search for LUDO.

4. Draw the search graph of expectimax search for a turn for each player, assuming there
are four players.One is controlled by you.

Player S

A B

Chance
5. Will it be feasibility to do vanilla search for solving LUDO? Why or why not?

ANSWER: The LUDO game is the multiplayer agent game mean 2 to 4 player can play the
game at a time so it is non-deterministic and there is uncertainty in game in which every player is
playing to win the game by moving to the designated location in the board.So vanilla search is
very easy search so that why it is not applicable for the LUDO game because while using vanilla
search it is easy to win the game.

6 . Will you design an optimistic agent or pessimistic agent for Ludo?Explain your
reasoning?

 In this design you can see the agents have sensor.


 Agents have a goal to to performs an action.

7. How would you speed up the decision‐making process of your algorithm? Explain the
Improvements you would make and why they will be helpful?
Think for a moment about how an organization makes a decision, first comes the facts, the data
that will inform the decision. Using these facts, someone formulate alternative courses of actions
and revaluates them according to agreed on criteria. The decision maker then chooses the best
alternative and the organization commits itself to action.
 Learn continuously and see how to tackle the game and make the opponent in
difficult position from your tricky strategies.
 Be active to have and compete with complex problems
 Add recourses or get help.
 Add tools and techniques that can address complexity.
And solve the difficult problems when the user approaches.
IMPROVEMENTS:
 Identify and define the problem that what kind of problem are facing while
playing.
 Generate alternate solutions to help it.
 Decide on preferred course of action.
 Implement the decision
 Evaluate results.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy