示例#1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // METHOD SEPARATOR METHOD SEPARATOR METHOD SEPARATOR METHOD SEPARATOR METHOD SEPARATOR METHOD SEPARATOR METHOD SEPARATOR
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Test to see that mini-max algorithm function In jj47Player works as intended.
        /// </summary>
        /// <param name="debugChooseMoveMiniMaxAlgorithmFunctionTop">enable or disable for TOP player</param>
        /// <param name="debugChooseMoveMiniMaxAlgorithmFunctionBottom">enable or disable for BOTTOM player</param>
        private static void DebugChooseMoveMiniMaxAlgorithmFunction(bool debugChooseMoveMiniMaxAlgorithmFunctionTop,
                                                                    bool debugChooseMoveMiniMaxAlgorithmFunctionBottom)
        {
            // Test for TOP player.
            if (debugChooseMoveMiniMaxAlgorithmFunctionTop == true)
            {
                // Create new game board.
                Board testBoardMiniMaxTOP = new Board(Position.Top);

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

                // Calls method that implement mini-max algorithm to predict the optimal move.
                int optimalMove = testTopPlayer.ChooseMove(testBoardMiniMaxTOP);

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

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

                // Test as TOP Player.
                jj47Player testBottomPlayer = new jj47Player(Position.Bottom, 3000);

                // Calls method that implement mini-max algorithm to predict the optimal move.
                int optimalMove = testBottomPlayer.ChooseMove(testBoardMiniMaxBottom);

                Console.WriteLine("BOTTOM Player AI determined optimal board move was: {0}", optimalMove);
            }
        }
示例#2
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);
            }
        }