Esempio n. 1
0
        public static Cube ApplyMoves(Cube cube, Move[] moves)
        {
            foreach (Move move in moves)
            {
                Cube.ApplyMove(cube, move);
            }

            return(cube);
        }
Esempio n. 2
0
        public static Move[] Scramble(int minMoves, int maxMoves, Cube cube)
        {
            int         maxMoveIndex = Enum.GetValues(typeof(Move)).Cast <int>().Max();
            List <Move> moves        = new List <Move>();

            Random rand = new Random();

            for (int i = 0; i < rand.Next(minMoves, maxMoves); i++)
            {
                Move m;

                do
                {
                    m = (Move)rand.Next(0, maxMoveIndex);
                } while (0 < moves.Count && !IsDecentNextMove(moves.Last(), m));

                Cube.ApplyMove(cube, m);
                moves.Add(m);
            }

            return(moves.ToArray());
        }