Ejemplo n.º 1
0
    public void VerifFormule()
    {
        Jardin jardin = terrainHandler.getJardin();
        Communicate comm = new Communicate(SCRIPT_PYTHON, jardin);
        //lance le script
        comm.GetSource().Execute(comm.GetScope());
        for (int i = 1; i <= NB_FORMULE; i++)
        {
            iField = (InputField)GameObject.Find(PATH + "Form_" + i).GetComponent<InputField>();
            output = (Text)GameObject.Find(PATH + "VerifPan_" + i + "/verif_resultat_" + i).GetComponent<Text>();

            if (iField.text == "")
            {
                continue;
            }
            try
            {
                Formule formule = FormuleFactory.parse(iField.text);

                foreach (Element el in jardin.GetElements())
                {
                    Debug.Log(el);
                }

                object pythonForm = comm.HandleForm(formule);
                Func<Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable<Func<Jardin, object>>("unity_my_interp_formul");
                object pythonJardin = unity_my_interp_formul(jardin);
                Func<object, object, object> unity_eval_one_form = comm.GetScope().GetVariable<Func<object, object, object>>("unity_eval_one_form");
                var res = unity_eval_one_form(pythonJardin, pythonForm);

                //Affiche résultat
                if ((bool)res == true)
                {
                    output.color = Color.green;
                    output.text = "Vrai";
                }
                else
                {
                    output.color = Color.red;
                    output.text = "Faux";
                }
            }
            catch (ParserLogException)
            {
                output.color = Color.red;
                output.text = "Erreur";
                Debug.Log("Erreur formule");
            }
            catch (ValueErrorException)
            {
                output.color = new Color32(255, 128, 0, 255);
                output.text = "Var libre";
            }
            catch (Exception)
            {
                output.color = Color.red;
                output.text = "Erreur imprévue";
            }
        }
    }
Ejemplo n.º 2
0
    public void VerifFormule()
    {
        iField = focusHandler.getCurrentFormule();
        output = focusHandler.getCurrentVerif();

        if (string.IsNullOrEmpty(iField.text))
        {
            return;
        }
        try
        {
            Formule     formule = FormuleFactory.parse(iField.text);
            Jardin      jardin  = terrainHandler.getJardin();
            Communicate comm    = new Communicate(SCRIPT_PYTHON, jardin);
            foreach (Element el in jardin.GetElements())
            {
                Debug.Log(el);
            }


            //lance le script
            comm.GetSource().Execute(comm.GetScope());
            object pythonForm = comm.HandleForm(formule);
            Func <Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable <Func <Jardin, object> >("unity_my_interp_formul");
            object pythonJardin = unity_my_interp_formul(jardin);
            Func <object, object, object> unity_eval_one_form = comm.GetScope().GetVariable <Func <object, object, object> >("unity_eval_one_form");
            var res = unity_eval_one_form(pythonJardin, pythonForm);
            Debug.Log("res=" + res);

            //Affiche résultat
            if ((bool)res == true)
            {
                output.color = Color.green;
                output.text  = "Vrai";
            }
            else
            {
                output.color = Color.red;
                output.text  = "Faux";
            }
        }
        catch (ParserLogException)
        {
            output.color = Color.red;
            output.text  = "Erreur";
            Debug.Log("Erreur formule");
        }
        catch (ValueErrorException)
        {
            output.color = new Color32(255, 128, 0, 255);
            output.text  = "Var libre";
        }
        catch (Exception)
        {
            output.color = Color.red;
            output.text  = "Erreur imprévue";
        }
    }
Ejemplo n.º 3
0
    public void VerifFormule()
    {
        iField = focusHandler.getCurrentFormule();
        output = focusHandler.getCurrentVerif();

        if (string.IsNullOrEmpty(iField.text))
        {
            return;
        }
        try
        {
            Formule formule = FormuleFactory.parse(iField.text);
            Jardin jardin = terrainHandler.getJardin();
            Communicate comm = new Communicate(SCRIPT_PYTHON, jardin);
            foreach(Element el in jardin.GetElements())
            {
                Debug.Log(el);
            }

            //lance le script
            comm.GetSource().Execute(comm.GetScope());
            object pythonForm = comm.HandleForm(formule);
            Func<Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable<Func<Jardin, object>>("unity_my_interp_formul");
            object pythonJardin = unity_my_interp_formul(jardin);
            Func<object, object, object> unity_eval_one_form = comm.GetScope().GetVariable<Func<object, object, object>>("unity_eval_one_form");
            var res = unity_eval_one_form(pythonJardin, pythonForm);
            Debug.Log("res=" + res);

            //Affiche résultat
            if ((bool)res == true)
            {
                output.color = Color.green;
                output.text = "Vrai";
            }
            else
            {
                output.color = Color.red;
                output.text = "Faux";
            }
        }
        catch (ParserLogException)
        {
            output.color = Color.red;
            output.text = "Erreur";
            Debug.Log("Erreur formule");
        }
        catch (ValueErrorException)
        {
            output.color = new Color32(255, 128, 0, 255);
            output.text = "Var libre";
        }
        catch (Exception)
        {
            output.color = Color.red;
            output.text = "Erreur imprévue";
        }
    }
Ejemplo n.º 4
0
    public object formules(Communicate comm)
    {
        String[] formuleTab = new string[]
        {
            "Rose(d)",
            "∀xRose(x)",
            "∃xRose(x)",
            "∀x(est_blanc(x) ⇒ ∃y(plus_petit_que(x,y) ∧ a_l_est_de(y,x)))"
        };

        object pythonArray = comm.pythonEmptyArray();

        foreach (String str in formuleTab)
        {
            comm.pythonAddInArray(pythonArray, comm.HandleForm(FormuleFactory.parse(str)));
        }
        return(pythonArray);
    }
Ejemplo n.º 5
0
    public object formules(Communicate comm)
    {
        String[] formuleTab = new string[]
            {
                "Rose(d)",
                "∀xRose(x)",
                "∃xRose(x)",
                "∀x(est_blanc(x) ⇒ ∃y(plus_petit_que(x,y) ∧ a_l_est_de(y,x)))"
            };

        object pythonArray = comm.pythonEmptyArray();

        foreach (String str in formuleTab)
        {
            comm.pythonAddInArray(pythonArray, comm.HandleForm(FormuleFactory.parse(str)));
        }
        return pythonArray;
    }
Ejemplo n.º 6
0
    public void test_one_form(String form, int name, Communicate comm, Jardin jardin)
    {
        Debug.Log("====================" + "f" + name + "====================");
        Formule f = FormuleFactory.parse(form);

        try
        {
            object pythonForm = comm.HandleForm(f);
            Debug.Log(name + " = " + pythonForm.ToString());

            Func<Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable<Func<Jardin, object>>("unity_my_interp_formul");
            object pythonJardin = unity_my_interp_formul(jardin);
            Func<object, object, object> unity_eval_one_form = comm.GetScope().GetVariable<Func<object, object, object>>("unity_eval_one_form");

            Debug.Log("f" + name + " = " + unity_eval_one_form(pythonJardin, pythonForm));
            Debug.Log("===========================================================");
        }
        catch (CommException c)
        {
            Debug.Log(c);
        }
    }
Ejemplo n.º 7
0
    public void test_one_form(String form, int name, Communicate comm, Jardin jardin)
    {
        Debug.Log("====================" + "f" + name + "====================");
        Formule f = FormuleFactory.parse(form);

        try
        {
            object pythonForm = comm.HandleForm(f);
            Debug.Log(name + " = " + pythonForm.ToString());

            Func <Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable <Func <Jardin, object> >("unity_my_interp_formul");
            object pythonJardin = unity_my_interp_formul(jardin);
            Func <object, object, object> unity_eval_one_form = comm.GetScope().GetVariable <Func <object, object, object> >("unity_eval_one_form");

            Debug.Log("f" + name + " = " + unity_eval_one_form(pythonJardin, pythonForm));
            Debug.Log("===========================================================");
        }
        catch (CommException c)
        {
            Debug.Log(c);
        }
    }
Ejemplo n.º 8
0
    public void VerifFormule()
    {
        Jardin      jardin = terrainHandler.getJardin();
        Communicate comm   = new Communicate(SCRIPT_PYTHON, jardin);

        //lance le script
        comm.GetSource().Execute(comm.GetScope());
        for (int i = 1; i <= NB_FORMULE; i++)
        {
            iField = (InputField)GameObject.Find(PATH + "Form_" + i).GetComponent <InputField>();
            output = (Text)GameObject.Find(PATH + "VerifPan_" + i + "/verif_resultat_" + i).GetComponent <Text>();

            if (iField.text == "")
            {
                continue;
            }
            try
            {
                Formule formule = FormuleFactory.parse(iField.text);


                foreach (Element el in jardin.GetElements())
                {
                    Debug.Log(el);
                }

                object pythonForm = comm.HandleForm(formule);
                Func <Jardin, object> unity_my_interp_formul = comm.GetScope().GetVariable <Func <Jardin, object> >("unity_my_interp_formul");
                object pythonJardin = unity_my_interp_formul(jardin);
                Func <object, object, object> unity_eval_one_form = comm.GetScope().GetVariable <Func <object, object, object> >("unity_eval_one_form");
                var res = unity_eval_one_form(pythonJardin, pythonForm);

                //Affiche résultat
                if ((bool)res == true)
                {
                    output.color = Color.green;
                    output.text  = "Vrai";
                }
                else
                {
                    output.color = Color.red;
                    output.text  = "Faux";
                }
            }
            catch (ParserLogException)
            {
                output.color = Color.red;
                output.text  = "Erreur";
                Debug.Log("Erreur formule");
            }
            catch (ValueErrorException)
            {
                output.color = new Color32(255, 128, 0, 255);
                output.text  = "Var libre";
            }
            catch (Exception)
            {
                output.color = Color.red;
                output.text  = "Erreur imprévue";
            }
        }
    }