Пример #1
0
        public override void Setup()
        {
            Console.WriteLine("Starting " + Name);

            int size        = Environment.Memory["Size"];
            int noResources = Environment.Memory["NoResources"];

            List <string> resPos  = new List <string>();
            string        compPos = $"{size / 2} {size / 2}";

            resPos.Add(compPos); // the position of the base

            for (int i = 1; i <= noResources; i++)
            {
                while (resPos.Contains(compPos)) // resources do not overlap
                {
                    int x = _rand.Next(size);
                    int y = _rand.Next(size);
                    compPos = $"{x} {y}";
                }

                ResourcePositions.Add($"res{i}", compPos);
                resPos.Add(compPos);
            }
        }
Пример #2
0
        public override void Setup()
        {
            Console.WriteLine("Starting " + Name);

            List <string> resPos  = new List <string>();
            string        compPos = Utils.Str(Utils.Size / 2, Utils.Size / 2);

            resPos.Add(compPos); // the position of the base

            for (int i = 1; i <= Utils.NoResources; i++)
            {
                while (resPos.Contains(compPos)) // resources do not overlap
                {
                    int x = Utils.RandNoGen.Next(Utils.Size);
                    int y = Utils.RandNoGen.Next(Utils.Size);
                    compPos = Utils.Str(x, y);
                }

                ResourcePositions.Add("res" + i, compPos);
                resPos.Add(compPos);
            }
        }