Beispiel #1
0
 def actions(self, state):
     if self.is_game_over(state):
         return "STOP"
     la = np.array(['UP', 'DOWN', 'RIGHT', 'LEFT'])
     is_legals_actions = np.array(
         [is_in_grid(move(state[0], a), self._grid.shape) for a in la])
     return la[is_legals_actions].tolist()
Beispiel #2
0
    def result(self, state, action):
        pos = state[0]
        elems_state = list(state[1])
        nb_propellers = state[2]

        next_pos = move(pos, action)

        if is_in_grid(next_pos, self._grid.shape):
            pos = next_pos
            ind_next_e = self._e_ij(*next_pos)
            next_e = elems_state[ind_next_e]

            if next_e == "R":
                nb_propellers = max(nb_propellers - 1, 0)

            elems_state[ind_next_e] = elem_rules_trans(next_e, self._earth_mode)

        return (pos, "".join(elems_state), nb_propellers)
Beispiel #3
0
    def result(self, state, action):
        pos = state[0]
        elems_state = list(state[1])
        nb_propellers = state[2]

        next_pos = move(pos, action)

        if is_in_grid(next_pos, self._grid.shape):
            pos = next_pos
            ind_next_e = self._e_ij(*next_pos)
            next_e = elems_state[ind_next_e]

            if next_e == 'R':
                nb_propellers = max(nb_propellers - 1, 0)

            elems_state[ind_next_e] = elem_rules_trans(next_e,
                                                       self._earth_mode)

        return (pos, ''.join(elems_state), nb_propellers)
Beispiel #4
0
 def actions(self, state):
     if self.is_game_over(state):
         return "STOP"
     la = np.array(["UP", "DOWN", "RIGHT", "LEFT"])
     is_legals_actions = np.array([is_in_grid(move(state[0], a), self._grid.shape) for a in la])
     return la[is_legals_actions].tolist()