示例#1
0
文件: main.py 项目: yucel-yilmaz/CSP
# The Dane drinks Tea.
# The Green house is exactly to the left of the White house.
# The owner of the Green house drinks Coffee.
# The person who smokes Pall Mall rears Birds.
# The owner of the Yellow house smokes Dunhill.
# The man living in the centre house drinks Milk.
# The Norwegian lives in the first house.
# The man who smokes Blends lives next to the one who keeps Cats.
# The man who keeps Horses lives next to the man who smokes Dunhill.
# The man who smokes Blue Master drinks Beer.
# The German smokes Prince.
# The Norwegian lives next to the Blue house.
# The man who smokes Blends has a neighbour who drinks Water.

pz = Puzzle()
pz.add_values("Home", [1, 2, 3, 4, 5])
pz.add_values("Color", ["Blue", "Green", "Red", "White", "Yellow"])
pz.add_values("Nationality", ["Brit", "Dane", "German", "Norwegian", "Swede"])
pz.add_values("Drink", ["Beer", "Coffee", "Milk", "Tea", "Water"])
pz.add_values("Cigarette",
              ["Blends", "Blue Master", "Dunhill", "Pall Mall", "Prince"])
pz.add_values("Pet", ["Birds", "Cats", "Dogs", "Horses", "Fish"])

# The Brit lives in the Red house.
pz.add_condition(Relationship.EQ, {"Nationality": "Brit"}, {"Color": "Red"})
# The Swede keeps Dogs as pets.
pz.add_condition(Relationship.EQ, {"Nationality": "Swede"}, {"Pet": "Dogs"})
# The Dane drinks Tea.
pz.add_condition(Relationship.EQ, {"Nationality": "Dane"}, {"Drink": "Tea"})
# The owner of the Green house drinks Coffee.
pz.add_condition(Relationship.EQ, {"Color": "Green"}, {"Drink": "Coffee"})