Beispiel #1
0
        public void GenerateCardsTest()
        {
            Logic target = new Logic(); // TODO: Initialize to an appropriate value
            List<Card> cards = target.GenerateCards();

            Assert.AreEqual(81, cards.Count);
        }
Beispiel #2
0
        private Image<Bgr, Byte> Run(string filename)
        {
            Stopwatch watch = new Stopwatch();
            watch.Start();

            ContourAnalyzer ca = new ContourAnalyzer();
            Image<Bgr, Byte> table = new Image<Bgr, byte>(filename);
            table = table.PyrDown().PyrDown();

            int debuglevel = cmbDebuglevel.SelectedIndex;

            Settings settings = new Settings(debuglevel);
            Dictionary<Card, System.Drawing.Point> cards = ca.LocateCards(table, settings);

            Logic logic = new Logic();
            HashSet<List<Card>> sets = logic.FindSets(new List<Card>(cards.Keys));

            Random rnd = new Random();
            foreach (List<Card> set in sets)
            {
                DrawSet(table, cards, rnd, set);
            }

            watch.Stop();
            this.Title = String.Format("Done. Elapsed time: {0}", watch.Elapsed.ToString());

            ImageSource bitmap = TreeViz.ToBitmapSource(table);
            Shower.Source = bitmap;

            return table;
        }
Beispiel #3
0
        public void LogicConstructorTest()
        {
            Logic target = new Logic();
            Stopwatch w1 = new Stopwatch();
            w1.Start();
            List<Card> cards = target.GenerateCards();
            w1.Stop();

            Stopwatch w2 = new Stopwatch();
            w2.Start();
            HashSet<List<Card>> all_sets = target.FindSets(cards);
            Assert.AreEqual(1080, all_sets.Count);
            w2.Stop();

            long gen = w1.ElapsedMilliseconds;
            long find = w2.ElapsedMilliseconds;
        }