Beispiel #1
0
        public static void WhiteWin(CreeperBoard board)
        {
            Position startPosition;
            Position endPosition;
            Move move;
            bool pausePrint = false;

            for (int i = 0; i < 4; i++)
            {
                startPosition = new Position(i, i + 1);
                endPosition = new Position(i + 1, i + 2);
                move = new Move(startPosition, endPosition, CreeperColor.Fire);
                board.Move(move);
                board.PrintToConsole(pausePrint);
            }
            for (int i = 0; i < 3; i++)
            {
                startPosition = new Position(i, i + 2);
                endPosition = new Position(i + 1, i + 3);
                move = new Move(startPosition, endPosition, CreeperColor.Fire);
                board.Move(move);
                board.PrintToConsole(pausePrint);
            }

            startPosition = new Position(4, 6);
            endPosition = new Position(5, 5);
            move = new Move(startPosition, endPosition, CreeperColor.Fire);
            board.Move(move);
            board.PrintToConsole(pausePrint);

            startPosition = new Position(4, 5);
            endPosition = new Position(5, 4);
            move = new Move(startPosition, endPosition, CreeperColor.Fire);
            board.Move(move);
            board.PrintToConsole(pausePrint);

            if(board.GetGameState(CreeperColor.Fire) == CreeperGameState.Complete)
            {
                Console.WriteLine("White wins!");
            }
        }
Beispiel #2
0
        public static void AIGame(CreeperBoard board)
        {
            CreeperAI.CreeperAI creeperAI = new CreeperAI.CreeperAI(2, 10, .01, 11, 1000);
            bool pauseAfterPrint = false;

            bool gameOver = false;
            CreeperColor turn = CreeperColor.Ice;

            while (!board.IsFinished(turn)
                && board.Pegs.Any(x => x.Color == CreeperColor.Fire)
                && board.Pegs.Any(x => x.Color == CreeperColor.Ice))
            {
                turn = (turn == CreeperColor.Fire) ? CreeperColor.Ice : CreeperColor.Fire;

                board.Move(creeperAI.GetMove(board, turn));
                board.PrintToConsole(pauseAfterPrint);
            }

            Console.WriteLine(String.Format("{0} won.", turn.ToString()));
        }
Beispiel #3
0
        public static void JumpTest(CreeperBoard board)
        {
            // test's a non jumping of flipping move
               /* if (board.IsValidMove(new Move(new Position(1, 2), new Position(2, 3), CreeperColor.White)))
            {
                Console.WriteLine("SideMove Test passed!");
            }
            else
            {
                Console.WriteLine("SideMove Test failed");
            }*/

            board.Move(new Move(new Position(4,0),new Position(3,0),CreeperColor.Ice));
            //board.Move(new Move(new Position(2, 0), new Position(4, 0), CreeperColor.White));
            if (board.IsValidMove(new Move(new Position(2,0), new Position(4,0), CreeperColor.Fire)))
            {
                Console.WriteLine("Jump Test works!");
            }
            else
            {
                Console.WriteLine("Jump Test Failed");
            }
        }
Beispiel #4
0
        public bool Defeats(Gene opponent)
        {
            try
            {
                int moveCount = 0;
                CreeperColor turn = CreeperColor.Ice;
                CreeperBoard board = new CreeperBoard();
                CreeperAI.AI thisAI = new CreeperAI.AI(_weights);
                CreeperAI.AI opponentAI = new CreeperAI.AI(opponent._weights);

                while (!board.IsFinished(turn))
                {
                    moveCount++;
                    if (moveCount > 70)
                    {
                        Console.WriteLine("Move Loop");
                        return false;
                    }
                    turn = turn.Opposite();

                    if (turn == CreeperColor.Fire)
                    {
                        board.Move(thisAI.GetMove(board, turn));
                    }
                    else
                    {
                        board.Move(opponentAI.GetMove(board, turn));
                    }
                }

                return turn == CreeperColor.Fire && board.GetGameState(turn) == CreeperGameState.Complete;
            }
            catch (Exception)
            {
                Console.WriteLine("Exception");
                return false;
            }
        }