LARG / HFO

Half Field Offense in Robocup 2D Soccer
MIT License
232 stars 93 forks source link

wrapping HFO for Multi-agents RL #121

Open torressliu opened 2 years ago

torressliu commented 2 years ago

Hello, what I am doing is packaging HFO into a GYM environment for multi-agent reinforcement learning algorithms. To always maintain the connection between the algorithm and the HFO server. I will" hfo_env connectToServer (hfo. LOW_LEVEL_FEATURE_SET, '/root/autodl-tmp/HFO-master/bin/teams/base/config/formations-dt', Args. Port, 'localhost', 'base_left', False) "wraps to a thread. And keep the thread in a loop. However, the connection still cannot be maintained and the server will down. And it is no use to add"config.set_serverWaitSeconds(500);//add" in HFO.cpp, Do you know why? My thread code is at the bottom. image image

class Player(threading.Thread):

def __init__(self, queue_state, queue_status, queue_next,queue_action, mark, *args, **kwargs):
    super(Player, self).__init__(*args, **kwargs)
    self.__flag = threading.Event()     # 用于暂停线程的标识
    self.__flag.set()       # 设置为True
    #self.__flag.clear()
    self.__running = threading.Event()      # 用于停止线程的标识
    self.__running.set()      # 将running设置为True
    self.hfo_env = hfo.HFOEnvironment()
    self.__reset = False
    self.__step = False
    self.__close = False
    self.action = 0# or 
    self.next_state = np.zeros([state_space]) 
    self.status=1
    self.state = np.zeros([state_space])
    self.mark=mark
    self.queue_state=queue_state
    self.queue_action=queue_action
    self.queue_status=queue_status
    self.queue_next=queue_next

def run(self):
    self.hfo_env.connectToServer(hfo.LOW_LEVEL_FEATURE_SET,
                        '/root/autodl-tmp/HFO-master/bin/teams/base/config/formations-dt',
                        6000, 'localhost', 'base_left', False)

@mhauskn

fanchunpeng commented 2 years ago

兄弟,你搞的咋样的,我最近也在研究如何把HFO改成多智能体,没搞出来? 你这个错误是:两个thread之间要加延时就可以了,time.sleep(5).

torressliu commented 2 years ago

Hi ,chunpeng. My MA-HFO wrapper is finished.however, the reward functions is not very suitful . we can create a wechat group if you like.