AI Lab4
AI Lab4
CSL 411
Lab Journal 4
Objectives:
Tools Used:
Submission Date:
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.
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)
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
}
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) : ")
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()