Exemplo n.º 1
0
 def __init__(self,
              initial_state=INI_STATE,
              additional_predicates=(),
              background=(),
              block_n=4,
              all_block=False):
     actions = [MOVE]
     self.max_step = 50
     self._block_encoding = {
         "a": 1,
         "b": 2,
         "c": 3,
         "d": 4,
         "e": 5,
         "f": 6,
         "g": 7
     }
     self.state_dim = MAX_WIDTH**3
     if all_block:
         self._all_blocks = list(
             string.ascii_lowercase)[:MAX_WIDTH] + ["floor"]
     else:
         self._all_blocks = list(
             string.ascii_lowercase)[:block_n] + ["floor"]
     self.language = LanguageFrame(actions,
                                   extensional=[ON, FLOOR, TOP] +
                                   list(additional_predicates),
                                   constants=self._all_blocks)
     self._additional_predicates = additional_predicates
     background = list(background)
     background.append(Atom(FLOOR, ["floor"]))
     # background.extend([Atom(BLOCK, [b]) for b in list(string.ascii_lowercase)[:block_n]])
     super(BlockWorld, self).__init__(background, initial_state, actions)
     self._block_n = block_n
Exemplo n.º 2
0
 def __init__(self, width=3, know_valid_pos=True):
     actions = [PLACE]
     self.language = LanguageFrame(actions, extensional=[ZERO, MINE, EMPTY, OPPONENT, SUCC],
                                   constants=[str(i) for i in range(width)])
     background = []
     #background.extend([Atom(LESS, [str(i), str(j)]) for i in range(0, WIDTH)
     #                   for j in range(0, WIDTH) if i < j])
     background.extend([Atom(SUCC, [str(i), str(i + 1)]) for i in range(width - 1)])
     background.append(Atom(ZERO, ["0"]))
     self.max_step = 50
     initial_state = np.zeros([3,3])
     super(TicTacTeo, self).__init__(background, initial_state, actions)
     self.width = width
     self.all_positions = [(i, j) for i in range(width) for j in range(width)]
     self.know_valid_pos = know_valid_pos
     self.action_n = len(self.all_positions)
     self.state_dim = width**2
Exemplo n.º 3
0
class TicTacTeo(SymbolicEnvironment):
    all_variations = ("n")
    def __init__(self, width=3, know_valid_pos=True,case = []):
        actions = [PLACE]
        self.language = LanguageFrame(actions, extensional=[ZERO, MINE, EMPTY, OPPONENT, SUCC],
                                      constants=[str(i) for i in range(width)])
        background = []
        #background.extend([Atom(LESS, [str(i), str(j)]) for i in range(0, WIDTH)
        #                   for j in range(0, WIDTH) if i < j])
        background.extend([Atom(SUCC, [str(i), str(i + 1)]) for i in range(width - 1)])
        background.append(Atom(ZERO, ["0"]))
        self.max_step = 50
        initial_state = np.zeros([3,3])
        self.case = case
        #init = np.zeros([3,3])
        if len(case)==0:
            initial_state = np.zeros([3,3])
Exemplo n.º 4
0
 def __init__(self, initial_state=("0", "0"), width=5):
     actions = [UP, DOWN, LEFT, RIGHT]
     self.language = LanguageFrame(actions, extensional=[ZERO, SUCC, CURRENT, LAST],
                                   constants=[str(i) for i in range(width)])
     background = []
     self.unseen_background = []
     self.unseen_background.extend([Atom(CLIFF, [str(x), "0"]) for x in range(1, width - 1)])
     self.unseen_background.append(Atom(GOAL, [str(width - 1), "0"]))
     background.append(Atom(LAST, [str(width - 1)]))
     #background.extend([Atom(CLIFF, [str(x), "0"]) for x in range(1, WIDTH-1)])
     #background.extend([Atom(LESS, [str(i), str(j)]) for i in range(0, width)
     #                   for j in range(0, width) if i < j])
     background.extend([Atom(SUCC, [str(i), str(i+1)]) for i in range(width - 1)])
     background.append(Atom(ZERO, ["0"]))
     #background.extend([Atom(CLIFF, ["1", str(y)]) for y in range(2, WIDTH)])
     #background.extend([Atom(CLIFF, ["3", str(y)]) for y in range(1, WIDTH-1)])
     super(CliffWalking, self).__init__(background, initial_state, actions)
     self.max_step = 50
     self.state_dim = 2
     self.all_actions = actions
     self.width=width