Пример #1
0
 public static async Task<string[]> GetIntentSuggestionsAsync(QuantumRandomNumberGeneratorWrapper rnd)
 {
     int numSuggestions = 5;
     string[] result = new string[numSuggestions];
     string[] words = await System.IO.File.ReadAllLinesAsync("words.txt");
     for (int i = 0; i < numSuggestions; i++)
     {
         result[i] = words[rnd.Next(words.Length)];
     }
     return result;
 }
Пример #2
0
        public static double[] GetQuantumRandom(double lat, double lon, int radius, QuantumRandomNumberGeneratorWrapper rnd)
        {
            double[] result = new double[2];
            Random   prnd   = new Random();

            bool dnn = false;

            while (dnn == false)
            {
                double lat01 = lat + radius * Math.Cos(180 * Math.PI / 180) / (6371000 * Math.PI / 180);
                double dlat  = ((lat + radius / (6371000 * Math.PI / 180)) - lat01) * 1000000;
                double lon01 = lon + radius * Math.Sin(270 * Math.PI / 180) / Math.Cos(lat * Math.PI / 180) / (6371000 * Math.PI / 180);
                double dlon  = ((lon + radius * Math.Sin(90 * Math.PI / 180) / Math.Cos(lat * Math.PI / 180) / (6371000 * Math.PI / 180)) - lon01) * 1000000;
                double lat1  = lat;
                double lon1  = lon;
                double rlat;
                double rlon;

                rlat = rnd.Next(0, (int)dlat);
                rlon = rnd.Next(0, (int)dlon);

                lat1 = lat01 + (rlat / 1000000);
                lon1 = lon01 + (rlon / 1000000);
                int dif = GetDistance(lat, lon, lat1, lon1);
                if (dif > radius)
                {
                }
                else
                {
                    result[0] = lat1;
                    result[1] = lon1;
                    dnn       = true;
                }
            }
            return(result);
        }
Пример #3
0
        public static FinalAttractor[] GetIDA(LatLng startcoord, double radius, int meta, QuantumRandomNumberGeneratorWrapper rnd, out string shaGid)
        {
            FinalAttractor[] result = new FinalAttractor[0];
            int al = 0; int cou = 0;

            shaGid = null;
            while ((al == 0) && (cou < 10))
            {
                cou++;
                int No        = getOptimizedDots(radius);
                int bytesSize = requiredEnthropyBytes(No);
                //byte[] byteinput = new byte[No]; // todo use byte or hex dependent on sourcetype
                //rnd.NextBytes(byteinput);
                byte[] byteinput = rnd.NextHexBytes((int)bytesSize, meta, out shaGid);
                if (meta == 1)
                {
                    bytesSize = bytesSize * 10;
                }
                int engin1 = initWithBytes(getHandle(), byteinput, bytesSize);
                int fa     = findAttractors(engin1, significance, filtering_significance);
                al     = getAttractorsLength(engin1);
                result = new FinalAttractor[al];
                unsafe
                {
                    IntPtr value;
                    value = getAttractors(engin1, radius, startcoord, 23);
                    if (value != null)
                    {
                        for (int j = 0; j < (int)al; j++)
                        {
                            result[j] = new FinalAttractor();
                            Marshal.PtrToStructure(value, result[j]);
                            value += Marshal.SizeOf <FinalAttractor>() /* == 192 */ + 16 /* need this to fix alignment on non-Windows platforms */;
                        }
                    }
                    //releaseAttractors(value, al);
                    //todo make release stuff here
                }
                releaseEngine(engin1);
            }
            return(result);
        }
Пример #4
0
        public static string Tolog(ITurnContext context, string type, double Lat, double Lng, string ptype, string shortCode, QuantumRandomNumberGeneratorWrapper rnd) //randoms
        {
            string resp = "Random Point generated" + "\n\n";

            if (type == "blind")
            {
                resp = "Mystery Point Generated" + "\n\n";
            }

            var code = "";

            if (type == "blind")
            {
                code = "X-" + shortCode;
            }
            else
            if ((type == "random") && (ptype == "pseudo"))
            {
                code = "P-" + shortCode;
            }
            else
            if ((type == "random") && ((ptype == "quantum") || (ptype == "qtime")))
            {
                code = "Q-" + shortCode;
            }

            resp += code + " (" + Lat.ToString("#0.000000", System.Globalization.CultureInfo.InvariantCulture)
                    + " " + Lng.ToString("#0.000000", System.Globalization.CultureInfo.InvariantCulture) + ")" + "\n\n";
            if (ptype == "qtime")
            {
                resp += "Suggested time: " + ((int)rnd.Next(23)).ToString("#0") + ":" + ((int)rnd.Next(59)).ToString("00") + "\n\n";
            }
            return(resp);
        }