Пример #1
0
        //Add selected number of animals, and roll their gender
        private void AddAnimal(int numberOfLion, int numberOfRabbits, int numberofHunters)
        {
            NumberofHunters = numberofHunters;
            //Add one hunter to the field
            while (numberofHunters != 0)
            {
                AllAnimals.Add(new Hunter());
                Arrows += 20;
                numberofHunters--;
            }

            while (numberOfLion != 0)
            {
                AnimalId++;
                AllAnimals.Add(new Lion(RandomRoll.GenderRoll(), AnimalId));
                numberOfLion--;
            }

            while (numberOfRabbits != 0)
            {
                AnimalId++;
                AllAnimals.Add(new Rabbit(RandomRoll.GenderRoll(), AnimalId));
                numberOfRabbits--;
            }
        }
Пример #2
0
        //Random select move from validmoves
        private (int, int) SelectetMove(Animal animal)
        {
            var validFields        = ValidMovesForAnimal(animal);
            var randomfield        = RandomRoll.RField(validFields);
            var selectedRamdomFeld = validFields[randomfield];
            var posOfRField        = XandY(selectedRamdomFeld);

            return(posOfRField);
        }
Пример #3
0
        //Placement of animals to random fields - make private
        private void Placement()
        {
            // Flat list and check animals thats not on a field
            var existingAnimals = Territories.SelectMany(c => c).Where(a => AllAnimals.Contains(a.animal)).Select(m => m.animal);

            foreach (var animal in AllAnimals.Except(existingAnimals))
            {
                var r  = RandomRoll.AnimalRandomPlacement();
                var r1 = RandomRoll.AnimalRandomPlacement();

                while (Territories[r][r1].animal != null)
                {
                    r  = RandomRoll.AnimalRandomPlacement();
                    r1 = RandomRoll.AnimalRandomPlacement();
                }

                Territories[r][r1].animal = animal;
            }
        }
Пример #4
0
        // Add a field to all fields, and generate random number of greenfields
        private void AddFields()
        {
            for (int i = 0; i <= 19; i++)
            {
                Territories.Add(new List <Field>());

                for (int j = 0; j <= 19; j++)
                {
                    int greenfield = RandomRoll.Greenfield();
                    if (greenfield < 5)
                    {
                        Territories[i].Add(new Field(true));
                    }
                    else
                    {
                        Territories[i].Add(new Field(false));
                    }
                }
            }
        }