Exemple #1
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);
        }
Exemple #2
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;
 }
Exemple #3
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);
        }