public ArrayList<Position> getMoves(Position p) {
    String e = ask("moves:" + p.getX() + ":" + p.getY() + ";");
    ArrayList<Position> m = new ArrayList<Position>();

    String[] o = e.split(":");
    for (int i = 0; i < o.length; i = i + 2) {
      m.add(new Position(Integer.parseInt(o[i]), Integer.parseInt(o[i + 1])));
    }

    return m;
  }
  private boolean atMaxLevel(DrawContext dc) {
    Position vpc = dc.getViewportCenterPosition();
    if (dc.getView() == null || this.getLevels() == null || vpc == null) return false;

    if (!this.getLevels().getSector().contains(vpc.getLatitude(), vpc.getLongitude())) return true;

    Level nextToLast = this.getLevels().getNextToLastLevel();
    if (nextToLast == null) return true;

    Sector centerSector =
        nextToLast.computeSectorForPosition(
            vpc.getLatitude(), vpc.getLongitude(), this.getLevels().getTileOrigin());
    return this.needToSplit(dc, centerSector);
  }
 public void move(Piece p, Position pos) {
   String s =
       ask(
           "move:"
               + p.getPos().getX()
               + ":"
               + p.getPos().getY()
               + ":"
               + pos.getX()
               + ":"
               + pos.getY()
               + ";");
   System.out.println(s);
 }
  private Vec4 computeReferencePoint(DrawContext dc) {
    if (dc.getViewportCenterPosition() != null)
      return dc.getGlobe().computePointFromPosition(dc.getViewportCenterPosition());

    java.awt.geom.Rectangle2D viewport = dc.getView().getViewport();
    int x = (int) viewport.getWidth() / 2;
    for (int y = (int) (0.5 * viewport.getHeight()); y >= 0; y--) {
      Position pos = dc.getView().computePositionFromScreenPoint(x, y);
      if (pos == null) continue;

      return dc.getGlobe().computePointFromPosition(pos.getLatitude(), pos.getLongitude(), 0d);
    }

    return null;
  }
  // board stuff
  public Piece getNet(Position p) {
    Piece tmp = null;

    String b = ask("get:" + p.getX() + ":" + p.getY() + ";");
    String[] cms = b.split(":");

    if (cms[0].equals("n")) {
      return tmp;
    }
    char[] chr = cms[0].toCharArray();
    char c = chr[0];
    Player s = new Player(cms[2].equals("b"), null);
    int l = Integer.parseInt(cms[1]);

    if (c == 'P') tmp = new Pawn(p, l, s);
    else if (c == 'R') tmp = new Rook(p, l, s);
    else if (c == 'K') tmp = new Knight(p, l, s);
    else if (c == 'B') tmp = new Bishop(p, l, s);
    else if (c == 'Q') tmp = new Queen(p, l, s);
    else if (c == '!') tmp = new King(p, l, s);

    return tmp;
  }