-
Notifications
You must be signed in to change notification settings - Fork 0
/
clue.py
52 lines (39 loc) · 1.1 KB
/
clue.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import termcolor
from logic import *
mustard = Symbol("ColMustard")
plum = Symbol("ProfPlum")
scarlet = Symbol("MsScarlet")
characters = [mustard, plum, scarlet]
ballroom = Symbol("ballroom")
kitchen = Symbol("kitchen")
library = Symbol("library")
rooms = [ballroom, kitchen, library]
knife = Symbol("knife")
revolver = Symbol("revolver")
wrench = Symbol("wrench")
weapons = [knife, revolver, wrench]
symbols = characters + rooms + weapons
def check_knowledge(knowledge):
for symbol in symbols:
if model_check(knowledge, symbol):
termcolor.cprint(f"{symbol}: YES", "green")
elif not model_check(knowledge, Not(symbol)):
print(f"{symbol}: MAYBE")
# There must be a person, room, and weapon.
knowledge = And(
Or(mustard, plum, scarlet),
Or(ballroom, kitchen, library),
Or(knife, revolver, wrench)
)
# Initial cards
knowledge.add(And(
Not(mustard), Not(kitchen), Not(revolver)
))
# Unknown card
knowledge.add(Or(
Not(scarlet), Not(library), Not(wrench)
))
# Known cards
knowledge.add(Not(plum))
knowledge.add(Not(ballroom))
check_knowledge(knowledge)