public override string Scramble()
        {
            if (!int.TryParse(TwistedCornersInput.Text, out int twistedCorners))
            {
                MessageBox.Show("Enter the number of twisted corners in the box", "Invalid number of twisted corners", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);
            }
            if (twistedCorners < 0 || twistedCorners > 7)
            {
                MessageBox.Show("Number of twisted corners must be between 0 and 7", "Invalid number of twisted corners", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);
            }
            if (twistedCorners == 0 && FloatingInput.SelectedItem.Equals(No))
            {
                MessageBox.Show("0-twists must be floating", "Invalid corners", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);
            }
            if (twistedCorners == 1 && FloatingInput.SelectedItem.Equals(Yes))
            {
                MessageBox.Show("1-twists must not be floating", "Invalid corners", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);
            }

            var canBeGreater = CardinalityBox.SelectedItem.Equals(EqualOrGreater);

            bool?            isFloatingTwist;
            List <FinalLeaf> baseLeaves;

            switch ((string)FloatingInput.SelectedItem)
            {
            case Yes:
                isFloatingTwist = true;
                baseLeaves      = floatingLeaves;
                break;

            case No:
                isFloatingTwist = false;
                baseLeaves      = nonFloatingLeaves;
                break;

            default:
                isFloatingTwist = null;
                baseLeaves      = cornerLeaves;
                break;
            }

            var possibleLeaves = canBeGreater ? baseLeaves.Where(x => x.NumTwisted >= twistedCorners).ToList() : cornerLeaves.Where(x => x.NumTwisted == twistedCorners).ToList();
            var cornerNode     = new Node(possibleLeaves, 0);

            var scramble = Scrambler.GetScramble(edgeNode, cornerNode, rand, isFloatingTwist);

            return(scramble);
        }
        public override string Scramble()
        {
            if (!int.TryParse(NumAlgsInput.Text, out int numAlgs))
            {
                MessageBox.Show("Enter the number of algs in the box", "Invalid number of algs", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);
            }
            if (numAlgs < 1 || numAlgs > 14)
            {
                MessageBox.Show("Number of algs must be between 1 and 14", "Invalid number of algs", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);
            }
            var combinationNode = combinationNodes.Single(x => x.NumAlgs == numAlgs);
            var scramble        = Scrambler.GetScramble(edgeNodes, cornerNodes, combinationNode, rand);

            return(scramble);
        }
        public override string Scramble()
        {
            if (!int.TryParse(FlippedEdgesInput.Text, out int flippedEdges))
            {
                MessageBox.Show("Enter the number of flipped edges in the box", "Invalid number of flipped edges", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);
            }
            if (flippedEdges < 0 || flippedEdges > 11)
            {
                MessageBox.Show("Number of flipped edges must be between 0 and 11", "Invalid number of flipped edges", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);
            }
            var canBeGreater   = CardinalityBox.SelectedItem.Equals(EqualOrGreater);
            var possibleLeaves = canBeGreater ? edgeLeaves.Where(x => x.NumTwisted >= flippedEdges).ToList() : edgeLeaves.Where(x => x.NumTwisted == flippedEdges).ToList();
            var edgeNode       = new Node(possibleLeaves, 0);
            var scramble       = Scrambler.GetScramble(edgeNode, cornerNode, rand, null);

            return(scramble);
        }
Example #4
0
 public override string Scramble(Random rand)
 {
     return(Scrambler.GetScramble(edgeNode, cornerNode, rand, null));
 }
        public override string Scramble(Random rand)
        {
            var scramble = Scrambler.GetScramble(edgeNodes, cornerNodes, combinationNode, rand);

            return(scramble);
        }
 public override string Scramble(Random rand)
 {
     return(Scrambler.GetScramble(edgeNode, cornerNode, rand, isFloatingTwist));
 }