0% found this document useful (0 votes)
4 views8 pages

AI Lab4

lab 4

Uploaded by

Muhammad Umair
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)
4 views8 pages

AI Lab4

lab 4

Uploaded by

Muhammad Umair
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/ 8

Artificial Intelligence

CSL 411

Lab Journal 4

Student Name: Muhammad Umair.


Enrolment No. 01-135221-039.
Class and Section: BD(IT),6th-B.

Department of Computer Science


BAHRIA UNIVERSITY, ISLAMABAD
Lab # 4: Rational Agents

Objectives:

To implement Simple Reflex Agent in Vacuum World.

Tools Used:

Python IDLE 3.4/Python IDLE 3.6

Submission Date:

Evaluation: Signatures of Lab Engineer:


Task # 1:

Consider the vacuum world shown in the figure below:

This particular world has just two locations: squares A and B. The vacuum agent perceives which square it is
in and1 whether there is dirt in the square. It can choose to move left, move right, suck up the dirt, or do
nothing. One very simple agent function is the following: if the current square is dirty, then suck, otherwise
move to the other square. A simple program for the agent function of vacuum-world is shown below:

Your task is to implement the above vacuum world and its agent program for a simple reflex agent. Also,
suggest a performance measure and evaluate your program based on that performance measure. Modify your
program accordingly.

rooms = ["A", "B"]


states = {"A": "Dirty", "B": "clean"}
actions = ["Suck", "move to A", "move to B"]

def get_state(room):
return states[room]

def get_action(state):
if state.lower() == "dirty":
return actions[0]
elif state.lower() == "clean":
return actions[1]
menu = int(input("Room A: 0 \t Room B: 1\n"))

if menu == 0:
room = "A"
elif menu == 1:
room = "B"
else:
print("Invalid input")
exit()

current_state = get_state(room)
action = get_action(current_state)

print(f"Room {room} is {current_state}. Action: {action}")

if action == "Suck":
print(f"Cleaning Room {room}...")
states[room] = "Clean"
print(f"Room {room} is now Clean.")

symptoms = {
"fever": False,
"cough": False,
"fatigue": False,
"loss of taste or smell": False
}

for symptom in symptoms:


response = input(f"Do you have {symptom}? (yes/no): ").strip().lower()
if response == "yes":
symptoms[symptom] = True

all_symptoms_present = True
for symptom, present in symptoms.items():
if not present:
all_symptoms_present = False
break

if all_symptoms_present:
print("All symptoms are present. Recommend COVID-19 test.")
test_result = input("Enter test result (positive/negative):
").strip().lower()
if test_result == "positive":
print("Recommend treatment: Isolate and consult a healthcare
provider.")
else:
print("No treatment needed. Continue to monitor symptoms.")
else:
print("Not all symptoms are present. No test recommended.")

Task # 2:

Develop a medical diagnosis system, designed as a simple reflex agent that diagnose the disease on the
basis of provided symptoms and test reports. Symptoms and test reports should be taken from the user as
percepts and agent has to display the diagnosed disease as its action. Also suggest that how can you convert
this agent into model-based agent, what changes from implementation perspective can be done to convert it
into model based.
Acute appendicitis:
Symptoms: Fever, Pain in Abdomen especially ILIAC FOSSA, vomiting,
Test: Blood CP with ESR… TLC (Total leucocyte count) will be high, DLC (Differential leucocyte
count) Neutrophils will be high , ESR high
Treatment: Surgery
Pneumonia:
Symptoms: Fever, Cough (with sputum), Pain in chest
Blood CP with ESR… TLC (Total leucocyte count) will be high, DLC (Differential leucocyte count)
Neutrophils will be high , ESR high
X-ray chest: pneumonic patch (sometimes)
Treatment: Antibiotics
# Acute appendicitis:
# Symptoms: Fever, Pain in Abdomen especially ILIAC FOSSA, vomiting,
# Test: Blood CP with ESR… TLC (Total leucocyte count) will be high, DLC
(Differential leucocyte count) Neutrophils will be high , ESR high
# Treatment: Surgery

def Acuteappendicitis():
fever = False
painInAbdomin = False
ILIACFossa = False
vomitting = False

for i in range(1):
fever = input("Do you have Fever (yes/no) : ")
painInAbdomin = input("Do you have painInAbdomin(yes/no) : ")
ILIACFossa = input("Do you have ILIACFossa(yes/no) : ")
vomitting = input("Do you have vomitting(yes/no) : ")

if (
fever == "yes"
and painInAbdomin == "yes"
and ILIACFossa == "yes"
and vomitting == "yes"
):
print(
"Recommended Tests: Blood CP with ESR… TLC (Total leucocyte count)
will be high, DLC (Differential leucocyte count) Neutrophils will be high , ESR
high"
)
choice = input("were the tests positive (yes/no):")
if choice == "yes":
print("Recommended Treatment : Treatment: Surgery")
else:
print("\nYou don't have Acuteappendicitis")

# Pneumonia:
# Symptoms: Fever, Cough (with sputum), Pain in chest
# Blood CP with ESR… TLC (Total leucocyte count) will be high, DLC
(Differential leucocyte count) Neutrophils will be high , ESR high
# X-ray chest: pneumonic patch (sometimes)
# Treatment: Antibiotics
def Pneumonia():

fever = False
cough = False
painInChest = False

for i in range(1):
fever = input("Do you have Fever (yes/no) : ")
cough = input("Do you have cough(yes/no) : ")
painInChest = input("Do you have pain in chest(yes/no) : ")

if fever == "yes" and cough == "yes" and painInChest == "yes":


print(
"Recommended Tests: lood CP with ESR… TLC (Total leucocyte count)
will be high, DLC (Differential leucocyte count) Neutrophils will be high , ESR
high\nX-ray chest: pneumonic patch (sometimes)"
)
choice = input("were the tests positive (yes/no):")
if choice == "yes":
print("Recommended Treatment : Treatment: Antibiotics")
else:
print("\nYou don't have Pneumonia")

def menu():
cho = int(input("Test for\n0: Acute appendicitis\n1: Pneumonia\n"))
if cho == 0:
Acuteappendicitis()
elif cho == 1:
Pneumonia()
else:
print("Invalid choice")

menu()

You might also like