public void run() {
        board.setLocation(0, 0);
        board.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        board.add(this);
        board.pack();
        board.setVisible(true);
        initializeUnits(this);
        board.addMouseListener(new MouseListener() {
            public void mouseReleased(MouseEvent e) {
                int x = e.getX() / scale - 1;
                int y = width - (e.getY() - scale / 2) / scale;
                if (turn && client == null) {
                    server.send(x + " " + y);
                    act(x, y);
                } else if (!turn && server == null) {
                    client.send(x + " " + y);
                    act(x, y);
                }
            }
            public void mousePressed(MouseEvent e) {}
            public void mouseExited(MouseEvent e) {}
            public void mouseEntered(MouseEvent e) {}
            public void mouseClicked(MouseEvent e) {}
        });
        while (true) {
            if (server == null && turn) {
                //System.out.println("your turn");
                String[] read = client.read().split(" ");
                int x = Integer.parseInt(read[0]);
                int y = Integer.parseInt(read[1]);
                //System.out.println(read);
                act(x, y);
            } else if (client == null && !turn) {
                //System.out.println("your turn");
                String[] read = server.read().split(" ");
                int x = Integer.parseInt(read[0]);
                int y = Integer.parseInt(read[1]);
                //System.out.println(read);
                act(x, y);
            }
        }
    }