Ejemplo n.º 1
0
    def setUp(self):
        self.kb = KnowledgeBase()

        # world
        self.kb += [
            Place(uid='place_from'),
            Person(uid='person_from'),
            Place(uid='place_thought'),
            Place(uid='place_to'),
            Person(uid='person_to'),
            LocatedIn(object='person_from', place='place_from'),
            LocatedIn(object='person_to', place='place_to')
        ]

        # quest
        self.kb += [
            Start(uid='start',
                  nesting=0,
                  type='simple_test',
                  require=(requirements.LocatedIn(object='person_from',
                                                  place='place_from'),
                           requirements.LocatedIn(object='person_to',
                                                  place='place_to'),
                           requirements.LocatedIn(object='hero',
                                                  place='place_from'))),
            State(uid='st_throught_place',
                  require=(requirements.LocatedIn(object='hero',
                                                  place='place_thought'), )),
            Finish(uid='st_finish',
                   start='start',
                   results={},
                   nesting=0,
                   require=(requirements.LocatedIn(object='hero',
                                                   place='place_to'), )),
            Jump(state_from='start', state_to='st_throught_place'),
            Jump(state_from='st_throught_place', state_to='st_finish')
        ]

        self.kb += [Hero(uid='hero')]

        self.kb.validate_consistency([
            restrictions.SingleStartStateWithNoEnters(),
            restrictions.FinishStateExists(),
            restrictions.AllStatesHasJumps(),
            restrictions.SingleLocationForObject(),
            restrictions.ReferencesIntegrity(),
            restrictions.ConnectedStateJumpGraph(),
            restrictions.NoCirclesInStateJumpGraph(),
            restrictions.MultipleJumpsFromNormalState(),
            restrictions.ChoicesConsistency()
        ])

        self.machine = machine.Machine(knowledge_base=self.kb,
                                       interpreter=FakeInterpreter())
Ejemplo n.º 2
0
    def check_quest(self, quest_class):
        self.kb += quest_class.construct_from_place(
            nesting=0,
            selector=self.selector,
            start_place=self.selector.new_place(candidates=('place_1', )))

        self.kb.validate_consistency([
            restrictions.SingleStartStateWithNoEnters(),
            restrictions.FinishStateExists(),
            restrictions.AllStatesHasJumps(),
            restrictions.SingleLocationForObject(),
            restrictions.ReferencesIntegrity(),
            restrictions.ConnectedStateJumpGraph(),
            restrictions.NoCirclesInStateJumpGraph(),
            # restrictions.MultipleJumpsFromNormalState(),
            restrictions.ChoicesConsistency(),
            restrictions.QuestionsConsistency(),
            restrictions.FinishResultsConsistency(),
            restrictions.RequirementsConsistency(),
            restrictions.ActionsConsistency()
        ])
Ejemplo n.º 3
0
from questgen.quests.hunt import Hunt
from questgen.quests.hometown import Hometown
from questgen.quests.search_smith import SearchSmith
from questgen.quests.delivery import Delivery
from questgen.quests.caravan import Caravan
from questgen.quests.collect_debt import CollectDebt
from questgen.quests.help_friend import HelpFriend
from questgen.quests.interfere_enemy import InterfereEnemy
from questgen.quests.help import Help

from questgen.relations import PROFESSION

# список ограничений для фактов о мире
WORLD_RESTRICTIONS = [
    restrictions.SingleLocationForObject(),
    restrictions.ReferencesIntegrity()
]

# список ограничений для графа задания
QUEST_RESTRICTIONS = [
    restrictions.SingleStartStateWithNoEnters(
    ),  # только одна начальная вершина для задания
    restrictions.FinishStateExists(),  # существуют завершающие вершины
    restrictions.AllStatesHasJumps(),  # существуют переходы из всех состояний
    restrictions.ConnectedStateJumpGraph(),  # граф связаный
    restrictions.NoCirclesInStateJumpGraph(),  # граф без циклов
    restrictions.MultipleJumpsFromNormalState(
    ),  # каждая обычная вершина имеет только одну исходящую дугу
    restrictions.ChoicesConsistency(),  # проверяем целостность развилок
    restrictions.QuestionsConsistency(
    ),  # проверяем целостность условных узлов
Ejemplo n.º 4
0
 def setUp(self):
     super(ReferencesIntegrityTests, self).setUp()
     self.restriction = restrictions.ReferencesIntegrity()