示例#1
0
        void func(Army A, Army B)
        {
            if (B.SmbAttackedOneSoldier(A.OneSoldierMakeAttack(0), 0))
            {
                A.SmbAttackedOneSoldier(B.OneSoldierMakeAttack(0), 0);
            }
            B.CheckDead();
            A.CheckDead();

            for (int i = 0; i < A.Count(); i++)
            {
                if (A.SADistance(i) > 0)
                {
                    List <IUnit> enemies = new List <IUnit>();
                    List <IUnit> friends = A.NewList(i - A.SADistance(i), i + A.SADistance(i));
                    int          k       = i - A.SADistance(i);
                    if (k < 0)
                    {
                        k       = Math.Abs(k) - 1;
                        enemies = B.NewList(0, k);
                    }
                    if (A.DoSA(i, friends, enemies))
                    {
                        i++;
                    }
                }
            }
            B.CheckDead();
            for (int i = 0; i < B.Count(); i++)
            {
                if (B.SADistance(i) > 0)
                {
                    List <IUnit> enemies = new List <IUnit>();
                    List <IUnit> friends = B.NewList(i - B.SADistance(i), i + B.SADistance(i));
                    int          k       = i - B.SADistance(i);
                    if (k < 0)
                    {
                        k       = Math.Abs(k) - 1;
                        enemies = A.NewList(0, k);
                    }
                    if (B.DoSA(i, friends, enemies))
                    {
                        i++;
                    }
                }
            }
            A.CheckDead();
        }
示例#2
0
        bool changeenumsList(Army A, Army B)
        {
            bool b = true;

            for (int i = 0; i < A.Count(); i++)
            {
                if (A.Take(i) is ArcherUnit)
                {
                    List <IUnit> enemies = new List <IUnit>();
                    int          n       = A.SADistance(i);

                    if (i % 2 == 0)
                    {
                        int j = i - 2 * n + 2;
                        int k = i + 2 * n;
                        k       = Math.Abs(i - 2 * n) - 2;
                        enemies = B.NewList(0, k);
                    }
                    else
                    {
                        int j = i - 2 * n;
                        int k = i + 2 * n - 2;
                        k       = Math.Abs(i - 2 * n) - 2;
                        enemies = B.NewList(0, k);
                        if ((k + 2) < B.Count())
                        {
                            IList <IUnit> e = B.NewList(k + 2, k + 2);
                            enemies.Add(e[0]);
                        }
                    }
                    if (enemies.Count() > 0)
                    {
                        b = false;
                        break;
                    }
                }
            }
            return(b);
        }
示例#3
0
        bool changeenumsList(Army A, Army B)
        {
            bool b = true;

            for (int i = 0; i < A.Count(); i++)
            {
                if (A.Take(i) is ArcherUnit)
                {
                    List <IUnit> enemies = new List <IUnit>();
                    int          k       = i - A.SADistance(i) + 1;
                    int          j       = i + A.SADistance(i) - 1;
                    enemies = B.NewList(k, j);
                    if (enemies.Count() > 0)
                    {
                        b = false;
                        break;
                    }
                }
            }
            return(b);
        }
示例#4
0
        void func(Army A, Army B)
        {
            int min;

            if (A.Count() == B.Count())
            {
                for (int j = 0; j < B.Count(); j++)
                {
                    if (B.SmbAttackedOneSoldier(A.OneSoldierMakeAttack(j), j))
                    {
                        A.SmbAttackedOneSoldier(B.OneSoldierMakeAttack(j), j);
                    }
                }
            }

            else
            {
                if (A.Count() < B.Count())
                {
                    min = A.Count();
                }
                else
                {
                    min = B.Count();
                }
                int i;
                for (i = 0; i < min; i++)
                {
                    if (B.SmbAttackedOneSoldier(A.OneSoldierMakeAttack(i), i))
                    {
                        A.SmbAttackedOneSoldier(B.OneSoldierMakeAttack(i), i);
                    }
                }
                if (A.Count() > min)
                {
                    if (B.IsHeAlive(i - 1))
                    {
                        if (B.SmbAttackedOneSoldier(A.OneSoldierMakeAttack(i), i - 1))
                        {
                            A.SmbAttackedOneSoldier(B.OneSoldierMakeAttack(i - 1), i);
                        }
                    }
                }
            }
            B.CheckDead();
            A.CheckDead();


            for (int i = 0; i < A.Count(); i++)
            {
                if (A.SADistance(i) > 0)
                {
                    List <IUnit> enemies = new List <IUnit>();
                    List <IUnit> friends = A.NewList(i - A.SADistance(i), i + A.SADistance(i));
                    int          k       = i - A.SADistance(i) + 1;
                    int          j       = i + A.SADistance(i) - 1;
                    enemies = B.NewList(k, j);
                    if (A.DoSA(i, friends, enemies))
                    {
                        i++;
                    }
                }
            }
            B.CheckDead();
            for (int i = 0; i < B.Count(); i++)
            {
                if (B.SADistance(i) > 0)
                {
                    List <IUnit> enemies = new List <IUnit>();
                    List <IUnit> friends = B.NewList(i - B.SADistance(i), i + B.SADistance(i));
                    int          k       = i - B.SADistance(i) + 1;
                    int          j       = i + B.SADistance(i) - 1;
                    enemies = A.NewList(k, j);
                    if (B.DoSA(i, friends, enemies))
                    {
                        i++;
                    }
                }
            }
            A.CheckDead();
        }
示例#5
0
        void func(Army A, Army B)
        {
            if (A.Count() >= 2 && B.Count() >= 2)
            {
                if (B.SmbAttackedOneSoldier(A.OneSoldierMakeAttack(1), 1))
                {
                    A.SmbAttackedOneSoldier(B.OneSoldierMakeAttack(1), 1);
                }
                if (B.SmbAttackedOneSoldier(A.OneSoldierMakeAttack(0), 0))
                {
                    A.SmbAttackedOneSoldier(B.OneSoldierMakeAttack(0), 0);
                }
            }
            else if (A.Count() >= 2 && B.Count() < 2)
            {
                if (B.SmbAttackedOneSoldier(A.OneSoldierMakeAttack(1), 0))
                {
                    A.SmbAttackedOneSoldier(B.OneSoldierMakeAttack(0), 1);
                    if ((B.SmbAttackedOneSoldier(A.OneSoldierMakeAttack(0), 0)))
                    {
                        A.SmbAttackedOneSoldier(B.OneSoldierMakeAttack(0), 0);
                    }
                }
            }
            else if (A.Count() < 2 && B.Count() >= 2)
            {
                if ((B.SmbAttackedOneSoldier(A.OneSoldierMakeAttack(0), 1)))
                {
                    if (A.SmbAttackedOneSoldier(B.OneSoldierMakeAttack(1), 0))
                    {
                        if ((B.SmbAttackedOneSoldier(A.OneSoldierMakeAttack(0), 0)))
                        {
                            A.SmbAttackedOneSoldier(B.OneSoldierMakeAttack(0), 0);
                        }
                    }
                }
            }
            else if (A.Count() < 2 && B.Count() < 2)
            {
                if (B.SmbAttackedOneSoldier(A.OneSoldierMakeAttack(0), 0))
                {
                    A.SmbAttackedOneSoldier(B.OneSoldierMakeAttack(0), 0);
                }
            }

            B.CheckDead();
            A.CheckDead();


            for (int i = 0; i < A.Count(); i++)
            {
                if (A.SADistance(i) > 0)
                {
                    List <IUnit> enemies = new List <IUnit>();
                    List <IUnit> friends = new List <IUnit>();
                    int          n       = A.SADistance(i);

                    if (i % 2 == 0)
                    {
                        int j = i - 2 * n + 2;
                        int k = i + 2 * n;
                        friends = A.NewList(k, j);
                        if ((i - 2 * n) > 0)
                        {
                            IList <IUnit> f = A.NewList(i - 2 * n, i - 2 * n);
                            friends.Add(f[0]);
                        }
                        k       = Math.Abs(i - 2 * n) - 2;
                        enemies = B.NewList(0, k);
                    }
                    else
                    {
                        int j = i - 2 * n;
                        int k = i + 2 * n - 2;
                        friends = A.NewList(k, j);
                        if ((i + 2 * n) < A.Count())
                        {
                            IList <IUnit> f = A.NewList(i + 2 * n, i + 2 * n);
                            friends.Add(f[0]);
                        }

                        k       = Math.Abs(i - 2 * n) - 2;
                        enemies = B.NewList(0, k);
                        if ((k + 2) < B.Count())
                        {
                            IList <IUnit> e = B.NewList(k + 2, k + 2);
                            enemies.Add(e[0]);
                        }
                    }
                    if (A.DoSA(i, friends, enemies))
                    {
                        i++;
                    }
                }
            }
            B.CheckDead();
            for (int i = 0; i < B.Count(); i++)
            {
                if (B.SADistance(i) > 0)
                {
                    List <IUnit> enemies = new List <IUnit>();
                    List <IUnit> friends = new List <IUnit>();
                    int          n       = B.SADistance(i);

                    if (i % 2 == 0)
                    {
                        int j = i - 2 * n + 2;
                        int k = i + 2 * n;
                        friends = B.NewList(k, j);
                        if ((i - 2 * n) > 0)
                        {
                            IList <IUnit> f = B.NewList(i - 2 * n, i - 2 * n);
                            friends.Add(f[0]);
                        }
                        k       = Math.Abs(i - 2 * n) - 2;
                        enemies = A.NewList(0, k);
                    }
                    else
                    {
                        int j = i - 2 * n;
                        int k = i + 2 * n - 2;
                        friends = B.NewList(k, j);
                        if ((i + 2 * n) < B.Count())
                        {
                            IList <IUnit> f = B.NewList(i + 2 * n, i + 2 * n);
                            friends.Add(f[0]);
                        }

                        k       = Math.Abs(i - 2 * n) - 2;
                        enemies = A.NewList(0, k);
                        if ((k + 2) < A.Count())
                        {
                            IList <IUnit> e = A.NewList(k + 2, k + 2);
                            enemies.Add(e[0]);
                        }
                    }
                    if (B.DoSA(i, friends, enemies))
                    {
                        i++;
                    }
                }
            }
            A.CheckDead();
        }