예제 #1
0
파일: DFS.cs 프로젝트: InessPopa/AITetris
        public void DFSUtil(int v, bool[] visited, int x, int y, Grid grid, GridRepo gridRepo, Graph graph)
        {
            visited[v] = true;

            Grid  aux = gridRepo.gridRepo.ElementAt(v);
            Tuple tup;

            if (graph.isLeaf(v))
            {
                tup = aux.gridSize();
                if (x * y > tup.getX() * tup.getY())
                {
                    this.grid.setGrid(aux.grid);
                    setMinX(tup.getX());
                    setMinY(tup.getY());
                }
            }

            IEnumerator <int> i = graph.adj.ElementAt(v).GetEnumerator();
            bool hasNext        = i.MoveNext();

            while (hasNext)
            {
                int n = i.Current;
                hasNext = i.MoveNext();
                if (!visited[n])
                {
                    DFSUtil(n, visited, this.getMinX(), this.getMinY(), this.grid, gridRepo, graph);
                }
            }
        }
예제 #2
0
파일: GBFS.cs 프로젝트: InessPopa/AITetris
        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);
            }
        }