(self)
| 55 | self.s2c = pipe_s2c |
| 56 | |
| 57 | def run(self): |
| 58 | enable_death_signal() |
| 59 | player = self._build_player() |
| 60 | context = zmq.Context() |
| 61 | c2s_socket = context.socket(zmq.PUSH) |
| 62 | c2s_socket.setsockopt(zmq.IDENTITY, self.identity) |
| 63 | c2s_socket.set_hwm(2) |
| 64 | c2s_socket.connect(self.c2s) |
| 65 | |
| 66 | s2c_socket = context.socket(zmq.DEALER) |
| 67 | s2c_socket.setsockopt(zmq.IDENTITY, self.identity) |
| 68 | s2c_socket.connect(self.s2c) |
| 69 | |
| 70 | state = player.reset() |
| 71 | reward, isOver = 0, False |
| 72 | while True: |
| 73 | # after taking the last action, get to this state and get this reward/isOver. |
| 74 | # If isOver, get to the next-episode state immediately. |
| 75 | # This tuple is not the same as the one put into the memory buffer |
| 76 | c2s_socket.send(dumps( |
| 77 | (self.identity, state, reward, isOver)), |
| 78 | copy=False) |
| 79 | action = loads(s2c_socket.recv(copy=False)) |
| 80 | state, reward, isOver, _ = player.step(action) |
| 81 | if isOver: |
| 82 | state = player.reset() |
| 83 | |
| 84 | @abstractmethod |
| 85 | def _build_player(self): |
nothing calls this directly
no test coverage detected