コード例 #1
0
    def create_knowledge_base(self) -> List[Fact]:
        """
        Method for create user knowledge base. You can also have other class methods, but entry point must be this
        function. Don't change the signature of the method, you can change return value, but it is not recommended.

        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !!  TODO: Write implementation of your knowledge base definition HERE   !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        """

        facts = []

        if not self.map_proxy.player_have_base(self.player):
            facts.append(Fact('player_dont_have_base'))

        facts.append(
            Fact('surrounded',
                 eval_function=self.all_fuzzy_surrounded,
                 data=self.all_fuzzy_surrounded))
        facts.append(
            Fact('game_period',
                 eval_function=self.all_fuzzy_level_number,
                 data=self.all_fuzzy_level_number))

        facts.append(
            Fact('tiles_for_protection',
                 eval_function=self.tiles_for_protection,
                 data=self.tiles_for_protection))

        return facts
コード例 #2
0
    def create_knowledge_base(self) -> List[Fact]:
        """
        Method for create user knowledge base. You can also have other class methods, but entry point must be this
        function. Don't change the signature of the method, you can change return value, but it is not recommended.

        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !!  TODO: Write implementation of your knowledge base definition HERE   !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        """

        facts = []

        # Add bool fact

        # Add fact with data holder
        # We can use there eval function same as data function
        # because if first_free_tile return None, bool value of None is False, otherwise bool value is True
        # You can use different functions for eval and data
        facts.append(
            Fact('player_dont_have_base',
                 eval_function=self.player_dont_have_base))
        facts.append(
            Fact('free_tile',
                 eval_function=self.free_tile,
                 data=self.free_tile))
        facts.append(Fact('yes', eval_function=self.yes))
        # Add numerical fact
        facts.append(Fact("money", eval_function=self.money, data=self.money))
        facts.append(
            Fact("free_place",
                 eval_function=self.free_place,
                 data=self.free_place))

        return facts
コード例 #3
0
    def create_knowledge_base(self) -> List[Fact]:
        """
        Method for create user knowledge base. You can also have other class methods, but entry point must be this
        function. Don't change the signature of the method, you can change return value, but it is not recommended.

        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !!  TODO: Write implementation of your knowledge base definition HERE   !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        """

        facts = []

        # Add numerical fact
        user_resources = self.game_object_proxy.get_resources(self.player)
        facts.append(Fact("money", lambda: user_resources))

        #place base
        if not self.map_proxy.player_have_base(self.player):
            facts.append(Fact('player_dont_have_base'))
        else:
            facts.append(Fact('player_have_base'))
        #resources and positions for first line of defense Archers
        if self.game_object_proxy.get_resources(self.player) >= 30:
            if self.check_positions():
                facts.append(Fact('can_place_archer'))
        #resources and positions for FLoD Knights
        if self.game_object_proxy.get_resources(self.player) >= 60:
            if self.check_positions():
                facts.append(Fact('can_place_knight'))

        #placing druids in corners, only if inner circle of guards is intact
        if self.game_object_proxy.get_resources(
                self.player) >= 100 and self.has_guards():
            facts.append(Fact('has_guards'))
            facts.append(Fact('has_resources_druid'))

        #place knights for second defense line
        if self.game_object_proxy.get_resources(self.player) >= 120:
            facts.append(Fact('can_buy_extended_guard'))

        #resources for ENT
        if self.game_object_proxy.get_resources(self.player) >= 200:
            facts.append(Fact('has_resources_ent'))

        #position for ENT
        if self.cross_free():
            facts.append(Fact('cross_not_occupied'))
        return facts
コード例 #4
0
ファイル: KnowledgeBase.py プロジェクト: latkam/fit-ctu
    def create_knowledge_base(self) -> List[Fact]:
        """
        Method for create user knowledge base. You can also have other class methods, but entry point must be this
        function. Don't change the signature of the method, you can change return value, but it is not recommended.

        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !!  TODO: Write implementation of your knowledge base definition HERE   !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        """

        facts = []

        visible_tiles = self.map_proxy.get_player_visible_tiles()

        facts.append(Fact('money', self.get_resources))

        if not self.map_proxy.player_have_base(self.player):
            facts.append(Fact('player_dont_have_base'))

        if self.map_proxy.player_have_base(self.player):
            facts.append((Fact('player_have_base')))

        for pos in visible_tiles:
            facts.append(Fact('position_is_visible', self.position_is_visible))
            if not self.map_proxy.is_position_occupied(pos):
                facts.append(
                    Fact('position_is_not_occupied',
                         self.position_is_not_occupied))
            if self.map_proxy.is_position_occupied(pos):
                facts.append(
                    Fact('position_is_occupied', self.position_is_occupied))
        return facts
コード例 #5
0
    def create_knowledge_base(self) -> List[Fact]:
        """
        Method for create user knowledge base. You can also have other class methods, but entry point must be this
        function. Don't change the signature of the method, you can change return value, but it is not recommended.

        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !!  TODO: Write implementation of your knowledge base definition HERE   !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        """

        facts = []

        if not self.map_proxy.player_have_base(self.player):
            facts.append(Fact('player_dont_have_base'))

        return facts
コード例 #6
0
ファイル: KnowledgeBase.py プロジェクト: latkam/fit-ctu
    def create_knowledge_base(self) -> List[Fact]:
        """
        Method for create user knowledge base. You can also have other class methods, but entry point must be this
        function. Don't change the signature of the method, you can change return value, but it is not recommended.

        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !!  TODO: Write implementation of your knowledge base definition HERE   !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        """

        facts = []

        # Add bool fact
        if not self.map_proxy.player_have_base(self.player):
            facts.append(
                Fact('player_dont_have_base',
                     eval_function=self.player_dont_have_base,
                     data=self.player_dont_have_base))

        # Add fact with data holder
        # We can use there eval function same as data function
        # because if first_free_tile return None, bool value of None is False, otherwise bool value is True
        # You can use different functions for eval and data
        facts.append(
            Fact('player_has_base',
                 eval_function=self.player_has_base,
                 data=self.player_has_base))
        facts.append(
            Fact('free_tile',
                 eval_function=self.first_free_tile,
                 data=self.first_free_tile))
        facts.append(
            Fact('visible_free_tile',
                 eval_function=self.visible_free_tile,
                 data=self.visible_free_tile))
        facts.append(
            Fact('base_neighbours',
                 eval_function=self.base_neighbours,
                 data=self.base_neighbours))
        facts.append(
            Fact('ideal_tile',
                 eval_function=self.ideal_tile,
                 data=self.ideal_tile,
                 probability=self.ideal_tile_probability()))
        facts.append(
            Fact('position_first_round',
                 eval_function=self.position_first_round,
                 data=self.position_first_round))
        facts.append(
            Fact('position_second_round',
                 eval_function=self.position_second_round,
                 data=self.position_second_round))
        facts.append(
            Fact('position_third_round',
                 eval_function=self.position_third_round,
                 data=self.position_third_round))

        # Add numerical fact
        facts.append(
            Fact("money",
                 lambda: self.game_object_proxy.get_resources(self.player)))
        facts.append(
            Fact('current_round',
                 lambda: self.game_object_proxy.get_current_round()))

        # print("money:", self.game_object_proxy.get_resources(self.player))

        return facts
コード例 #7
0
    def create_knowledge_base(self) -> List[Fact]:
        """
        Method for create user knowledge base. You can also have other class methods, but entry point must be this
        function. Don't change the signature of the method, you can change return value, but it is not recommended.

        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        !!  TODO: Write implementation of your knowledge base definition HERE   !!
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        """

        facts = []

        # Add bool fact

        # Add fact with data holder
        # We can use there eval function same as data function
        # because if first_free_tile return None, bool value of None is False, otherwise bool value is True
        # You can use different functions for eval and data
        facts.append(
            Fact('player_dont_have_base',
                 eval_function=self.player_dont_have_base))
        facts.append(
            Fact('free_tile',
                 eval_function=self.free_tile,
                 data=self.free_tile))
        facts.append(
            Fact('visible_free_tile',
                 eval_function=self.visible_free_tile,
                 data=self.visible_free_tile))
        facts.append(
            Fact('free_sides',
                 eval_function=self.free_sides,
                 data=self.free_sides))
        # facts.append(Fact('resources_archer6', eval_function=self.resources_archer6, data=self.free_first_ring))
        facts.append(
            Fact('resources_knight', eval_function=self.resources_knight))
        facts.append(Fact('has_guards', eval_function=self.has_guards))
        facts.append(
            Fact('resources_druid', eval_function=self.resources_druid))
        facts.append(
            Fact('resources_magician', eval_function=self.resources_magician))
        facts.append(
            Fact('resources_archer', eval_function=self.resources_archer))
        facts.append(Fact('king_low', eval_function=self.king_low))
        facts.append(
            Fact('found_good',
                 eval_function=self.found_good,
                 data=self.found_good))
        facts.append(
            Fact('free_place_from_base2',
                 eval_function=self.free_place_from_base2,
                 data=self.free_place_from_base2))
        facts.append(
            Fact('free_place_from_base3',
                 eval_function=self.free_place_from_base3,
                 data=self.free_place_from_base3))
        facts.append(Fact('resources_ent1', eval_function=self.resources_ent1))
        facts.append(Fact('enemy_of', eval_function=self.enemy_of))
        facts.append(
            Fact('near_minotaur',
                 eval_function=self.near_minotaur,
                 data=self.near_minotaur))
        facts.append(
            Fact('resources_archer5', eval_function=self.resources_archer5))
        facts.append(Fact('yes', eval_function=self.yes))
        facts.append(Fact('no', eval_function=self.no))
        # Add numerical fact
        facts.append(
            Fact("money",
                 lambda: self.game_object_proxy.get_resources(self.player)))

        return facts