public int probe(int x, int y) {
    if (finished)
      return look(x, y);
    else if (x < 0 || x >= c || y < 0 || y >= r)
      return OUT_OF_BOUNDS;
    else if (mark_map[y][x])
      return MARKED;
    unprobed_map[y][x] = false;
    if (mine_map[y][x] < 0) {
	if (realrules) {
	    // find non-mine
	    int tx,ty;
	    do {
		tx=pick(c);
		ty=pick(r);
	    } while (mine_map[ty][tx]<0);
	    // swap
	    mine_map[ty][tx]=mine_map[y][x];
	    mine_map[y][x]=0;
	    computeweights();
	}
	else
	    finished = true;
    }
    realrules=false;
    return mine_map[y][x];
  }