TrenchOOMDPClass.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:simple_rl 作者: david-abel 项目源码 文件源码
def agent_place(self, state):
        next_state = copy.deepcopy(state)

        agent = next_state.get_first_obj_of_class("agent")

        agent.set_attribute("has_block", 0)
        next_x = agent.get_attribute("x") + agent.get_attribute("dx")
        next_y = agent.get_attribute("y") + agent.get_attribute("dy")

        if self._is_lava_state_action(next_state, "forward"):
            lava_remove = 0
            for l in next_state.get_objects_of_class("lava"):
                if next_x == l.get_attribute("x") and next_y == l.get_attribute("y"):
                    break
                lava_remove += 1

            next_state.get_objects_of_class("lava").pop(lava_remove)
        else:
            new_block = {"x": next_x, "y": next_y}
            new_block_obj = self._make_oomdp_objs_from_list_of_dict([new_block], "block")
            next_state.get_objects_of_class("block").append(new_block_obj[0])

        return next_state
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号