Example #1
0
 public static void DFS_for_if(if_operator if_)
 {
     for (int i = 0; i < if_.info.information.if_Operators.Count; i++)
     {
         bool isCorrect = false;
         for (int k = 0; k < ifs.Count; k++)
         {
             if (if_.info.information.if_Operators[i] == ifs[k].info.information)
             {
                 if (ifs[k].path == -1)
                 {
                     DFS_for_if(ifs[k]);
                 }
                 if (ifs[k].path >= 0)
                 {
                     for (int q = 0; q < if_.info.information.if_Operators[i].exits[ifs[k].path].Count; q++)
                     {
                         if (if_.info.information.if_Operators[i].exits[ifs[k].path][q] == Controller.results[i].information)
                         {
                             isCorrect = true;
                             break;
                         }
                     }
                 }
                 else
                 {
                     isCorrect = true;
                 }
                 break;
             }
         }
         if (!isCorrect)
         {
             if_.path = -2;
             return;
         }
     }
     try
     {
         List <int> indexes = new List <int>();
         for (int k = 0; k < if_.info.information.up_connection.Count; k++)
         {
             for (int j = 0; j < Data.Count; j++)
             {
                 if (if_.info.information.up_connection[k] == Data[j].info.information)
                 {
                     indexes.Add(j);
                     if (Data[j].data == null)
                     {
                         DFS_for_WD(Data[j]);
                         if (Data[j].data == null)
                         {
                             Data[j].isTrue = false;
                         }
                     }
                     if (!Data[j].isTrue)
                     {
                         throw new Exception();
                     }
                     break;
                 }
             }
         }
         Math_Field[] opearnds = new Math_Field[indexes.Count];
         int          Count    = 0;
         for (int i = 0; i < indexes.Count; i++)
         {
             if (Data[indexes[i]].isTrue)
             {
                 if (Math_Field.idCOM(Data[indexes[0]].data, Data[indexes[i]].data))
                 {
                     Math_Field.id_to_normal(Data[indexes[0]].data, ref Data[indexes[i]].data);
                 }
                 else
                 {
                     Math_Field.id_to_normal(Data[indexes[i]].data, ref Data[indexes[0]].data);
                 }
                 opearnds[Count] = Data[indexes[i]].data;
                 Count++;
             }
         }
         if_.path = Config.logic(if_.info.information.name, opearnds);
     }
     catch
     {
         if_.path = -1;
         return;
     }
 }
Example #2
0
        public static void DFS_for_if(if_operator if_)
        {
            for (int i = 0; i < if_.info.information.if_Operators.Count; i++)
            {
                bool isCorrect = false;
                for (int k = 0; k < ifs.Count; k++)
                {
                    if (if_.info.information.if_Operators[i] == ifs[k].info.information)
                    {
                        if (ifs[k].path == -1)
                        {
                            DFS_for_if(ifs[k]);
                        }
                        if (ifs[k].path >= 0)
                        {
                            for (int q = 0; q < if_.info.information.if_Operators[i].exits[ifs[k].path].Count; q++)
                            {
                                if (if_.info.information.if_Operators[i].exits[ifs[k].path][q] == Controller.results[i].information)
                                {
                                    isCorrect = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            isCorrect = true;
                        }
                        break;
                    }
                }
                if (!isCorrect)
                {
                    if_.path = -2;
                    return;
                }
            }
            try
            {
                List <int> indexes = new List <int>();
                for (int k = 0; k < if_.info.information.up_connection.Count; k++)
                {
                    for (int j = 0; j < Data.Count; j++)
                    {
                        if (if_.info.information.up_connection[k] == Data[j].info.information)
                        {
                            indexes.Add(j);
                            if (Data[j].data == null)
                            {
                                DFS_for_WD(Data[j]);
                                if (Data[j].data == null)
                                {
                                    Data[j].isTrue = false;
                                }
                            }
                            if (!Data[j].isTrue)
                            {
                                throw new Exception();
                            }
                            break;
                        }
                    }
                }
                switch (if_.info.information.name)
                {
                case "COM_NN_D":
                {
                    if (Math_Field.idCOM(Data[indexes[0]].data, Data[indexes[1]].data))
                    {
                        Math_Field.id_to_normal(Data[indexes[0]].data, ref Data[indexes[1]].data);
                        switch (Data[indexes[0]].data.COM(Data[indexes[1]].data))
                        {
                        case 1:
                        {
                            if_.path = 0;
                        }
                        break;

                        case 0:
                        {
                            if_.path = 1;
                        }
                        break;

                        case 2:
                        {
                            if_.path = 2;
                        }
                        break;
                        }
                    }
                    else
                    {
                        Math_Field.id_to_normal(Data[indexes[1]].data, ref Data[indexes[0]].data);
                        switch (Data[indexes[1]].data.COM(Data[indexes[0]].data))
                        {
                        case 2:
                        {
                            if_.path = 0;
                        }
                        break;

                        case 0:
                        {
                            if_.path = 1;
                        }
                        break;

                        case 1:
                        {
                            if_.path = 2;
                        }
                        break;
                        }
                    }
                    return;
                }

                case "isDown":
                {
                    if (Data[indexes[0]].data.isDown)
                    {
                        if_.path = 0;
                    }
                    else
                    {
                        if_.path = 1;
                    }
                    return;
                }
                }
            }
            catch
            {
                if_.path = -1;
                return;
            }
        }