Britbot
bool Britbot.EnemyGroup.IsFormed ( ) [inline]

Definition at line 632 of file EnemyGroup.cs.

        {
            Location[][] ringLocations = new Location[Group.GetRingCount(this.EnemyPirates.Count)][];

            //set the pivot
            Location pivot = this.GetLocation(true);

            //set the locations
            for (int i = 0; i < ringLocations.Length; i++)
            {
                ringLocations[i] = Group.GenerateRingLocations(pivot, i).ToArray();
            }

            //excluding the 0th ring which is special
            int maxRing = ringLocations.Length - 2;

            //this is basic summation of arithmetic sequence excluding the first ting
            int maxEmptySpots = Group.GetStructureVolume(maxRing) - this.EnemyPirates.Count;

            //iterate over all the rings
            for (int i = 0; i < ringLocations.Length; i++)
            {
                //iterate over all the location in each ring
                for (int k = 0; k < ringLocations[i].Length; k++)
                {
                    if (Bot.Game.GetPirateOn(ringLocations[i][k]) == null)
                        if (i == maxRing)
                            maxEmptySpots--;
                        else
                            return false;
                }
            }

            if (maxEmptySpots < 0)
                return false;

            return true;
        }