for room1 in rooms: for room2 in rooms: if room1 != room2: knowledge.add(Not(And(room1, room2))) """ 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)
Or(Symbol("Mostarda0"), Symbol("Black0"), Symbol("Violeta0"), Symbol("Marinho0"), Symbol("Rosa0"), Symbol("Branca0")), Or(Symbol("faca0"), Symbol("castical0"), Symbol("revoler0"), Symbol("corda0"), Symbol("cano0"), Symbol("chave0")), Or(Symbol("hall0"), Symbol("estar0"), Symbol("cozinha0"), Symbol("jantar0"), Symbol("festas0"), Symbol("musica0"), Symbol("jogos0"), Symbol("biblioteca0"), Symbol("escritorio0"))) # If one person, room or weapon is in the answer, # it implicates that the others aren't for character1 in characters: for character2 in characters: if character1 != character2: knowledge.add( Implication(Symbol(f"{character1}0"), Not(Symbol(f"{character2}0")))) for weapon1 in weapons: for weapon2 in weapons: if weapon1 != weapon2: knowledge.add( Implication(Symbol(f"{weapon1}0"), Not(Symbol(f"{weapon2}0")))) for room1 in rooms: for room2 in rooms: if room1 != room2: knowledge.add( Implication(Symbol(f"{room1}0"), Not(Symbol(f"{room2}0")))) # If one person has a card,