Exemplo n.º 1
0
        // this moves empties an "S" only
        // we want to leave S fixed !!!

        public void sosUnstackE(ref board tb, ref csosDisStrategy cds)
        {
            int    i, PosLastLetter, n = cds.UnstackMoves.Count;
            card   c;
            string srcLetter;   // from the pattern
            string desLetter = cds.Pattern.Substring(0, 1);
            string strPattern = cds.Pattern.Substring(1);
            string strSrc, strDes;
            int    FromStack = -1, ToStack = -1, FromCard = -1;
            int    e;

            tb.CopyWorkingInts(ref xEmpties, GlobalClass.WorkingType.tEmpties);
            for (i = 0; i < 3; i++)
            {
                xDepth[i] = 0;
            }


            for (i = 0; i < n; i++)
            {
                strSrc = cds.UnstackMoves[i].id_src;
                if (strSrc == "S")
                {
                    PosLastLetter = strPattern.Length - 1;
                    srcLetter     = strPattern.Substring(PosLastLetter, 1);
                    strPattern    = strPattern.Substring(0, PosLastLetter);
                    c             = dictLookup[srcLetter];
                    FromStack     = c.iStack;
                    FromCard      = c.iCard;
                }
                else
                {
                    e         = Convert.ToInt32(strSrc);
                    FromStack = xEmpties[e];
                    xDepth[e]--;
                    FromCard = xDepth[e];
                }
                strDes = cds.UnstackMoves[i].id_des;
                if (strDes == "S")
                {
                    c       = dictLookup[desLetter];
                    ToStack = c.iStack;
                }
                else
                {
                    e       = Convert.ToInt32(strDes);
                    ToStack = xEmpties[e];
                    xDepth[e]++;
                }
                tb.moveto(FromStack, FromCard, ToStack);
            }
        }
Exemplo n.º 2
0
        private void SOSorder(params object[] args)
        {
            int    iPtr = 0;
            int    NumVars = 0, NumEmptystacks = 0;
            string strSlots   = "";
            string strMoves   = "";
            string strPattern = "";


            foreach (object arg in args)
            {
                string strTemp = arg.ToString();
                switch (iPtr)
                {
                case 0: strPattern = strTemp;
                    NumVars        = strPattern.Length;
                    iPtr           = 1;
                    break;

                case 1: NumEmptystacks = Convert.ToInt32(strTemp);
                    iPtr = 2;
                    break;

                case 2: strSlots = strTemp;
                    iPtr         = 3;
                    break;

                case 3: strMoves = strTemp;
                    iPtr         = 0;
                    VerifyMoves(strMoves);
                    csosDisStrategy cds = new csosDisStrategy(NumEmptystacks, strPattern.Length, strPattern, strSlots, strMoves);
                    sosDisStrategy.Add(cds);
                    break;
                }
            }
        }