예제 #1
0
        private HashSet <GridState> seenStates;         //V současnosti se nevyužívá

        //Inicializace řešiče
        public Solver(Grid grid)
        {
            Grid = grid;
            GridState s = new GridState(grid);

            s.MakeForcedMoves();
            stack = new Stack <GridState>();
            stack.Push(s);
            seenStates = new HashSet <GridState>();
        }
예제 #2
0
            private GridState ConstructStateFromPath(int i, List <Point> path)
            {
                GridState newState = new GridState(this);

                foreach (Point p in path)
                {
                    newState.Cells[p.X, p.Y] = Branches[i].Color;
                    newState.Branches[i].Add(p);
                }
                newState.Branches[i].Solved = newState.Branches[i].Other.Solved = true;
                newState.MakeForcedMoves();
                return(newState);
            }
예제 #3
0
            private IEnumerable <GridState> BranchNextStates(int i) //Musí se chodit přes index
            {
                Point be         = Branches[i].Last();
                var   directions = Grid.Directions.Where(d => CanGoTo(Branches[i], d)).OrderBy(d => RateDirection(Branches[i], d)).ToList();

                foreach (Point d in directions)
                {
                    Point     np       = Grid.NeigbourCoordinates(be, d);
                    GridState newState = new GridState(this);
                    newState.Branches[i].Add(np);
                    newState.Cells[np.X, np.Y] = Cells[be.X, be.Y];
                    newState.MakeForcedMoves();
                    yield return(newState);
                }
            }