コード例 #1
0
ファイル: Equation.cs プロジェクト: greatwallet/Match
        // count the number of difference of matches
        private static int matchDiff(ref Equation root, ref Equation result)
        {
            // Assert: root.optr == result.optr
            Debug.Assert(root.ssds.Count == result.ssds.Count);
            int count = 0;

            for (int i = 0; i < root.ssds.Count; i++)
            {
                count += SSD.diff(root.ssds[i], result.ssds[i]);
            }
            return(count);
        }
コード例 #2
0
ファイル: SSD_match.cs プロジェクト: greatwallet/Match
        // display operator
        public void display(char c)
        {
            // opnd
            if (c - '0' >= 0 && c - '0' <= 9)
            {
                displayDigit(SSD.digit2binary(c - '0'));
                return;
            }
            // optr
            Clear();
            switch (c)
            {
            case '+':
            {
                add2.Visible = true;
                G.Visible    = true;
                break;
            }

            case '-':
            {
                G.Visible = true;
                break;
            }

            case '*':
            {
                mul.Visible = true;
                break;
            }

            case '/':
            {
                divide.Visible = true;
                break;
            }

            case '=':
            {
                eq1.Visible = true;
                eq2.Visible = true;
                break;
            }

            default: return;
            }
        }
コード例 #3
0
ファイル: SSD_match.cs プロジェクト: greatwallet/Match
        // display digit
        public void displayDigit(byte bcd)
        {
            int d = SSD.binary2digit(bcd);

            Debug.Assert(d >= 0 && d <= 9);
            for (int i = 0; i < 7; i++)
            {
                if (checkOnebit(bcd, i))
                {
                    turnUp(i);
                }
                else
                {
                    turnDown(i);
                }
            }
        }
コード例 #4
0
ファイル: Equation.cs プロジェクト: greatwallet/Match
        // expand One Possible random equation List, define its ancestors, attribute, ssds and optr
        private static void expand(Equation father, out List <Equation> children)
        {
            children = new List <Equation>();

            for (int i = 0; i < father.ssds.Count; i++)
            {
                SSD cur_ssd = father.ssds[i];

                // expand curent ssd
                var cur_ssd_list = cur_ssd.expand(father.Attribute);

                for (int j = 0; j < cur_ssd_list.Count; j++)
                {
                    Equation son = new Equation();
                    // ssds
                    son.ssds = new List <SSD>(father.ssds);
                    // change the i'th ssd to a new one.
                    son.ssds[i] = cur_ssd_list[j];

                    // optr
                    son.optr = new Dictionary <int, char>(father.optr);
                    // attribute
                    son.Attribute = inverse(father.Attribute);
                    // ancestors
                    son.anncestors = new List <Equation>(father.anncestors);
                    son.anncestors.Insert(0, father);

                    //* Cut branch Operation*/
                    // if same as grandpa: (means it goes back! ) then should be cut!
                    if (sameAsGrandpa(son, i))
                    {
                        continue;
                    }
                    // if the son's depth = 3, and son's ssds[i] == grandpa's ssds[i], then cut!
                    if (father.get_depth() == 2 && son.ssds[i] == father.anncestors[0].ssds[i])
                    {
                        continue;
                    }

                    children.Add(son);
                }
            }
        }
コード例 #5
0
 public static int diff(SSD left, SSD right)
 {
     return(countOnes(Convert.ToByte(left.BCD ^ right.BCD)));
 }
コード例 #6
0
 public bool Equals(SSD rt)
 {
     return(BCD == rt.BCD);
 }