Пример #1
0
        // this is done from the startup program -or-
        // it could be done from DealStrategy where new boards are created
        // from a bunch of boards that have empty columns
        public void AddInitialBoard(ref board nb, int TypeInitialBoard, ref csuitable Suitable)
        {
            int desptr;

            int[] des     = new int[112];
            Int64 ChkWord = 0;

            this.Suitable = Suitable;
            bool bInsertFailed = false;

            switch (TypeInitialBoard)
            {
            case GlobalClass.FIRST_CARD:
                int tsbCount = 0;
                nb.ComputeRemainingSuits();
                LastBest          = nb.score - 1;
                cSC.BestScore     = LastBest;
                nb.TimeOfLastDeal = DateTime.Now;
                nb.DealCounter    = 5 - nb.ThisColumn[10].Cards.Count / 10;
                // if there are 20 cards left, we must have dealt 3 times

                nb.MyMoves.AddMoveInfo(TypeInitialBoard, nb.DealCounter, 0);
                nb.from = -1;       // didnt come from another board
                desptr  = nb.FormVerify(ref des, ref ChkWord);
                cSC.stlookup.bIsNewBoard(ChkWord, desptr, ref des, nb.MyMoves.TheseMoves.Count, ref tsbCount, ref bInsertFailed);
                Debug.Assert(!bInsertFailed);
                Debug.Assert(0 == tsbCount);
                break;

            case GlobalClass.DEALT_A_CARD:

                break;
            }
            AddNewBoard(ref nb);
        }
Пример #2
0
        // this gets rid of as many facedown cards as possible
        // this should be run only if suits are locked out and only a few suits are remaining
        public int TryUnstackAll(ref board oldtb)
        {
            int Any;
            int Total = 0;
            int ne    = oldtb.NumEmptyColumns;
            int ru    = oldtb.UnexposedTypes.Count;
            int rs    = oldtb.ComputeRemainingSuits();

            if (rs > 3)
            {
                return(0);          // the works best with only a few suits
            }
            if (ru > ne)
            {
                return(0);         // need a bunch of empty columns for sure
            }
            if (oldtb.DealCounter < 5)
            {
                return(0);                          // only on last deal
            }
            board tb = new board(ref oldtb);

            tb.AssignCompletedID(GlobalClass.TypeCompletedBy.ID_USTK);
            //tb.ShowBoard();

            Any = TryUnstackOne(ref tb, ref Total);

            //do
            //{
            //    Any = TryUnstackOne(ref tb);
            //    if (Any > 0)
            //    {
            //        tb.ReScoreBoard();
            //        Total += Any;
            //    }
            //} while (Any > 0);
            //tb.ExplainBoard("did unstack");
            tb.AssignCompletedID();
            NewBoards.Add(tb);
            return(Total);
        }