import prb
from pathlib import Path
prbFile = Path("./tests/mafia_2.prb")
If one passes a Path
, the file is read automatically.
problem = prb.PRB(prbFile)
If one passes a string, it is assummed to be the source.
problem = prb.PRB(prbFile.read_text())
problem.description.text
gives the description of the problem provided by its author.
print(problem.description.text)
Mafia game example 1. Maniac has almost killed Paul, but doc has saved Paul's him! 2. Maniac has killed Vlad and burned his flat. 3. The psycho had a vision about Vlad. 4. The psycho had a vision about Nick. 5. Maniac has killed Nick and burned his flat.
problem.orig.mappingFacts
is a collection of facts. The problem we use as an example is a classic Mafia/Werewolf game without seer roles, so the only facts in this example are NotMapsFact
.
f = problem.orig.mappingFacts[0]
problem.orig.mappingFacts
[<prb.NotMapsFact at 0x7f6c55a98e80>, <prb.NotMapsFact at 0x7f6c55a93c00>, <prb.NotMapsFact at 0x7f6c55a98f80>, <prb.NotMapsFact at 0x7f6c55a98680>, <prb.NotMapsFact at 0x7f6c58b07f00>, <prb.NotMapsFact at 0x7f6c58b07d80>]
Each fact can be related to paragraph number in the problem text.
f.paragraphNo
1
Each MappingFact
maps entities to each other (states their equivalence), or states their inequivalence.
e = f.entities[1]
f.entities
(<prb.Entity at 0x7f6c58abd580>, <prb.Entity at 0x7f6c58b11be0>)
Each entity has its id
and a ref to dimension
describing that variable.
e.dimension.name, e.id
('Role', 'doc')