예제 #1
0
#
# Artificial Intelligence 2I1AE1
#

#
# @file animals.py
#
# @author Regis Clouard.
#

from engine import addRule, addFact

print "   Load file: animals.py" 

## Add the rules
addRule(['animal_has_hair'],'animal_is_mammal')
addRule(['animal_gives_milk'], 'animal_is_mammal')
addRule(['animal_has_feathers'], 'animal_is_bird')
addRule(['animal_flies', 'animal_lays_eggs'], 'animal_is_bird')
addRule(['animal_is_mammal', 'animal_eats_meat'], 'animal_is_carnivore')
addRule(['animal_is_mammal', 'animal_has_pointed_teeth', 'animal_has_claws', 'animal_has_eyes_point_forward'], 'animal_is_carnivore')
addRule(['animal_is_mammal', 'animal_has_hoofs'], 'animal_is_ungulate')
addRule(['animal_is_mammal', 'animal_is_not_carnivore'], 'animal_is_ungulate')
addRule(['animal_is_carnivore', 'animal_has_tawny_color', 'animal_has_dark_spots'], 'animal_is_cheetah')
addRule(['animal_is_carnivore', 'animal_has_tawny_color', 'animal_has_black_stripes'], 'animal_is_tiger')
addRule(['animal_is_ungulate', 'animal_has_black_stripes'], 'animal_is_zebra')
addRule(['animal_is_ungulate', 'animal_has_long_legs', 'animal_has_long_neck', 'animal_has_tawny_color', 'animal_has_dark_spots'], 'animal_is_giraffe')
addRule(['animal_is_bird', 'animal_does_not_fly', 'animal_has_long_neck', 'animal_has_long_legs', 'animal_is_black_and_white'], 'animal_is_ostrich')
addRule(['animal_is_bird', 'animal_does_not_fly', 'animal_swims', 'animal_is_back_and_white'], 'animal_is_penguin')
addRule(['animal_is_bird', 'animal_flies'], 'animal_is_albatross')
예제 #2
0
#
# @file puzzle.py
#

# @author EL HIMDI Yasmine
# @author PARMENTIER Laurent

from engine import addRule, addFact

## Reset the memory working and the knowledge base.
print "   Load file:  puzzle.py" 

## Add the rules

# a)
addRule(['house_next_lake'], 'treasure_not_in_kitchen')

# b)
addRule(['tree_front_yard_is_oak'], 'treasure_in_garage')

# c)
addRule(['treasure_not_in_kitchen'], 'tree_front_yard_not_elm')

# e) !AvB <=> A=>B
addRule(['tree_front_yard_not_elm'], 'treasure_is_burried_under_flagpole')

# Consider the following fact:
def case():
	# d) is a fact
    addFact('house_next_lake')
    return 'None'