Beispiel #1
0
        static void Main(string[] args)
        {
            GameBoard Game = new GameBoard();

            Game.newGameBoard();
            Player PlayerX = new Player();

            PlayerX.setPlayer(identity.X);
            Player PlayerO = new Player();

            PlayerO.setPlayer(identity.O);
            Player currentPlayer = null;
            COORD  coord         = new COORD();
            Move   move          = new Move();

            FirstPlayer(PlayerX, PlayerO, ref currentPlayer);
            beginGame(ref currentPlayer, ref Game, ref move);
        }
Beispiel #2
0
        //Returns the token as a Square object based on the board itself
        public Square getSquareToken(COORD coord)
        {
            //get the piece value from the board, using its 0-7 reference system
            char temp = board.getPieceAt(coord.row - 1, coord.col - 1);

            //Return the square type represented by the value
            if (temp == 'W')
            {
                return(Square.fromIdentity(firstPlayer));
            }
            else if (temp == 'B')
            {
                return(Square.fromOppositeIdentity(firstPlayer));
            }
            else
            {
                return(Square.S);
            }
        }
Beispiel #3
0
        public bool movePiece(identity currentPlayer, Move move)
        {
            //If the current player is the first player, then white is moving
            bool isFirstsTurn = false;

            if (firstPlayer == currentPlayer)
            {
                isFirstsTurn = true;
            }

            //Flip the move if needed
            Move boardRelativeMove = flipMoveIfNeeded(move);


            //Check the move
            bool moveIsValid = checkMove(currentPlayer, move);

            if (moveIsValid)
            {
                //If the move is valid...
                //and if there is a piece from the other team that will be taken
                char pieceAtEnd = board.getPieceAt(boardRelativeMove.End.row, boardRelativeMove.End.col);
                if (pieceAtEnd != 'S')
                {
                    //set the destination as the last piece taken
                    pieceLastTaken = move.End;
                }
                else
                {
                    //Otherwise, set the piece last taken to null

                    pieceLastTaken = null;
                }
            }
            else
            {
                return(false);
            }
            //Execute the move on the Low Abstraction Board
            return(board.makeMove(isFirstsTurn, boardRelativeMove.Begin.row, boardRelativeMove.Begin.col, boardRelativeMove.End.row, boardRelativeMove.End.col, false));
        }
        static void Main(string[] args)
        {
            //Define the players
            Player PlayerX = new Player();

            PlayerX.setPlayer(identity.X);
            Player PlayerO = new AIPlayer();

            PlayerO.setPlayer(identity.O);
            Player currentPlayer = null;

            //Find out the first player, and set currentPlayer
            FirstPlayer(PlayerX, PlayerO, ref currentPlayer);

            //Setup the game board
            game = new GameBoard();
            game.newGameBoard(currentPlayer.getIdentity());

            COORD coord = new COORD();
            Move  move  = new Move();

            beginGame(currentPlayer.getIdentity(), ref PlayerX, ref PlayerO, ref game, ref move);
        }
Beispiel #5
0
 public void convertMove(COORD coord)
 {
     coord.X = row - 1;
     coord.Y = col - 64 - 1;
 }
Beispiel #6
0
 public Square getSquareToken(COORD coord)
 {
     return((Square)Board[coord.X, coord.Y]);
 }
Beispiel #7
0
 public void convertMove(COORD coord)
 {
     coord.X = 8 - row;
     coord.Y = col - 65;
 }