public KlondikeStatus Copy() { var status = new KlondikeStatus(); for (int i = 0; i < idToFace.Length; i++) { status.idToFace[i] = idToFace[i]; } // for (int i = 0; i < allList.Length; i++) // { // status.allList[i].AddRange(allList[i]); // } Copy(foundations[0], status.foundations[0]); Copy(foundations[1], status.foundations[1]); Copy(foundations[2], status.foundations[2]); Copy(foundations[3], status.foundations[3]); Copy(tableaus[0], status.tableaus[0]); Copy(tableaus[1], status.tableaus[1]); Copy(tableaus[2], status.tableaus[2]); Copy(tableaus[3], status.tableaus[3]); Copy(tableaus[4], status.tableaus[4]); Copy(tableaus[5], status.tableaus[5]); Copy(tableaus[6], status.tableaus[6]); Copy(waste, status.waste); Copy(stock, status.stock); return(status); }
public StatusNode AddChild(KlondikeStatus status) { var node = new StatusNode(); node.parent = this; node.status = status; children.Add(node); return(node); }
//search a win path from board //how to store board //how to print path public void CompletelySearch(int[] board) { searchCount = 0; statusTree.Clear(); winPaths.Clear(); var status = new KlondikeStatus(); status.FromBoard(board); statusTree.SetupRoot(status); SearchDepthFirst(statusTree.root); Console.WriteLine("searchCount: " + searchCount); }
public static string GetToNextStatusOps(KlondikeStatus s1, KlondikeStatus s2) { for (var id = 1; id < 53; id++) { var p1 = s1.GetParent(id); var p2 = s2.GetParent(id); if (s1.GetParentIndex(p1) != s2.GetParentIndex(p2)) { var card = id; if (s1.BelongTableau(p1)) { card = s1.GetFirstFaceUp(p1); } return(string.Format("{0},<{1},{2}> -> {3}, {4}", s1.GetParentName(p1), _SuitC(card), _RankStr(card), s2.GetParentName(p2), s1.GetFaceBacksTableau())); } } return(string.Empty); }
public String GetParentToCurrentOps() { var listPath = new List <StatusNode>(); var node = this; while (node != null) { listPath.Add(node); node = node.parent; } listPath.Reverse(); var sbd = new StringBuilder(); sbd.AppendFormat("ops:{0}", listPath.Count).AppendLine(); for (var i = 0; i < listPath.Count - 1; i++) { var one = listPath[i]; var next = listPath[i + 1]; sbd.AppendFormat("{0}:{1}", KlondikeStatus.DoubleNumber(i + 1), KlondikeStatus.GetToNextStatusOps(one.status, next.status)).AppendLine(); } return(sbd.ToString()); }
public void AddChild(KlondikeStatus status) { root.AddChild(status); }
public void SetupRoot(KlondikeStatus status) { root.status = status; }