示例#1
0
    def multiplayer_client(self, event):
        self.ip = self.entr.get()

        if not client.check_connection(self.ip):
            win = tkinter.Toplevel(self.window)
            lab = tkinter.Label(win, text="Wrong IP")
            lab.pack()
            return None

        save_ip(self.ip)
        self.two_players_variant('multiplayer_client')
        d = Data_Maker()

        def blocking_board(event):
            pass

        self.board.make_usability(blocking_board)
        state = client.get_state(self.board, load_ip())
        state = json.loads(state)
        state[1]['regim'] = 'multiplayer_client'
        d.decode_board(self.board, self.game, state)
示例#2
0
    def change_side(self, board):
        def blocking_board(event):
            pass

        self.move_whites = not self.move_whites
        if self.regim == 'multiplayer_client':
            d = datamaker.Data_Maker()
            state = json.dumps(d.encode_board(board, self))
            board.make_usability(blocking_board)
            client.send_state(state, board, load_ip())
            state = client.get_state(board, load_ip())
            state = json.loads(state)
            state[1]['regim'] = 'multiplayer_client'
            d.decode_board(board, self, state)
        if self.regim == 'multiplayer_server':
            d = datamaker.Data_Maker()
            state = json.dumps(d.encode_board(board, self))
            board.make_usability(blocking_board)
            server.send_state(state, board)
            state = server.get_state(board)
            state = json.loads(state)
            state[1]['regim'] = 'multiplayer_server'
            d.decode_board(board, self, state)
示例#3
0
                return "left"
            else:
                return "right"
        else:
            # We can stop turning now
            if distance > Bounds.MAX_DISTANCE:
                # But we need to move closer
                return "forward"
            else:
                # We are close enough
                return "stop"


action = "stop"

while True:
    state = client.get_state()

    if MY_NUM not in state["labels"] or TARGET_NUM not in state["labels"]:
        continue

    my_pose = state["labels"][MY_NUM]
    target_pose = state["labels"][TARGET_NUM]

    action = next_action(my_pose, target_pose, action)

    print(action)

    robot.action(action)
    time.sleep(0.2)
示例#4
0
 def reset(self):
     self.curr_state = client.get_state()
     return self.curr_state
示例#5
0
 def step(self, action):
     client.set_speed(action)
     next_state = client.get_state()
     reward = self.get_reward(self.curr_state, next_state)
     done = False
     return obs, reward, done, None