public PrecureChainList Solve(Precure precure) { PrecureChainList firstState = new PrecureChainList(PrecureList); firstState.Add(precure); PrecureChainList ans = firstState; _queue.Enqueue(firstState); while (_queue.Count > 0) { var curr = _queue.Dequeue(); ans = curr; foreach (var w in Candidate(curr.LastPrecure)) { if (ans.Find(x => x == w) != null) { continue; } curr.Add(w); _queue.Enqueue(curr.Clone()); curr.RemoveAt(curr.Count - 1); } } return(ans); }
public PrecureChainList Clone() { var wcl = new PrecureChainList(this.AllPrecures) { _chain = _chain.ToList() }; return(wcl); }