0% found this document useful (0 votes)
19 views4 pages

Symbiosis Skills and Open University

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)
19 views4 pages

Symbiosis Skills and Open University

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/ 4

SYMBIOSIS SKILLS AND OPEN UNIVERSITY

B.Sc. in Data Science


Assignment sheet
Subject- Introduction to Artificial Intelligence
Practical : 1
Date: 23-06-2021

Q1. Write a program to Create a captcha in python platform


Q2. Write algorithm for
● self-reflexive,

● model based,

● utility based and

● Learning agent.
Q3. Write the algorithms for implementing different kinds of agents for different
scenarios.
SYMBIOSIS SKILLS AND OPEN UNIVERSITY
B.Sc. in Data Science
Assignment sheet
Subject- Introduction to Artificial Intelligence
Skill : 1
Date: 23-06-2021

Q1. Optimise the given Code for automated vacuum cleaner implementing self-reflex
agent.

import random

class Environment(object):
def __init__(self):
# instantiate locations and conditions
# 0 indicates Clean and 1 indicates Dirty
self.locationCondition = {'A': '0', 'B': '0'}

# randomize conditions in locations A and B


self.locationCondition['A'] = random.randint(0, 1)
self.locationCondition['B'] = random.randint(0, 1)

class SimpleReflexVacuumAgent(Environment):
def __init__(self, Environment):
print (Environment.locationCondition)
# Instantiate performance measurement
Score = 0
# place vacuum at random location
vacuumLocation = random.randint(0, 1)
# if vacuum at A
if vacuumLocation == 0:
print ("Vacuum is randomly placed at Location A.")
# and Location A is Dirty.
if (Environment.locationCondition['A'] == 1):
print ("Location A is Dirty.")
# suck the dirt and mark it clean
Environment.locationCondition['A'] = 0;
Score += 1
print ("Location A has been Cleaned.")
# move to B
print ("Moving to Location B...")
Score -= 1
# if B is Dirty
if Environment.locationCondition['B'] == 1:
print ("Location B is Dirty.")
# suck and mark clean
Environment.locationCondition['B'] = 0;
Score += 1
print ("Location B has been Cleaned.")
else:
# move to B
Score -= 1
print ("Moving to Location B...")
# if B is Dirty
if (Environment.locationCondition['B'] == 1):
print ("Location B is Dirty.")
# suck and mark clean
Environment.locationCondition['B'] = 0;
Score += 1
print ("Location B has been Cleaned.")

elif vacuumLocation == 1:
print ("Vacuum randomly placed at Location B.")
# and B is Dirty
if Environment.locationCondition['B'] == 1:
print ("Location B is Dirty.")
# suck and mark clean
Environment.locationCondition['B'] = 0;
Score += 1
print ("Location B has been Cleaned.")
# move to A
Score -= 1
print ("Moving to Location A...")
# if A is Dirty
if (Environment.locationCondition['A'] == 1):
print ("Location A is Dirty.")
# suck and mark clean
Environment.locationCondition['A'] = 0;
Score += 1
print ("Location A has been Cleaned.")
else:
# move to A
print ("Moving to Location A...")
Score -= 1
# if A is Dirty
if (Environment.locationCondition['A'] == 1):
print ("Location A is Dirty.")
# suck and mark clean
Environment.locationCondition['A'] = 0;
Score += 1
print ("Location A has been Cleaned.")
# done cleaning
print( Environment.locationCondition)
print ("Performance Measurement: " + str(Score))

theEnvironment = Environment()
theVacuum = SimpleReflexVacuumAgent(theEnvironment)

You might also like