Beispiel #1
0
        public override Point[] Decide(Board board)
        {
            board.Print();
            Console.WriteLine("Tura nr" + board.Turns + " " + (color == Color.White ? "Białych" : "Czarnych"));
            Point[] playerChoice = new Point[2];
            Piece   onBoard;

            Point[] availableMoves;

            while (true)
            {
                playerChoice[0] = GetPiece("Wybierz bierkę", board.CanDraw);

                onBoard = board.BoardTab[playerChoice[0].x, playerChoice[0].y];
                if (onBoard == null || onBoard.Color != color)
                {
                    //not your piece
                    Console.WriteLine("To nie jest twoja bierka");
                }
                else
                {
                    availableMoves = onBoard.GetValidMoves(board, playerChoice[0]).ToArray();
                    if (availableMoves.Length == 0)
                    {
                        Console.WriteLine("Ta bierka nie ma dostępnych ruchów, wybierz inną");
                    }
                    else
                    {
                        break;
                    }
                }
            }
            board.Print(availableMoves);
            while (true)
            {
                Console.WriteLine("Wybrano bierkę: " + (char)('a' + playerChoice[0].x) + (8 - playerChoice[0].y).ToString());
                Console.WriteLine("Dostępne ruchy");
                foreach (Point move in availableMoves)
                {
                    Console.Write((char)('a' + move.x) + (8 - move.y).ToString() + " ");
                }
                Console.WriteLine();
                playerChoice[1] = GetPiece("Ustaw wybraną bierkę", board.CanDraw);
                if (!Array.Exists(availableMoves, x => x.x == playerChoice[1].x && x.y == playerChoice[1].y))
                {
                    Console.WriteLine("Nie możesz wykonać takiego ruchu");
                }
                else
                {
                    break;
                }
            }
            return(playerChoice);
        }
Beispiel #2
0
        static void AB()
        {
            Player A     = new AlphaBeta(Color.White, 4);
            Player B     = new RandomPlayer(Color.Black);
            Board  board = new Board(A, B);

            do
            {
                board.ExecuteTurn();
                board.Print();
                Console.Read();
            } while (!board.MatchEnded());
            board.PrintMatchResult();
            Console.ReadLine();
        }