public static pseudoCard CVTMoveValueToInfo(cMoveData cMD) { pseudoCard pCard = new pseudoCard(cMD.ID); pCard.score = cMD.Score; pCard.desID = cMD.Des; pCard.iStack = cMD.Src; pCard.desID_is_iStack = true; return(pCard); }
public static bool GetCurrentLocation(ref board tb, ref pseudoCard pCard) { pCard.size = -1; int LastRank = 0, LastSuit = -1; foreach (column cCol in tb.ThisColumn) { if (cCol.iStack > 9) { break; } foreach (card cCrd in cCol.Cards) { if (cCrd.ID == pCard.ID) { pCard.iStack = cCrd.iStack; pCard.iCard = cCrd.iCard; pCard.size = 0; LastRank = cCrd.rank; LastSuit = cCrd.suit; } if (pCard.size >= 0) { Debug.Assert(LastRank == (cCrd.rank + 1) && (LastSuit == cCrd.suit)); if (LastRank == (cCrd.rank + 1) && (LastSuit == cCrd.suit)) { return(false); } pCard.size++; LastRank = cCrd.rank; LastSuit = cCrd.suit; } } if (pCard.size > 0) { return(true); } } Debug.Assert(false); return(false); }
// dont call this unless it was sorted by rank // this does not handle card subsets that are in the same column public bool JoinAnyLikeSuits(ref board tb) { if (cSC.bTrigger) { Console.WriteLine(MethodBase.GetCurrentMethod().Name); } series sDes, sSrc; int PossibleCostReduction; int RankWanted, LowestRank, RankWantedLoc; PsuedoMoveList.Clear(); //foreach (series s1 in tb.SortedSEQ) for (int i = 0; i < tb.SortedSEQ.Count - 1; i++) { sDes = tb.SortedSEQ[i]; // biggest is first in sorted order of ranks PossibleCostReduction = sDes.bRankable ? 1 : 0; //foreach (series s2 in tb.SortedSEQ) for (int j = i + 1; j < tb.SortedSEQ.Count; j++) { sSrc = tb.SortedSEQ[j]; if (sSrc.sSuit != sDes.sSuit) { continue; // in event more then one suit is in the sorted list } PossibleCostReduction += sSrc.bRankable ? 1 : 0; // the 1 below represents possibly a single available placeholder if (sDes.nEmptiesToUnstack + sSrc.nEmptiesToUnstack > (tb.NumEmptyColumns + 1 + PossibleCostReduction)) { return(false); } if (sDes.iStack == sSrc.iStack) { continue; } // make s1 (bottom) the destination and s2 (top) the source (ranks must be different) if (sDes.topCard.rank == sSrc.topCard.rank) { continue; // nothing to join } // 9..6 could join to 6..3 by moveing only the 5..3 if it exists RankWanted = sDes.bottomCard.rank - 1; // find a card in source to be mvoed that is this rank LowestRank = sSrc.bottomCard.rank; if (!(RankWanted > LowestRank && sSrc.topCard.rank >= RankWanted)) { continue; } // figure out where that card is in the source to be moved RankWantedLoc = sSrc.top + (1 + sSrc.topCard.rank - sDes.bottomCard.rank); card cSrc = tb.ThisColumn[sSrc.iStack].Cards[RankWantedLoc]; Debug.Assert(RankWanted == cSrc.rank); sSrc.size -= (1 + sSrc.topCard.rank - sDes.bottomCard.rank); sSrc.topCard = cSrc; sSrc.top = cSrc.iCard; if (sSrc.nEmptiesToUnstack == 0 && sDes.nEmptiesToUnstack == 0) { tb.moveto(cSrc.iStack, cSrc.iCard, sSrc.bottomCard.iStack); return(true); } pseudoCard pCard = new pseudoCard(sDes.topCard.ID, sSrc.bottomCard.ID, true); PsuedoMoveList.Insert(0, pCard); if (sSrc.nEmptiesToUnstack > 0) { if (!UnstackBelow(ref sSrc)) { return(false); } } if (sDes.nEmptiesToUnstack > 0) { if (!UnstackBelow(ref sDes)) { return(false); } } return(JoinPsudos()); } } return(false); }