コード例 #1
0
        public chess_power whatthemorbestpaice(List <chess_power> cplst)
        {
            Node <chess_power> cpnd  = cplst.GetFirst();
            chess_power        cp    = cpnd.GetInfo();
            chess_power        cpmin = new chess_power(mat, cp.befor, cp.after, playernum, picbox, kings, rooks, kingsplace);
            int min = Math.Abs(mat[cp.befor.X, cp.befor.Y]);

            while (cpnd != null)
            {
                cp = cpnd.GetInfo();
                int scour = cp.totalscour();
                int item  = Math.Abs(mat[cp.befor.X, cp.befor.Y]);
                if (Math.Abs(mat[cp.befor.X, cp.befor.Y]) < min)
                {
                    min   = Math.Abs(mat[cp.befor.X, cp.befor.Y]);
                    cpmin = new chess_power(mat, cp.befor, cp.after, playernum, picbox, kings, rooks, kingsplace);
                }
                cpnd = cpnd.GetNext();
            }
            return(cpmin);
        }
コード例 #2
0
        public void filllistinchess_power(int n, Point[] pt, List <Point>[] lpt, List <chess_power> cplst)
        {
            if (n >= 0)
            {
                Node <chess_power> chnd = cplst.GetFirst();
                List <Point>       lst  = lpt[n - 1];

                Node <Point> nd = lst.GetFirst();
                while (chnd != null)
                {
                    chnd = chnd.GetNext();
                }
                while (nd != null)
                {
                    chess_power cp = new chess_power(mat, pt[n - 1], nd.GetInfo(), playernum, picbox, kings, rooks, kingsplace);
                    chnd = cplst.Insert(chnd, cp);
                    nd   = nd.GetNext();
                }
                if (n > 1)
                {
                    filllistinchess_power(n - 1, pt, lpt, cplst);
                }
            }
        }
コード例 #3
0
        public void clever(int playernum, int[] kings, int[] rooks, Point[] kingsplace, PictureBox[] picbox, int[,] mat)
        {
            int k = 0; // number of items in the game for the playernumber

            TimeSpan    interval = new TimeSpan(0, 0, 2);
            tootalscoor tc       = new tootalscoor(picbox, kings, playernum, rooks, mat, kingsplace);

            for (int i = 0; i < mat.GetLength(0); i++)
            {
                for (int j = 0; j < mat.GetLength(1); j++)
                {
                    if (mat[i, j] * playernum > 0)
                    {
                        k++;
                    }
                }
            }
            Point[] pt = new Point[k];
            int     p  = 0;

            for (int i = 0; i < mat.GetLength(0); i++)
            {
                for (int j = 0; j < mat.GetLength(1); j++)
                {
                    if (mat[i, j] * playernum > 0)
                    {
                        pt[p] = new Point(i, j);
                        p++;
                    }
                }
            }
            List <Point>[] lpt = new List <Point> [k];
            tc.Filllist(k, pt, lpt);

            List <chess_power> cplst = new List <chess_power>();

            tc.filllistinchess_power(k, pt, lpt, cplst);

            //  int t = 1; // this is just to stop the debug
            int max = tc.getmaxtotalscore(cplst);
            List <chess_power> thebest = new List <chess_power>();

            thebest = tc.whatthebestpaice(cplst);
            chess_power final = tc.whatthemorbestpaice(thebest);

            if (mat[final.after.X, final.after.Y] != 0)
            {
                smartply.loser = mat[final.after.X, final.after.Y];
            }
            ///////////////////////////////////////
            int old = mat[final.befor.X, final.befor.Y];

            lastx = new Point(final.befor.X, final.befor.Y);
            mat[final.befor.X, final.befor.Y] = 0;
            mat[final.after.X, final.after.Y] = old;
            ////////////////////////////////////////////////


            game_main pppp = new game_main();

            picbox[final.befor.X * 10 + final.befor.Y - 2 * final.befor.X].ImageLocation = null;
            Application.DoEvents();

            picbox[final.after.X * 10 + final.after.Y - 2 * final.after.X].ImageLocation = pppp.chessimage(old);
            newx = new Point(final.after.X, final.after.Y);
            picbox[final.after.X * 10 + final.after.Y - 2 * final.after.X].SizeMode = PictureBoxSizeMode.CenterImage;

            pppp.refreshcolors(picbox, playernum, mat);
        }