Ejemplo n.º 1
0
        //获取指定列的BreakStats
        BreakState GetBreakStats(int column)
        {
            BreakState res = new BreakState();

            res.Column        = column;
            res.isPerFect     = IsPerfect(column);
            res.canBreak      = CanBreak(column);
            res.EmptySpace    = GetSapceCount(column);
            res.isSingleColor = IsSingleColor(column);
            res.TopColorCount = TopColorCount(column);

            return(res);
        }
Ejemplo n.º 2
0
        //这里可能会设置 AnOtherBreakStep 下一步打破步骤,避免回测
        private void BreakStep()
        {
            //遍历容器,设置breakStats
            for (int i = 0; i < NCol; i++)
            {
                breakStats[i] = GetBreakStats(i);
            }
            //查找需要打破的列数,
            int BreakColumn = GetBreakColumn();

            Console.WriteLine("很麻烦呀" + BreakColumn);
            BreakState needBreakStats = breakStats[BreakColumn];
            int        TopCount       = needBreakStats.TopColorCount;
            Step       TempStep       = FindFitRowStep(BreakColumn, TopCount);

            Console.WriteLine(TempStep);
            MoveTo(TempStep);
        }
Ejemplo n.º 3
0
        //此函数会可能会设置 AnOtherBreakStep
        Step FindFitRowStep(int columnFrom, int needSpace)
        {
            int  leftNumber = needSpace;
            Step Res        = new Step();

            Res.ColumnFrom = columnFrom;
            bool bUseStep2 = false;
            //完美列
            List <BreakState> PerfectList = new List <BreakState>();

            for (int i = 0; i < NCol; i++)
            {
                if (breakStats[i].isPerFect)
                {
                    PerfectList.Add(breakStats[i]);
                }
            }

            if (PerfectList.Count > 0)
            {
                BreakState PerBS = PerfectList.First();
                PerfectList.RemoveAt(0);
                Res.ColumnTo = PerBS.Column;

                if (needSpace <= 3)
                {
                    Res.Number = needSpace;
                    return(Res);
                }
                else
                {
                    Res.Number  = 3;
                    leftNumber -= 3;
                    //二次移动开始
                    if (PerfectList.Count > 0)
                    {
                        BreakState PerBS1 = PerfectList.First();
                        PerfectList.RemoveAt(0);
                        AnOtherBreakStep.ColumnFrom = columnFrom;
                        AnOtherBreakStep.ColumnTo   = PerBS1.Column;
                        AnOtherBreakStep.Number     = leftNumber;
                        return(Res);
                    }
                    else
                    {
                        bUseStep2 = true;
                        Console.WriteLine("完美列不够用了");
                    }
                }
            }
            //非完美列
            List <BreakState> NotOkList = new List <BreakState>();

            for (int i = 0; i < NCol; i++)
            {
                if (i != columnFrom && !breakStats[i].isPerFect && breakStats[i].EmptySpace > 0)
                {
                    NotOkList.Add(breakStats[i]);
                }
            }
            //使用非完美列来填充
            if (leftNumber > 0)
            {
                if (NotOkList.Count == 0)
                {
                    Console.WriteLine("Count =0");
                }
                BreakState NotOkBs = NotOkList.Max();
                NotOkList.RemoveAt(0);
                if (bUseStep2)
                {
                    AnOtherBreakStep.ColumnFrom = columnFrom;
                    AnOtherBreakStep.ColumnTo   = NotOkBs.Column;
                    AnOtherBreakStep.Number     = leftNumber;
                }
                else
                {
                    Res.ColumnTo = NotOkBs.Column;
                    Res.Number   = leftNumber;
                    leftNumber   = leftNumber - NotOkBs.EmptySpace;
                    if (leftNumber > 0)
                    {
                        Console.WriteLine("还没有弄完呀");
                    }
                }
            }

            return(Res);
        }