Exemplo n.º 1
0
        public void Test_Blades()
        {
            var t             = TestSymmetry(new ShapeOrientationCollection(new[] { new ShapeOrientation(Shape.Ray, Orientation.Original), new ShapeOrientation(Shape.Ray, Orientation.Right) }, true));
            var uniqueHashSet = new HashSet <string>();
            var values        = new Dictionary <int, List <string> >();

            foreach (var a in "AZRIBJVLTPYSDWNMCFXEKG")
            {
                foreach (var b in " AZRIBJVLTPYSDWNMCFXEKG")
                {
                    foreach (var c in " " /*" AZRIBJVLTPYSDWNMCFXEKG*/)
                    {
                        for (var o1 = Orientation.Original; o1 <= Orientation.LeftFlip; o1++)
                        {
                            for (var o2 = Orientation.Original; o2 <= Orientation.LeftFlip; o2++)
                            {
                                if (b == ' ' && o1 != Orientation.Original)
                                {
                                    continue;
                                }
                                if (c == ' ' && o2 != Orientation.Original)
                                {
                                    continue;
                                }
                                var so = new List <ShapeOrientation>
                                {
                                    new ShapeOrientation((Shape)a, Orientation.Original)
                                };
                                if (b != ' ')
                                {
                                    so.Add(new ShapeOrientation((Shape)b, o1));
                                }
                                if (c != ' ')
                                {
                                    so.Add(new ShapeOrientation((Shape)c, o2));
                                }
                                var soc = new ShapeOrientationCollection(so, true);
                                if (!uniqueHashSet.Add(soc.ToString()))
                                {
                                    continue;
                                }
                                var idx = TestSymmetry(soc);
                                if (!values.ContainsKey(idx))
                                {
                                    values[idx] = new List <string>();
                                }
                                values[idx].Add(soc.ToString());
                            }
                        }
                    }
                }
            }
            Assert.AreEqual(1, values.Count);
        }
Exemplo n.º 2
0
        public int TestSymmetry(ShapeOrientationCollection col)
        {
            var rawUniques = RotationGenerator.GetUniqueOrientations(col).ToArray();

            Orientation[] uniques = EliminateDupes(rawUniques);
            var           retval  = 0;

            foreach (var orientation in uniques)
            {
                retval |= (1 << (int)orientation);
            }
            return(retval);
        }