Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Final-Term Exam (Take-Home) Fall - 2020

Subject: Artificial Intelligence Submission: 30 jan 10 am


Instructor: Safdar Hussain, Hira Farman, darakshanSyed, Sophia ajaz

Program: BS (CS) / BS (SE) Time Allowed: 1 Week No.


of Students: Max. Marks: 35

Faculty of Engineering, Sciences and Technology

Instructions:

1. Upload your project in a zipped file containing the Visual Studio Project Solution
before the due date on BlackBoard.

2. The zipped solution should contain a Word File also where you write your name and
registration ID on the first page and then attach the screenshots of the running project as
well as of your complete code class by class or any other answers.

3. Answer scripts can be uploaded on BlackBoard any time before its deadline.
Therefore, do not wait for the last hour to avoid any unforeseen problems.

4. Submission of answer copy(ies) will be considered acceptable through


BlackBoard only. Therefore, do not submit your document through email or any
other medium.

5. Use 12 pt. font size and Times New Roman font style along with 1-inch page
margins.

6. Provide relevant, original and conceptual answers, as this exam aims to test your
ability to examine, explain, modify or develop concepts discussed in class.

7. Do not copy answers from the internet or other sources. The plagiarism of your
answers may be checked through Turnitin.

8. Recheck your answers before the submission on BlackBoard to correct any content or
language related errors.

9. Double check your solution before uploading it on BlackBoard to ensure that you
have uploaded the correct file with your answers.
Question 1: [15 Marks]
Let’s  consider the following 3-state MDP(Markov Decision Process) for a robot trying to
walk, the three states being ‘Fallen‘, ‘Standing‘ and ‘Moving‘, as shown in the following
figure.

Use the MDP formulation to code the following problem and find the optimal Values
using the value iteration algorithm. And then use policy iteration method to find
optimal policy for discount factor γ=0.1. Try using this method with a different discount
factor, for example a much larger discount factor like 0.9 or 0.99, or a much smaller one
like 0.01. Does the optimal policy change comment on it?

Question 2: [10 Marks]

The Football Bowl Subdivision (FBS) level of the National Collegiate Athletic
Association (NCAA) consists of over 100 schools. Most of these schools belong to one of
several conferences, or collections of schools, that compete with each other on a regular
basis in collegiate sports. Suppose the NCAA has commissioned a study that will propose
the formation of conferences based on the similarities of the constituent schools.
Therefore, the director has decided to travel to five schools and the graph is given to you
in the following diagram where S is the goal school (state) and P is the initial school
(state).
Implement to simulate this problem by Informed Search (A* search).

Here the paths to every school are not directed. The cost of every school’s path is mentioned
on the path line in dark and the h(n) values are given on the side of nodes in blue.

For every iteration, you need to display

 visited school list’s value at present


 visited school state’s path
 path length
 estimated complete [h(n) plus real] path cost
Also provide your comments regarding whether

 h(n) is acceptable and stable?


 optimal path is found and why? If not then why not? Also, how would you put the
h(n) values of the states to make it right.

Question 3: [5+5= Marks]

A.Use the knowledge from adversarial search find optimal solution. Write a python code
to check if any King is unsafe on the Chessboard or not. Given a matrix board [8]
[8] comprising of the king (K), the queen(q), the bishop(b), the knight(t), the rook (r)and
pawns (p) of black and white color. Empty spaces are represented by “ * ” .
To accomplish the task, you need to check which of the king i.e. black of white is unsafe.
If you find him under attack by any of the piece, the answer will be according to the
situation with explanation that black bishop can attack the white king. In case of both
kings are safe then explanation would be like no King is in danger.

White Side: K, Q, B, T, R, P
Black Side: k, q, b, t, r, p
Examples:
Input:
board[][] = {{* * * k * * * *},
{p p p * p p p p},
{* * * * * b * *},
{* * * R * * * *},
{* * * * * * * *},
{* * * * * * * *},
{t P P P P P P *},
{* * K * * * * *}}

Output: White King in danger


Explanation: Black knight can attack the white king.

B. You are a robot assigned to place three Knights on a 3 x 3 chess board such that (1) all
Knights do not attack each other, (2) only one Knight is placed in each row, and (3) only one
Knight is placed in each column. Recall that a knight attacks in an “L” pattern, i.e., a knight
moves two spaces rectilinearly and then one space at right angles to the initial movement.
For the benefit of students who do not play chess, the following boards illustrate the
allowed cells (marked as O) and prohibited cells (marked as X) after you place a knight
(marked as K) at a cell. Once a knight is placed at a cell marked as K, any other knight may
be placed only in a cell marked as O, and may not be placed in a cell marked as X. Only
symmetry-collapsed positions are shown below. All other constraint positions may be
obtained by symmetry reflections and rotations.

row row row


K X X X O X O X O
3 3 3
row row row
X O X K X X X K X
2 2 2
row row row
X X O X O X O X O
1 1 1
col col col col col col col col col
C1 C2 C3 C1 C2 C3 C1 C2 C3

You decide to formulate this task as a CSP in which columns are the variables
(named C1 through C3) and rows are the domain values (named 1, 2, and 3). After you
have solved the CSP, each column (variable) will be assigned a row (value), and all
constraints will be satisfied. The columns (variables) are C1-C3:
• C1, col 1 - will be assigned the row number of the knight in column 1
• C2, col 2 - will be assigned the row number of the knight in column 2
• C3, col 3 - will be assigned the row number of the knight in column 3

The rows (domain values) are the digits 1-3:


1, the knight in that column is in row 1
2, the knight in that column is in row 2
3, the knight in that column is in row 3
There are no unitary constraints, and so the initial variable domains include all
possible values:
D1 = {1, 2, 3} D2 = {1, 2, 3} D3 = {1, 2, 3}

First of all think all CSP constraints as explicit relations of all allowed pairs of variable
values: Implement constraint graph associated with your CSP and then Run arc consistency
also comment on your results.

You might also like