Example #1
0
        private bool JudgeWin(AttackDirectionInfo directionInfo_1, AttackDirectionInfo directionInfo_2)
        {
            bool res = false;

            int totalConnectCount = directionInfo_1.ConnectCount + directionInfo_2.ConnectCount - 1;
            int liveCount         = 0;

            if (directionInfo_1.IsLive)
            {
                liveCount += 1;
            }
            if (directionInfo_2.IsLive)
            {
                liveCount += 1;
            }

            if (totalConnectCount >= 5)
            {
                res = true;
            }
            //else if (totalConnectCount == 4)
            //{
            //    if (liveCount == 2)
            //        res = true;
            //}

            return(res);
        }
Example #2
0
        protected AttackDirectionInfo GetAttackConnectInfo(Model model, int posX, int posY, ChessType posChessType, int volumeX, int volumeY)
        {
            AttackDirectionInfo res = new AttackDirectionInfo();
            int connectCount        = 0;

            var board = model.GetBoardByCopy();

            while (board[posY][posX] == posChessType)
            {
                connectCount++;
                posX += volumeX;
                posY += volumeY;

                if ((posY < 0 || posY >= GameDef.board_cell_length) ||
                    (posX < 0 || posX >= GameDef.board_cell_length))
                {
                    break;
                }
            }

            res.ConnectCount = connectCount;

            if ((posY < 0 || posY >= GameDef.board_cell_length) ||
                (posX < 0 || posX >= GameDef.board_cell_length))
            {
                res.IsLive = false;
            }
            else
            {
                if (board[posY][posX] == ChessType.None)
                {
                    res.IsLive = true;
                }
                else if (board[posY][posX] == posChessType)
                {
                    Console.WriteLine("Error impossible...");
                }
                else
                {
                    res.IsLive = false;
                }
            }

            return(res);
        }
Example #3
0
        protected virtual int CalculateAttackScore(AttackDirectionInfo directionInfo_1, AttackDirectionInfo directionInfo_2)
        {
            int res = 0;

            int totalConnectCount = directionInfo_1.ConnectCount + directionInfo_2.ConnectCount - 1;
            int liveCount         = 0;

            if (directionInfo_1.IsLive)
            {
                liveCount += 1;
            }
            if (directionInfo_2.IsLive)
            {
                liveCount += 1;
            }

            if (totalConnectCount >= 5)
            {
                res = 2000000;
            }
            else if (totalConnectCount == 4)
            {
                if (liveCount == 2)
                {
                    res = 999999;
                }
                else if (liveCount == 1)
                {
                    res = 6000;
                }
                else if (liveCount == 0)
                {
                    res = 0;
                }
            }
            else if (totalConnectCount == 3)
            {
                if (liveCount == 2)
                {
                    res = 1800;
                }
                else if (liveCount == 1)
                {
                    res = 800;
                }
                else if (liveCount == 0)
                {
                    res = 0;
                }
            }
            else if (totalConnectCount == 2)
            {
                if (liveCount == 2)
                {
                    res = 500;
                }
                else if (liveCount == 1)
                {
                    res = 250;
                }
                else if (liveCount == 0)
                {
                    res = 0;
                }
            }
            else if (totalConnectCount == 1)
            {
                if (liveCount == 2)
                {
                    res = 125;
                }
                else if (liveCount == 1)
                {
                    res = 50;
                }
                else if (liveCount == 0)
                {
                    res = 0;
                }
            }

            return(res);
        }