You are on page 1of 11

SWE 424 | Artificial Intelligence with Lab

Mid-Term Assignment
Course Code: SWE 424
Course Title: Artificial Intelligence with Lab
Course Teacher: K. M. Imtiaz-Ud-Din
Assistant Professor
Department of Software Engineering

Date: 24.08.2020

Submitted by:
Name: Abdullah-Al-Yeamin Maruf
ID: 173-35-256
Section: A
Department of Software Engineering
Daffodil International University

1|P a ge
SWE 424 | Artificial Intelligence with Lab

Mid-Term Assignment:
Problem:

Problem Description:

A student lives in Younus khan scholar Garden. Which is DIU boys hostel. He want to go AB-4
for attend classes. There are many possible way to go Boys hostel to AB-4.

So now build a simple reflex agent to solve this problem. The agent start from node A, which
is Boys hostel and It’s end node is L, which is AB-4.

2|P a ge
SWE 424 | Artificial Intelligence with Lab

3|P a ge
SWE 424 | Artificial Intelligence with Lab

Solution:
a. Task Environment:
Hare we see the Daffodil International University Permanent Campus map. Hare every place
has a name. Such as Boys hostel is A, Hall main gate is B, DDBL ATM booth is C, Main gate is
D, DIU golf ground is E, Green garden is F, AB1 is J, food court is N, Admission office is G, AB4
is L, DIU auditorium is M. Here we also see DIU playground, AB3, Bonomaya, Girls hostel.

b. Purpose / Objective:
Now build a simple reflex agent, which can go from A node which is DIU boys hostel to L
node which is AB-4.

c. Why this specific task should be solved by an agent of this type:


Simple reflex agents are just that simple and solved only low level AI. The agent designer
(human) will tell the agent exactly which action to perform for which percept. Human will
design an agent function to solve this problem. Simple reflex agent cannot compute complex
equations or solve complicated problems. They work only in environments that are fully-
observable in the current percept. It performs actions based on a current situation.

d. Percepts:
Location: A node, B node, C node, D node, E node, F node, G node, H node, I node, J node, K
node, L node, M node, N node, O node, P node
Colour: Black, Red

e. Sensors:
Location Sensor, Colour Sensor

f. Actions:
moveForword, moveLeft, moveRight, standby

g. Actuators:
wheel, motor, shaft, no operation mode program

4|P a ge
SWE 424 | Artificial Intelligence with Lab

h. List of all the environment states or percepts or situations that will be


faced by agent:
Percept Variables:
Location (A / B / C / D / E / F / G / H / I / J / K / L / M / N / O / P)
Colour (Black / Red)

All Possible Actions


1. Move Forward
2. Move Left
3. Move Right
4. Standby
List:
1. [A, Red] – move forward / move left / move right / standby
2. [A, Black] - move forward / move left / move right / standby
3. [B, Red] – move forward / move left / move right / standby
4. [B, Black] - move forward / move left / move right / standby
5. [C, Red] – move forward / move left / move right / standby
6. [C, Black] - move forward / move left / move right / standby
7. [D, Red] – move forward / move left / move right / standby
8. [D, Black] - move forward / move left / move right / standby
9. [E, Red] – move forward / move left / move right / standby
10. [E, Black] - move forward / move left / move right / standby
11. [F, Red] – move forward / move left / move right / standby
12. [F, Black] - move forward / move left / move right / standby
13. [G, Red] – move forward / move left / move right / standby
14. [G, Black] - move forward / move left / move right / standby
15. [H, Red] – move forward / move left / move right / standby
16. [H, Black] - move forward / move left / move right / standby
17. [I, Red] – move forward / move left / move right / standby
18. [I, Black] - move forward / move left / move right / standby
19. [J, Red] – move forward / move left / move right / standby
20. [J, Black] - move forward / move left / move right / standby
21. [K, Red] – move forward / move left / move right / standby
22. [K, Black] - move forward / move left / move right / standby
23. [L, Red] – move forward / move left / move right / standby
24. [L, Black] - move forward / move left / move right / standby
25. [M, Red] – move forward / move left / move right / standby
26. [M, Black] - move forward / move left / move right / standby
27. [N, Red] – move forward / move left / move right / standby
28. [N, Black] - move forward / move left / move right / standby
29. [O, Red] – move forward / move left / move right / standby
30. [O, Black] - move forward / move left / move right / standby
31. [P, Red] – move forward / move left / move right / standby
32. [P, Black] - move forward / move left / move right / standby

Current environment state or situation - [A, Red]

5|P a ge
SWE 424 | Artificial Intelligence with Lab

i. Performance Measure:

Performance Measure is a scale that will help us to understand which action is the most
desirable action or the best action in a certain situation or environment state.

+1 point for move forward to a different location if current location is Black

+1 point for move forward, move left or move right to a different location or standby if
current location is Red

j. Decision Tree:

6|P a ge
SWE 424 | Artificial Intelligence with Lab

j. Decision Tree:

i. Agent Function:

if (location == A and colour == Red)


then move_forword

if (location == A and colour == Black)


then move_forword

if (location == B and colour == Red)


then move_right

if (location == B and colour == Black)


then move_forword

if (location == C and colour == Red)


then move_forword

if (location == C and colour == Black)


then move_forword

if (location == D and colour == Red)


then move_right

if (location == D and colour == Black)


then move_forword

if (location == G and colour == Red)


then move_left

if (location == G and colour == Black)


then move_forword

if (location == H and colour == Red)


then move_right

if (location == H and colour == Black)


then move_forword

if (location == L and colour == Red)


then standby

7|P a ge
SWE 424 | Artificial Intelligence with Lab

j. Agent Program:

#include <stdio.h>
#define Black 0
#define Red 1
#define move_forward 2
#define move_left 3
#define move_right 4
#define standby 5
#define A 10
#define B 11
#define C 12
#define D 13
#define G 14
#define H 15
#define L 16

/*Agent program based on agent function. This C function


will take the percepts as parameter and return the action*/

int student_robot_agent(int location,int colour){


if (location == A && colour == Red){
return move_forward;
}
if(location == A && colour == Black){
return move_forward;
}
if(location == B && colour == Red){
return move_right;
}
if(location == B && colour == Black){
return move_forward;
}

8|P a ge
SWE 424 | Artificial Intelligence with Lab

if(location == C && colour == Red){


return move_forward;
}
if(location == C && colour == Black){
return move_forward;
}
if (location == D && colour == Red){
return move_right;
}
if(location == D && colour == Black){
return move_forward;
}
if(location == G && colour == Red){
return move_left;
}
if(location == G && colour == Black){
return move_forward;
}
if(location == H && colour == Red){
return move_right;
}
if(location == H && colour == Black){
return move_forward;
}
if(location == L && colour == Red){
return standby;
}
}

int main()
{
//taking percepts
int location, colour;

9|P a ge
SWE 424 | Artificial Intelligence with Lab

int robotStatus = 1;

while(robotStatus) {
printf("Please Enter location - A = 10 / B = 11 / C = 12 / D = 13 / G
= 14 / H = 15 / L = 16 \n");
scanf("%d", &location);
printf("Please Enter colour - Black = 0 / Red = 1 \n");
scanf("%d", &colour);

//decision making
//calling the C function that implemented agent function
int action = student_robot_agent(location,colour);

//performing action

if(action == move_forward){
printf("--- Move Forword ---\n\n");
}

else if(action == move_right){


printf("--- Move Right ---\n\n");
}

else if(action == move_left){


printf("--- Move Left ---\n\n");
}

else if(action == standby){


printf("--- No Operation ---\n\n");
robotStatus = 0;
}
}
return 0;
}

10 | P a g e
SWE 424 | Artificial Intelligence with Lab

K. Output Screenshot:

11 | P a g e

You might also like