示例#1
0
文件: CTTBoard.cs 项目: ustasBD/ttt
        public int[,]  GetNextStepAssesment(CTTBoard board, CTTBoard.Player pl)
        {
            var assArr = new int[3, 3];

            Task[] tskList = new Task[9];
            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    int xc = x;
                    int yc = y;

                    {
                        Console.WriteLine("{0},{1}", xc, yc);

                        if (board.GetCell(xc, yc) != 0)
                        {
                            assArr[xc, yc] = -100;
                        }
                        else
                        {
                            var copyBoard = (CTTBoard)board.Clone();
                            var ass       = _getStepAssesment(copyBoard, pl, pl, xc, yc, 0);
                            //if (ass != null)
                            assArr[xc, yc] = ass;
                        }
                    };
                    //tskList[x+y*3] = Task.Factory.StartNew(assFunk);
                }
            }
            //Task.WaitAll(tskList);
            return(assArr);
        }
示例#2
0
文件: CTTBoard.cs 项目: ustasBD/ttt
        private static int _getStepAssesment(CTTBoard board, CTTBoard.Player me, CTTBoard.Player pl, int x, int y, int level)
        {
            board.ApplyStep(pl, x, y);
            int stepScore = _stepAssesmetInfinity - level;
            int nopScore  = _stepAssesmetInfinity;

            if (me != pl)
            {
                stepScore = -stepScore;
            }
            else
            {
                nopScore = -nopScore;
            }

            var retAss = -nopScore;

            if (board.CheckWin( ))
            {
                //Dump2Con(board);
                //Console.WriteLine(string.Format("{0},{1}",x,y));
                board.CleanCell(x, y);
                return(stepScore);
            }
            if (board.CheckComplete())
            {
                board.CleanCell(x, y);
                return(0);
            }

            for (int xx = 0; xx < 3; xx++)
            {
                for (int yy = 0; yy < 3; yy++)
                {
                    if (board.GetCell(xx, yy) == 0)
                    {
                        var ass = _getStepAssesment(board, me, InvPlayer(pl), xx, yy, level + 1);
                        if (me != pl)
                        {
                            if (retAss < ass)
                            {
                                retAss = ass;
                            }
                        }
                        else
                        if (retAss > ass)
                        {
                            retAss = ass;
                        }
                    }
                }
            }
            board.CleanCell(x, y);
            return(retAss);
        }
示例#3
0
文件: CTTBoard.cs 项目: ustasBD/ttt
        public Tuple <byte, byte> GetNextStep(CTTBoard board, CTTBoard.Player pl)
        {
            var assArr = GetNextStepAssesment(board, pl);

            return(Tuple.Create((byte)0, (byte)0));
        }