private bool FindPlace4(Grid grid, int nrForm, int i, int j, bool found, Graph graph) { int n = grid.getN(); int nr = grid.getNrDisplay(); int[,] table = new int[n, n]; for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { table[x, y] = grid.getGrid()[x, y]; } } Grid grid1 = new Grid(table, n, nr, -1); if (i < 2) { return(found); } else if (j + 1 == grid.getN() && grid.getRowSumOFGrid(i) == 0 && grid.getRowSumOFGrid(i + 1) == 0 && grid.getRowSumOFGrid(i + 2) == 0) { return(found); } else if (j + 1 == grid.getN()) { return(FindPlace4(grid, nrForm, i - 1, 0, found, graph)); } else if (grid1.PutTetris(nrForm, i, j)) { grid1.setNrGrid(this.GetNr()); graph.addEdge(grid.getNrGrid(), this.GetNr()); graph.AddVertice(); int x = this.GetNr() + 1; this.SetNr(x); gridRepo.addGrid(grid1); found = true; return(FindPlace4(grid, nrForm, i, j + 1, found, graph)); } else { return(FindPlace4(grid, nrForm, i, j + 1, found, graph)); } }
public int tetrisHeight(Grid grid) { int height = 0; while (height < 8 && grid.getRowSumOFGrid(height) == 0) { height++; } return(8 - height); }