public void TestCorrectElements()
        {
            int size = 9;

            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = i + 1;
            }
            for (int j = 0; j < 10; j++)
            {
                NPuzzleUtils.Shuffle(array);
                Assert.AreEqual(NPuzzleUtils.CorrectElements(array), true);
            }
        }
Esempio n. 2
0
    /*!
     * Generate a random acceptable initial state
     *
     */
    public static Problem.NPuzzleState <int[]> GenerateInitState(int size)
    {
        int[] state = new int[size];
        for (int i = 0; i < size; i++)
        {
            state[i] = i + 1;
        }

        NPuzzleUtils.Shuffle(state);

        while (!NPuzzleUtils.AcceptableState(state))
        {
            NPuzzleUtils.Shuffle(state);
        }


        return(new Problem.NPuzzleState <int[]>(state));
    }