Exemple #1
0
        public override ulong GetMove(ulong board)
        {
            ulong player_board, opp_board;
            int   player_piecestoplace, opp_piecestoplace;

            if (Board.IsWhiteTurn(board))
            {
                player_board         = Board.WhiteBoard(board);
                opp_board            = Board.BlackBoard(board);
                player_piecestoplace = Board.WhitePiecesLeftToPlace(board);
                opp_piecestoplace    = Board.BlackPiecesLeftToPlace(board);
            }
            else
            {
                player_board         = Board.BlackBoard(board);
                opp_board            = Board.WhiteBoard(board);
                player_piecestoplace = Board.BlackPiecesLeftToPlace(board);
                opp_piecestoplace    = Board.WhitePiecesLeftToPlace(board);
            }

            ulong new_player_board;

            if (Board.IsPlacementPhase(board))
            {
                var new_piece = InterpretInput("Place piece at: ");

                new_player_board = player_board | new_piece;
                player_piecestoplace--;
            }
            else
            {
                var old_piece = InterpretInput("Take piece from: ");
                var new_piece = InterpretInput("And place at: ");
                new_player_board = player_board & ~old_piece | new_piece;
            }
            throw new NotImplementedException();

            // see if we made a run
            var   old_runs      = Board.GetRunPieces(player_board);
            var   new_runs      = Board.GetRunPieces(new_player_board);
            ulong new_opp_board = opp_board;

            if (new_runs != old_runs && Board.CountBits(new_runs) >= Board.CountBits(old_runs))
            {
                var remove_piece = InterpretInput("Remove piece at: ");

                new_opp_board &= ~remove_piece;
            }

            return(Board.CreateBoardForNextTurn(IsWhite, new_player_board, new_opp_board, player_piecestoplace, opp_piecestoplace));
        }