コード例 #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // METHOD SEPARATOR METHOD SEPARATOR METHOD SEPARATOR METHOD SEPARATOR METHOD SEPARATOR METHOD SEPARATOR METHOD SEPARATOR
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Test to see that heuristic evaluation function In jj47Player works as intended.
        /// </summary>
        /// <param name="debugHeuristicEvaluationFunctionTOP">enable or disable for TOP player</param>
        /// <param name="debugHeuristicEvaluationFunctionBOTTOM">enable or disable for BOTTOM player</param>
        private static void DebugHeuristicEvaluationFunction(bool debugHeuristicEvaluationFunctionTOP,
                                                             bool debugHeuristicEvaluationFunctionBOTTOM)
        {
            // Test for TOP player.
            if (debugHeuristicEvaluationFunctionTOP == true)
            {
                // Create new game board.
                Board testBoardHeuristicTop = new Board(Position.Top);

                testBoardHeuristicTop.Display();
                Console.WriteLine("\n\n");

                // Debug - test setter for number of stones at specified position.
                testBoardHeuristicTop.SetStonesAt(2, 0);

                testBoardHeuristicTop.Display();
                Console.WriteLine("\n\n");

                if (testBoardHeuristicTop.StonesAt(2) != 0)
                {
                    Console.WriteLine("Method setStonesAt(position) not functioning properly");
                }

                // Store the board value the AI determined.
                int moveTopValue = -1;

                //Test as TOP Player.
                jj47Player testTopPlayer = new jj47Player(Position.Top, 100000);

                moveTopValue = testTopPlayer.HeuristicEvaluation(testBoardHeuristicTop);

                Console.WriteLine("TOP Player AI determined optimal board value was: {0}", moveTopValue);
            }

            // Test for BOTTOM player.
            if (debugHeuristicEvaluationFunctionBOTTOM == true)
            {
                // Create new game board.
                Board testBoardHeuristicBottom = new Board(Position.Bottom);

                testBoardHeuristicBottom.Display();
                Console.WriteLine("\n\n");

                // Debug - test setter for number of stones at specified position.
                testBoardHeuristicBottom.SetStonesAt(10, 0);

                testBoardHeuristicBottom.Display();
                Console.WriteLine("\n\n");

                if (testBoardHeuristicBottom.StonesAt(10) != 0)
                {
                    Console.WriteLine("Method setStonesAt(position) not functioning properly");
                }

                // Store the board value the AI determined.
                int moveBottomValue = -1;

                // Test as BOTTOM Player.
                jj47Player testBottomPlayer = new jj47Player(Position.Bottom, 100000);

                moveBottomValue = testBottomPlayer.HeuristicEvaluation(testBoardHeuristicBottom);

                Console.WriteLine("BOTTOM Player AI determined optimal board value was: {0}", moveBottomValue);
            }
        }