Git Product home page Git Product logo

alpharobot's Introduction

Alpha Robot

General

The code is using the MCTS based on A* as the final policy. But there are still bugs to be figured out in the environment(not our developers' faults). The Version-0 environment has wrong utils.py for sampling. The Version-1 environment has wrong __pycache__ in grid_map_env\classes which causes some weird phenomenon. Although the Version-2 fixed the bug in version-1, it also carelessly changes the probability of noise, which is subject to severely affect the MCTS's decisions. So the most correct environment has not been released by TAs, we are expecting the TAs to fix all the bugs then let our model perform at best.

--Developer Xiaoyang Liu

debug开关

由于pythonprint会导致性能损失 请使用统一定义的DEBUGbool常量确定是否需要debug数据输出

argv定义

  • condition : (row,col,direction,speed)
  • position : (row,col)
  • robot_state : 对应函数建议加上"_RS"后缀以区分

方向统一定义

请统一化方向对 (row,col) 的正负改变方向

DIR_OFFSET=((0,-1),(-1,0),(0,1),(1,0))      #定义不同方向的行为,每次运动会导致 (row,col)+=DIR_OFFSET[direction]
                                            #**请统一使用这一标准,并使用这个常量变换offset和direction**
#请使用如下转换
offsets=DIR_OFFSET[direction]
direction=DIR_OFFSET.index(offsets)

#或者
offsets=self.direction_to_offset(direction)
direction=self.offset_to_direction(offsets)

确定终点

Calibrate_target(self,house_map)->None: 将会遍历检查终点,并记录在self.target中 为了减少计算,请在初始化时调用 并使用self.target确定终点位置

policy编码方式

如果需要使用查表的policy定义方式,可以考虑如下定义

#key为(row,col,direction,speed)
#value编码如下
#policy         -1: 减速
#               1: 加速
#               0: 保持
#               10+x: x是希望的方向(应该只能在speed==0时返回)
#               -404: 默认,代表未定义该状态
# **请使用rlt=self.policy.get(condition,-404),将默认返回设置为-404**

这也是A*所使用的方式

get_Action_from_policy(self,robot_state,condition,policy_source)->Action 可以使用上述函数快捷从policy得到Action

预估消耗步数

line_cost(self,l)->int: 该函数会计算以0起始速度加速后减速停止,移动l距离所需要的最小步数

Heuristic(self,position,direction=None)->int A*所使用的Heuristic

确认是否可通行(包括数值范围检查)

Space_check(self,house_map,position)->bool 一个is_collision()的包装函数,同时检查数值范围是否合法

估算错误率(在线)

不确定的错误率,提供了一个错误率预估函数 def check_err_rate(self,house_map,robot_state,ag)->Action 将您的算法作为ag的值 该函数会使用ag计算Action并且自动在下次调用中检查上次操作是否存在噪声

#err rate check使用
self.simul_expected=None    #期待的下一个状态
self.simul_step_count=0     #获取Action总次数
self.simul_err_count=0      #出现噪声的次数

A* part

A_Star(self,house_map,robot_state)->Action A*的总入口,直接返回Action 是将下列的文件

A_Star_path_init(self,house_map,robot_state)->None 初始化A*,包括确定终点,初始化最小堆 同时会使用robot_stateself.A_start_conditio赋值

A_Star_path_calculate(self,house_map)->None 对A*进行计算,会在时间或者pop限制用完后自动返回 总会计算得到self.A_rout

  1. 计算限制达到,self.A_full_path=False 这时self.A_rout会引导走向最后pop的点
  2. 计算限制未达到,self.A_full_path=True 这时self.A_rout会引导走向终点

|self.A_rout的结构||||||||| |:---:|:---:|:---:|:---:|:---:|:---:| |self.A_rout[0]|||self.A_rout[1]|||...|self.A_rout[n]|| | row |col|direction to next node| row |col|direction to next node|...|row |col|

A_Policy_generation(self)->None 将会使用self.A_rout的内容为self.A_policy赋值

#self.A_policy  -1: 减速
#               1: 加速
#               0: 保持
#               10+x: x是希望的方向(应该只能在speed==0时返回)
#               -404: 默认,代表未定义该状态
# **请使用rlt=self.policy.get(condition,-404),将默认返回设置为-404**

Heuristic(self,position,direction=None)->int A*所使用的Heuristic

alpharobot's People

Contributors

xiaoyangliu39 avatar neverendingsnow avatar chenyuhengsjtu avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.