Beispiel #1
0
        public static void logic(Random rnd)
        {
            Manager manager = new Manager(rnd);
            Row a = new Row();
            int count = 0;
            do
            {
                if (manager.possibilities.Count == 0)
                {
                    Console.WriteLine("mistake");
                    break;
                }
                    a = manager.possibilities[rnd.Next(manager.possibilities.Count - 1)] as Row;
                a.pins(manager.answer, a);
                Console.WriteLine(manager.answer.ToString() + " answer\n");
                Console.WriteLine(a.ToString() + " guess\n");
                Console.WriteLine(a.black_pins + " " + a.white_pins);

                //goes threw the hole array from up to down and erases the not possible options
                for (int i = manager.possibilities.Count - 1; i >= 0; i--)
                {
                    Row check = manager.possibilities[i] as Row;
                    int samePlace = HowManySamePlace(a, check);
                    int amount = HowManySameAll(a, check);

                    //the logic
                    if (a.black_pins != samePlace || amount > a.white_pins + a.black_pins)
                        manager.possibilities.RemoveAt(i);

                }
                count++;
            } while (a.black_pins < 4);

            Console.WriteLine("it took " + count + " times");
        }