public void paintComponent(Graphics g) {
        super.paintComponent(g);

        Dimension ds = getSize();
        d = Math.min(ds.width, ds.height) - 5;
        float strokeWidth = (float) d / 200.0f;
        stroke = new BasicStroke(strokeWidth);
        Graphics2D g2d = (Graphics2D) g;
        g2d.setStroke(stroke);
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        if (d <= 0)
            return;
        g.clearRect(0, 0, ds.width, ds.height);
        g.translate((ds.width - d) / 2, (ds.height - d) / 2);
        g.setColor(Color.black);
        g.drawRect(0, 0, d, d);
        for (int i = 0; i < agents.length; i++)
            agents[i].paintComponent(g, d);
    }