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>(); }
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); }
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); } }