Exemple #1
0
    def get_build(self, board, wid, rule_checker):
        """
        Asks the player to build a floor

        :param board: GameBoard, copy of the current state of the game
        :param wid: Worker ID of the worker that the player needs to build with

        :return: Json that represents a build action
        """
        worker_position = board.find_worker(self.__player_id, wid)
        builds = gen_builds(self.__player_id, worker_position, board, rule_checker)
        for i in builds:
            return i
Exemple #2
0
    def check_build_states(self, player, worker, depth):
        """
        Check all possible build states at this layer
        :param player: Player ID
        :param worker: worker as (x, y)
        :param depth: current tree depth
        """

        if depth >= self.look_ahead:
            return True

        for build in gen_builds(player, worker, self.__state.board,
                                self.checker):
            self.__state.push(build)
            winner = self.checker.check_game_over(self.__pid, self.__opponent)
            if winner == self.__opponent:
                return False
            if not self.check_move_states(self.other_player(player),
                                          depth + 1):
                return False
            self.__state.pop()
        return True