Example #1
0
        public Backpack Mutate(Backpack backpack, List <Item> items)
        {
            int index           = _rnd.Next(0, backpack.Items.Count() - 1);
            var bitPresentation = backpack.Presentation(items);

            if (bitPresentation.ElementAt(index) == 0)
            {
                Console.WriteLine($"Adding {items[index].Name}");
                backpack.Items.Add(items[index]);
            }
            else
            {
                Console.WriteLine($"Removing {items[index].Name}");
                backpack.Items.Remove(items[index]);
            }

            return(backpack);
        }
Example #2
0
 private void printPack(string info, Backpack pack)
 {
     Console.WriteLine(info + $"{itemsPresentation()} \n" +
                       $"{string.Join("\t  ", pack.Presentation(_baseItems))}" + $"\t TotalWeight - {pack.TotalWeight}, " + $"TotalWorth - {pack.TotalWorth}");
 }