/// <summary>
        /// Returns true if ComAdobeGraniteFragsImplCheckHttpHeaderFlagProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of ComAdobeGraniteFragsImplCheckHttpHeaderFlagProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ComAdobeGraniteFragsImplCheckHttpHeaderFlagProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     FeatureName == other.FeatureName ||
                     FeatureName != null &&
                     FeatureName.Equals(other.FeatureName)
                     ) &&
                 (
                     FeatureDescription == other.FeatureDescription ||
                     FeatureDescription != null &&
                     FeatureDescription.Equals(other.FeatureDescription)
                 ) &&
                 (
                     HttpHeaderName == other.HttpHeaderName ||
                     HttpHeaderName != null &&
                     HttpHeaderName.Equals(other.HttpHeaderName)
                 ) &&
                 (
                     HttpHeaderValuepattern == other.HttpHeaderValuepattern ||
                     HttpHeaderValuepattern != null &&
                     HttpHeaderValuepattern.Equals(other.HttpHeaderValuepattern)
                 ));
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (FeatureName != null)
         {
             hashCode = hashCode * 59 + FeatureName.GetHashCode();
         }
         if (FeatureDescription != null)
         {
             hashCode = hashCode * 59 + FeatureDescription.GetHashCode();
         }
         if (ActivePercentage != null)
         {
             hashCode = hashCode * 59 + ActivePercentage.GetHashCode();
         }
         if (CookieName != null)
         {
             hashCode = hashCode * 59 + CookieName.GetHashCode();
         }
         if (CookieMaxAge != null)
         {
             hashCode = hashCode * 59 + CookieMaxAge.GetHashCode();
         }
         return(hashCode);
     }
 }
예제 #3
0
    public void CreateSign(FeatureDescription d)
    {
        Material imageMat = GameObject.Find("ImageCube").GetComponent <Renderer>().material as Material;
        Material mat      = new Material(imageMat.shader);

        GameObject go = Instantiate(GameObject.Find("SignText"));

        // plane.AddComponent<TextMeshPro>();
        // plane.GetComponent<MeshFilter>().mesh = CreatePlane();
        // plane.GetComponent<Renderer>().material = mat;
        // plane.GetComponent<MeshCollider>().enabled = false;

        TextMeshPro text = go.GetComponent <TextMeshPro>();

        text.text     = d.text;
        text.fontSize = 1;

        SetCommon(go, d);

        float s = 0.05f;

        go.transform.localScale = new Vector3(s, s, s);

        // fixme remove nudge
        go.transform.localPosition += new Vector3(0, 0, -0.125f);
    }
예제 #4
0
    public IEnumerator LoadImage(FeatureDescription d)
    {
        Material mat = imageMaterial;

        GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);

        plane.GetComponent <MeshFilter>().mesh      = CreatePlane();
        plane.GetComponent <Renderer>().material    = mat;
        plane.GetComponent <MeshCollider>().enabled = false;

        SetCommon(plane, d);

        string url = "https://img.cryptovoxels.com/img.php?url=" + WebUtility.UrlEncode(d.url) + "&mode=color";

        using (WWW www = new WWW(url))
        {
            // Wait for download to complete
            yield return(www);

            mat      = new Material(imageMaterial);
            mat.name = WebUtility.UrlEncode(d.url);
            plane.GetComponent <Renderer>().material = mat;
            Debug.Log("Got url " + url);
            mat.mainTexture = www.texture;
        }
    }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (FeatureName != null)
         {
             hashCode = hashCode * 59 + FeatureName.GetHashCode();
         }
         if (FeatureDescription != null)
         {
             hashCode = hashCode * 59 + FeatureDescription.GetHashCode();
         }
         if (HttpHeaderName != null)
         {
             hashCode = hashCode * 59 + HttpHeaderName.GetHashCode();
         }
         if (HttpHeaderValuepattern != null)
         {
             hashCode = hashCode * 59 + HttpHeaderValuepattern.GetHashCode();
         }
         return(hashCode);
     }
 }
        private void DeleteVersionOfFeature(HttpClient client, string groupName, FeatureDescription feature, string version)
        {
            var versionUri = $"{Options.AugurkUrl}/api/v2/products/{Options.ProductName}/groups/{groupName}/features/{feature.Title}/versions/{version}/";
            var response   = client.DeleteAsync(versionUri).Result;

            Console.WriteLine($"\t\tDeleted version {version} of feature {feature.Title}");
            response.EnsureSuccessStatusCode();
        }
예제 #7
0
 public override int GetHashCode()
 {
     unchecked {
         int result = (FeatureDescription != null ? FeatureDescription.GetHashCode() : 0);
         result = (result * 397) ^ (FeatureStatus != null ? FeatureStatus.GetHashCode() : 0);
         result = (result * 397) ^ (FeatureId != null ? FeatureId.GetHashCode() : 0);
         return(result);
     }
 }
예제 #8
0
 public override int GetHashCode()
 {
     unchecked {
         int result = FeatureDescription?.GetHashCode() ?? 0;
         result = (result * 397) ^ (FeatureStatus?.GetHashCode() ?? 0);
         result = (result * 397) ^ (FeatureId?.GetHashCode() ?? 0);
         return(result);
     }
 }
예제 #9
0
        private void AddChildren(FeatureDescription feature, Dictionary <string, List <FeatureDescription> > childRepository)
        {
            var strippedTitle = feature.Title.Replace(" ", String.Empty);

            if (childRepository.ContainsKey(strippedTitle))
            {
                feature.ChildFeatures = childRepository[strippedTitle];
                childRepository[strippedTitle].ForEach(f => AddChildren(f, childRepository));
            }
        }
예제 #10
0
    public void SetCommon(GameObject g, FeatureDescription d)
    {
        Vector3 offset = new Vector3(0.25f, 0.25f, -0.125f);

        g.name = "feature-" + d.uuid;
        g.transform.SetParent(transform, false);
        g.transform.localScale       = new Vector3(d.scale[0], d.scale[1], d.scale[2]);
        g.transform.localPosition    = new Vector3(d.position[0], d.position[1], d.position[2]) + offset;
        g.transform.localEulerAngles = new Vector3(d.rotation[0], d.rotation[1], d.rotation[2]) * Mathf.Rad2Deg;
        g.transform.localPosition   -= g.transform.forward * 0.01f;
    }
예제 #11
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            if (Item.Owner == null)
            {
                Item.Owner = App.User;
            }

            BindingContext = Item;
            FeatureName.SetBinding(Entry.TextProperty, "Name");
            FeatureDescription.SetBinding(Entry.TextProperty, "Description");
        }
예제 #12
0
파일: Meme.cs 프로젝트: kraidiky/TribeSim
        public static Meme InventNewMeme(int seed, AvailableFeatures memeAffectedFeature, List <Meme> memesAlreadyKnown = null)
        {
            Meme meme       = new Meme(memeAffectedFeature, CreateMemeId(memeAffectedFeature, seed));
            var  randomizer = new Random(meme.MemeId);

            meme.yearInvented = World.Year;
            FeatureDescription featureDescription = WorldProperties.FeatureDescriptions[(int)memeAffectedFeature];

            meme.keepDiary  = randomizer.Chance(WorldProperties.ChancesThatMemeWillWriteALog);
            meme.efficiency = -1;
            meme.price      = -1;
            if (featureDescription.MemeEfficiencyMean > 1 && (featureDescription.range == FeatureRange.ZeroToOne || featureDescription.range == FeatureRange.MinusOneToPlusOne))
            {
                meme.efficiency = 1;
            }
            else if (featureDescription.MemeEfficiencyMean <= -1 && featureDescription.range == FeatureRange.MinusOneToPlusOne)
            {
                meme.efficiency = -1;
            }
            else
            {
                do
                {
                    meme.efficiency = randomizer.NormalRandom(featureDescription.MemeEfficiencyMean, featureDescription.MemeEfficiencyStdDev);
                    if (meme.efficiency == 0)
                    {
                        Console.WriteLine($"meme.efficiency == 0");
                    }
                }while (meme.efficiency < featureDescription.LowerRange || (meme.efficiency > featureDescription.UpperRange));                             // А что, все мымы теперь 0-1? Может у нас специальный мем снижающий какое-то качество, почему бы и нет, собственно? Пусть отбор решает. Заодно посмотрим что он там нарешать сможет.
            }
            meme.complexityCoefficient = Math.Pow(2, (meme.efficiency - featureDescription.MemeEfficiencyMean) / featureDescription.MemeEfficiencyStdDev); // Зачем вообще complexityCoefficient считать внутри цикла?

            while (meme.price < 0)
            {
                var pedestalPrice        = featureDescription.MemePricePedestal;
                var efficiencyPrice      = Math.Abs(meme.efficiency) * featureDescription.MemePriceEfficiencyRatio;
                var randomPricePart      = randomizer.NormalRandom(featureDescription.MemePriceRandomMean, featureDescription.MemePriceRandomStdDev);
                var complexityMultiplier = Math.Pow(meme.ComplexityCoefficient, WorldProperties.MemeCostComplexityPriceCoefficient);
                meme.price = (pedestalPrice + efficiencyPrice + randomPricePart) * complexityMultiplier;
            }

            meme.Report(string.Format("Meme teaches how {3}. It affects: {0}; Efficiency: {1:f5}; It takes {2:f2} memory.", memeAffectedFeature.GetDescription(), meme.Efficiency, meme.Price, meme.ActionDescription)); // Логер, конечно, можно не переделывать, потому что мемы создаются шибко редко.

            return(meme);
        }
예제 #13
0
    public void CreateSign(FeatureDescription d)
    {
        GameObject go = new GameObject("SignText", typeof(TextMeshPro));

        TextMeshPro text = go.GetComponent <TextMeshPro>();

        text.text = d.text;
        text.autoSizeTextContainer = true;
        text.color = Color.black;

        SetCommon(go, d);

        float s = 0.05f;

        go.transform.localScale = new Vector3(s, s, s);

        // fixme remove nudge
        go.transform.localPosition += new Vector3(0, 0, -0.125f);
    }
        /// <summary>
        /// Returns true if ComAdobeGraniteFragsImplRandomFeatureProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of ComAdobeGraniteFragsImplRandomFeatureProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ComAdobeGraniteFragsImplRandomFeatureProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     FeatureName == other.FeatureName ||
                     FeatureName != null &&
                     FeatureName.Equals(other.FeatureName)
                     ) &&
                 (
                     FeatureDescription == other.FeatureDescription ||
                     FeatureDescription != null &&
                     FeatureDescription.Equals(other.FeatureDescription)
                 ) &&
                 (
                     ActivePercentage == other.ActivePercentage ||
                     ActivePercentage != null &&
                     ActivePercentage.Equals(other.ActivePercentage)
                 ) &&
                 (
                     CookieName == other.CookieName ||
                     CookieName != null &&
                     CookieName.Equals(other.CookieName)
                 ) &&
                 (
                     CookieMaxAge == other.CookieMaxAge ||
                     CookieMaxAge != null &&
                     CookieMaxAge.Equals(other.CookieMaxAge)
                 ));
        }
예제 #15
0
        private static double MutateFeature(Random randomizer, double parentGenes, FeatureDescription feature)
        {
            double newFeatureValue = -1;
            Double lowerBound      = 0;
            Double upperBound      = Double.PositiveInfinity;

            if (feature.range == FeatureRange.ZeroToOne)
            {
                upperBound = 1;
            }
            short attempts = 0;

            do   // Обычно правильные данные выпадают с первого раза. и получается, что у нас ровно в два раза больше проверок, чем надо.
            {
                if (attempts == 500)
                {
                    MessageBox.Show("Randomizer could not produce a value for a feature to fit between " + lowerBound + " and " + upperBound + " after 500 consecutive throws. The last attempt was " + newFeatureValue + ". Please fix the genetic values.", "Bad genetic initial data", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                newFeatureValue = parentGenes + randomizer.NormalRandom(feature.MutationStrengthMean, feature.MutationStrengthStdDev);
                attempts++;
            }while (newFeatureValue < lowerBound || newFeatureValue > upperBound); // При кривых начальных данных, например mean = -2 std = 1 может замедлиться в сотни раз.
            return(newFeatureValue);
        }
예제 #16
0
        /// <summary>
        /// Gets groups containing the descriptions for all features for the specified product.
        /// </summary>
        /// <param name="productName">The name of the product for which the feature descriptions should be retrieved.</param>
        /// <returns>An enumerable collection of <see cref="Entities.Group"/> instances.</returns>
        public async Task <IEnumerable <Group> > GetGroupedFeatureDescriptionsAsync(string productName)
        {
            Dictionary <string, List <FeatureDescription> > featureDescriptions = new Dictionary <string, List <FeatureDescription> >();
            Dictionary <string, Group> groups = new Dictionary <string, Group>();

            using (var session = _storeProvider.Store.OpenAsyncSession())
            {
                var data = await session.Query <DbFeature, Features_ByTitleProductAndGroup>()
                           .Where(feature => feature.Product.Equals(productName, StringComparison.OrdinalIgnoreCase))
                           .Select(feature =>
                                   new
                {
                    feature.Group,
                    feature.ParentTitle,
                    feature.Title,
                    feature.Versions
                })
                           .Take(1000)
                           .ToListAsync();

                var comparer = new SemanticVersionComparer();
                foreach (var uniqueFeature in data.GroupBy(record => (group: record.Group, title: record.Title)))
                {
                    var latestFeature      = uniqueFeature.OrderByDescending(record => record.Versions.OrderByDescending(v => v, comparer).First(), comparer).First();
                    var featureDescription = new FeatureDescription()
                    {
                        Title         = uniqueFeature.Key.title,
                        LatestVersion = latestFeature.Versions.OrderByDescending(v => v, comparer).First(),
                    };

                    if (String.IsNullOrWhiteSpace(latestFeature.ParentTitle))
                    {
                        if (!groups.ContainsKey(latestFeature.Group))
                        {
                            // Create a new group
                            groups.Add(latestFeature.Group, new Group()
                            {
                                Name     = latestFeature.Group,
                                Features = new List <FeatureDescription>()
                            });
                        }

                        // Add the feature to the group
                        ((List <FeatureDescription>)groups[latestFeature.Group].Features).Add(featureDescription);
                    }
                    else
                    {
                        if (!featureDescriptions.ContainsKey(latestFeature.ParentTitle))
                        {
                            featureDescriptions.Add(latestFeature.ParentTitle, new List <FeatureDescription>());
                        }

                        featureDescriptions[latestFeature.ParentTitle].Add(featureDescription);
                    }
                }

                // Map the lower levels
                foreach (var feature in groups.Values.SelectMany(group => group.Features))
                {
                    AddChildren(feature, featureDescriptions);
                }
            }

            return(groups.Values.OrderBy(group => group.Name).ToList());
        }
예제 #17
0
        public static void ProcessFeatureXml(XmlNode featureNode, Hashtable features)
        {
            FeatureDescription description = new FeatureDescription();

            string  feature = NodeText(featureNode.Attributes["name"]);
            Feature thisFeature;

            switch (feature)
            {
            case "Writer Blog": thisFeature = Feature.TeamBlog; break;

            case "Insert Maps": thisFeature = Feature.Maps; break;

            case "Terms of Use": thisFeature = Feature.TermsOfUse; break;

            case "Privacy": thisFeature = Feature.Privacy; break;

            case "Help": thisFeature = Feature.Help; break;

            case "FTP Help": thisFeature = Feature.FTPHelp; break;

            case "Gallery": thisFeature = Feature.WLGallery; break;

            case "Live Clipboard": thisFeature = Feature.LiveClipboard; break;

            case "Blog Providers": thisFeature = Feature.BlogProviders; break;

            case "Insert Video": thisFeature = Feature.VideoProviders; break;

            case "Tag Providers": thisFeature = Feature.TagProviders; break;

            case "Video Copyright Link": thisFeature = Feature.VideoCopyright; break;

            case "YouTube Video": thisFeature = Feature.YouTubeVideo; break;

            case "Allow Multiselect Images": thisFeature = Feature.AllowMultiSelectImage; break;

            case "Wordpress": thisFeature = Feature.Wordpress; break;

            default: return;
            }

            string enabled = NodeText(featureNode.Attributes["enabled"]);

            description.Enabled = (enabled == "true") ? true : false;

            //check for parameters
            XmlNodeList parameters = featureNode.SelectNodes("parameter");

            foreach (XmlNode param in parameters)
            {
                description.AddParam(param.Attributes["name"].Value, param.Attributes["value"].Value);
            }

            if (features.ContainsKey(thisFeature))
            {
                features[thisFeature] = description;
            }
            else
            {
                features.Add(thisFeature, description);
            }
        }
        public static void ProcessFeatureXml(XmlNode featureNode, Hashtable features)
        {
            FeatureDescription description = new FeatureDescription();

            string feature = NodeText(featureNode.Attributes["name"]);
            Feature thisFeature;
            switch (feature)
            {
                case "Writer Blog": thisFeature = Feature.TeamBlog; break;
                case "Insert Maps": thisFeature = Feature.Maps; break;
                case "Terms of Use": thisFeature = Feature.TermsOfUse; break;
                case "Privacy": thisFeature = Feature.Privacy; break;
                case "Help": thisFeature = Feature.Help; break;
                case "FTP Help": thisFeature = Feature.FTPHelp; break;
                case "Gallery": thisFeature = Feature.WLGallery; break;
                case "Live Clipboard": thisFeature = Feature.LiveClipboard; break;
                case "Blog Providers": thisFeature = Feature.BlogProviders; break;
                case "Insert Video": thisFeature = Feature.VideoProviders; break;
                case "Tag Providers": thisFeature = Feature.TagProviders; break;
                case "Video Copyright Link": thisFeature = Feature.VideoCopyright; break;
                case "YouTube Video": thisFeature = Feature.YouTubeVideo; break;
                case "Allow Multiselect Images": thisFeature = Feature.AllowMultiSelectImage; break;
                case "Wordpress": thisFeature = Feature.Wordpress; break;
                default: return;
            }

            string enabled = NodeText(featureNode.Attributes["enabled"]);
            description.Enabled = (enabled == "true") ? true : false;

            //check for parameters
            XmlNodeList parameters = featureNode.SelectNodes("parameter");
            foreach (XmlNode param in parameters)
            {
                description.AddParam(param.Attributes["name"].Value, param.Attributes["value"].Value);
            }

            if (features.ContainsKey(thisFeature))
                features[thisFeature] = description;
            else
                features.Add(thisFeature, description);

        }
        private IEnumerable <string> GetVersionsForFeature(HttpClient client, string groupName, FeatureDescription feature)
        {
            var versionsUri = $"{Options.AugurkUrl}/api/v2/products/{Options.ProductName}/groups/{groupName}/features/{feature.Title}/versions";
            var response    = client.GetAsync(versionsUri).Result;

            response.EnsureSuccessStatusCode();

            return(JsonConvert.DeserializeObject <IEnumerable <string> >(response.Content.ReadAsStringAsync().Result));
        }
 public NavigationParameter(FeatureDescription feature, NavigationHelper navigation)
 {
     Feature    = feature;
     Navigation = navigation;
 }