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 void GBFSUtil(int parent, bool[] visited, int x, int y, Grid grid, GridRepo gridRepo, Graph graph) { visited[parent] = true; Grid aux = gridRepo.gridRepo.ElementAt(parent); Tuple tup; if (graph.isLeaf(parent)) { tup = aux.gridSize(); if (x * y > tup.getX() * tup.getY()) { this.getT().setGrid(aux.getGrid()); setMinX(tup.getX()); setMinY(tup.getY()); } } else { int kid = graph.findMin(gridRepo, parent); GBFSUtil(kid, visited, this.getMinX(), this.getMinY(), this.getT(), gridRepo, graph); } }