//this is for testing purposes public GridState NextState() { while (stack.Any()) { GridState s = stack.Pop(); CountScenarios++; foreach (GridState ns in s.NextStates().Reverse()) { stack.Push(ns); } return(s); } return(new GridState(Grid)); }
//Prohledávání do hloubky pomocí zásobníku public GridState SolveConnections(System.ComponentModel.BackgroundWorker bw) { while (stack.Any()) { if (bw != null && bw.CancellationPending) { break; } GridState s = stack.Pop(); CountScenarios++; if (s.Solved) { return(s); } foreach (GridState ns in s.NextStates().Reverse()) { stack.Push(ns); } } return(new GridState(Grid)); }