Ejemplo n.º 1
0
        /// <summary>
        /// Adds a strong analogy to the list, cloning in memory any sub analogies/relationships necessary. i.e. we duplicate the tree structure.
        /// </summary>
        /// <param name="a"></param>
        public void AddAnalogy(Analogy a)
        {
            // First check if it already exists.
            Analogy found = FindAnalogy(a);

            // If it exists, update (by adding relationships, not taking away)
            if (found != null)
            {
                UpdateAnalogy(found, a);
                return;
            }

            // Otherwise, clone and store new version.
            GroupElement lhs = a.LHS.DeepCopy();
            GroupElement rhs = a.RHS.DeepCopy();

            Analogy newAnalogy = new Analogy(lhs, rhs, workspace);

            // Clone analogy relationships.
            newAnalogy.CloneRelationshipsFrom(a);

            analogies.Add(newAnalogy);
            analogyCompetitionStats[newAnalogy] = new CompetitionStats();
            analogyCompetitionStats[newAnalogy].AddWin();               // start with default win.
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds group to the collection, unless one with the same range and same subelements exists.
        /// </summary>
        /// <param name="g"></param>
        public void AddGroup(Group g)
        {
            // Make sure group doens't already exist.
            if (FindExistingGroup(g) != null)
            {
                return;
            }

            Group newGroup = (Group)g.DeepCopy();

            groups.Add(newGroup);

            groupCompetitionStats[newGroup] = new CompetitionStats();
            groupCompetitionStats[newGroup].AddWin();                   // start with default win.
        }