public StatusNode TryMoveStatus(StatusNode node) { //tableau to tableau makes card flip //tableau to foundation //(waste or stock) to foundation //(waste or stock) to table //foundation to table //how to decide a status is win //if all tableau cards are faceup then win //how to decide a status is faild //if move many count but tableau still have back card //when should stop //1 win //2 faild return(null); }
void SearchDepthFirst(StatusNode node) { searchCount++; Console.WriteLine(string.Format("f1: {0}, f2: {1}, search:{2}", faild1Count, faild2Count, searchCount)); if (winPaths.Count > 0) { return; } /** * in a node i know a status A * find all card transform add to Ts * for each T in Ts * got a new status node B * if B is win * find a win path * else if B is faild * find a faild path * else * SearchDeepthFirst(B) * search from A with Next T in Ts */ // { // var ctfs = node.status.ComputeAllCardTransform(); // foreach(var ctf in ctfs){ // var nextStatus = node.status.GetNextStatus(ctf); // var nextNode = node.AddChild(nextStatus); // if(nextStatus.IsWin){ // winPaths.Add(nextNode); // Console.WriteLine("find a new win path, total:{0}", winPaths.Count); // }else if(nextNode.IsFaildStatus){ // }else{ // SearchDepthFirst(nextNode); // } // } // } { var allNextStatus = node.status.GetAllNextStatus(); if (allNextStatus.Count > 0) { foreach (var nextStatus in allNextStatus) { var nextNode = node.AddChild(nextStatus); if (nextStatus.IsWin) { winPaths.Add(nextNode); Console.WriteLine("find a win path"); SaveAWinToFile(nextNode.GetParentToCurrentOps()); } else if (nextNode.IsFaildStatus) { faild1Count++; } else { SearchDepthFirst(nextNode); } } } else { faild2Count++; } } }
void SearchBreadthFirst(StatusNode node) { }