private double trial() { Percolation perc = new Percolation(this.gridsize); int x, y; int i; for (i = 0; i < this.gridsize * this.gridsize; i++) { do { x = StdRandom.uniform(this.gridsize) + 1; y = StdRandom.uniform(this.gridsize) + 1; } while (perc.isOpen(x, y)); perc.open(x, y); if (perc.percolates()) { return i / ((double) this.gridsize * this.gridsize); } } throw new IndexOutOfBoundsException("Opened all sites, but no percolation (?!)"); }