コード例 #1
0
    public void unsubstitute(Eq eqbefore, Eq eqafter)
    {
        string prevEq = currentEquation.print();

        eqafter         = eqafter.substitute(new Eq("★"), substitutions);
        eqafter         = eqafter.substitute(new Eq("◎"), substitutionc);
        currentEquation = currentEquation.substitute(eqbefore, eqafter);
        if (!prevEq.Equals(currentEquation.print()))
        {
            currentEquation     = currentEquation.substitute(new Eq("◎"), new Eq("★"));
            substitutions       = substitutionc;
            starAvailable       = true;
            currentFormula.text = currentEquation.print();
            fullFormula.text   += "\n" + currentEquation.print();
            if (yexist)
            {
                if (eqbefore.print().Contains("x") || eqbefore.print().Contains("y"))
                {
                    if (currentEquation.find(answer))
                    {
                        pm.ProbSolved();
                        pm.transGlow.SetActive(false);
                        for (int i = 0; i < 5; i++)
                        {
                            PracTranss[i].GetComponent <PracTrans>().eq = new Eq("");
                            PracTranss[i].GetComponent <PracTrans>().setEq();
                        }
                    }
                }
            }
            else if (currentEquation.find(answer))
            {
                pm.ProbSolved();
                pm.transGlow.SetActive(false);
                for (int i = 0; i < 5; i++)
                {
                    PracTranss[i].GetComponent <PracTrans>().eq = new Eq("");
                    PracTranss[i].GetComponent <PracTrans>().setEq();
                }
            }
            else
            {
                pm.transGlow.SetActive(true);
            }
        }
        else
        {
            pm.ProbFailed();
        }
    }
コード例 #2
0
ファイル: Equation.cs プロジェクト: snuproject2019/diff
    public bool find(Eq e)
    {
        Eq t = new Eq(this.operat, this.operand1, this.operand2);

        if (t.print() == e.print())
        {
            return(true);
        }
        else
        {
            if (operand2 != null)
            {
                if (t.operand2.find(e))
                {
                    return(true);
                }
                ;
            }
            if (operand1 != null)
            {
                if (t.operand1.find(e))
                {
                    return(true);
                }
                ;
            }
            return(false);
        }
    }
コード例 #3
0
ファイル: Equation.cs プロジェクト: snuproject2019/diff
 public string print()
 {
     if (operand2 != null)
     {
         if (operat.Equals("/"))
         {
             return("\\frac " + "{" + operand1.print() + "} {" + operand2.print() + "}");
         }
         return("{{" + operand1.print() + "}" + operat + "{" + operand2.print() + "}}");
     }
     else if (operand1 != null)
     {
         return(operat + "{(" + operand1.print() + ")}");
     }
     else
     {
         return(operat);
     }
 }
コード例 #4
0
    public void substitutex(Eq eq)
    {
        string symbol;

        if (starAvailable)
        {
            symbol        = "★";
            starAvailable = false;
            substitutions = eq;
        }
        else
        {
            symbol        = "◎";
            substitutionc = eq;
        }

        currentEquation     = currentEquation.dsubstitute(eq, new Eq(symbol));
        currentFormula.text = currentEquation.print();
        fullFormula.text   += "\n" + currentEquation.print();
        //SetTools();
    }
コード例 #5
0
    public void CreateProblem()
    {
        m = Random.Range(2, 10);
        n = Random.Range(2, 10);
        Eq[] probs =
        {
            new Eq("d", new Eq("^",         new Eq("e"),          new Eq("sin",           new Eq("^",             new Eq("x"),             new Eq(m.ToString()))))),
            new Eq("d", new Eq("^",         new Eq("e"),          new Eq(" \\times ",     new Eq(n.ToString()),   new Eq("x")))),
            new Eq("d", new Eq("+",         new Eq("^",           new Eq("x"),            new Eq(m.ToString())),  new Eq("^",              new Eq("e"),             new Eq("sin",           new Eq("y"))))),
            new Eq("d", new Eq("^",         new Eq("sin",         new Eq("x")),           new Eq(m.ToString()))),
            new Eq("d", new Eq("^",         new Eq("+",           new Eq("x"),            new Eq("sin",           new Eq("y"))),           new Eq(m.ToString()))),
            new Eq("d", new Eq("+",         new Eq("cos",         new Eq("x")),           new Eq("sin",           new Eq("y")))),
            new Eq("d", new Eq("cos",       new Eq("sin",         new Eq("x")))),
            new Eq("d", new Eq("+",         new Eq("cos",         new Eq("x")),           new Eq("y"))),
            new Eq("d", new Eq(" \\times ", new Eq(n.ToString()), new Eq("^",             new Eq("x"),            new Eq(m.ToString())))),
            new Eq("d", new Eq(" \\times ", new Eq("^",           new Eq("e"),            new Eq("x")),           new Eq("cos",            new Eq("y")))),
            new Eq("d", new Eq(" \\times ", new Eq(n.ToString()), new Eq("x"))),
            new Eq("d", new Eq(" \\times ", new Eq("x"),          new Eq("y"))),
            new Eq("d", new Eq("+",         new Eq("x"),          new Eq("^",             new Eq("e"),            new Eq(" \\times ",      new Eq(n.ToString()),    new Eq("y"))))),
            new Eq("d", new Eq("^",         new Eq("e"),          new Eq(" \\times ",     new Eq("x"),            new Eq("sin",            new Eq("y"))))),
            new Eq("d", new Eq(" \\times ", new Eq(n.ToString()), new Eq("^",             new Eq("x"),            new Eq(m.ToString())))),
            new Eq("d", new Eq("^",         new Eq("e"),          new Eq(" \\times ",     new Eq("sin",           new Eq("x")),            new Eq("cos",            new Eq("y"))))),
            new Eq("d", new Eq(" \\times ", new Eq(" \\times ",   new Eq(n.ToString()),   new Eq("sin",           new Eq("x"))),           new Eq("^",              new Eq("e"),            new Eq("y")))),
            new Eq("d", new Eq("^",         new Eq("e"),          new Eq("cos",           new Eq(" \\times ",     new Eq("^",              new Eq("x"),             new Eq(m.ToString())),  new Eq("y"))))),
            new Eq("d", new Eq("^",         new Eq("x"),          new Eq(m.ToString()))),
            new Eq("d", new Eq(" \\times ", new Eq(n.ToString()), new Eq("^",             new Eq("x"),            new Eq(m.ToString()))))
        };
        Eq prob = probs[Random.Range(0, probs.Length)];

        yexist = prob.print().Contains("y");
        currentFormula.text = prob.print();
        fullFormula.text    = prob.print();
        currentEquation     = prob;
        trans         = true;
        starAvailable = true;
        SetPracTranss();
        SetTools();
    }
コード例 #6
0
ファイル: Equation.cs プロジェクト: snuproject2019/diff
    /*
     * public void dunsubstitute(Eq e){
     *  if(this.operat=="d"){
     *      operand1.unsubstitute(e);
     *  }else{
     *      if(this.operat!=""){
     *          operand1.dunsubstitute(e);
     *          if(operand2!=null){
     *              operand2.dunsubstitute(e);
     *          }
     *      }
     *  }
     *  setValue();
     * }
     */
    public Eq substitute(Eq e, Eq newE)
    {
        Eq t = new Eq(this.operat, this.operand1, this.operand2);

        if (t.print() == e.print())
        {
            return(newE);
        }
        else
        {
            if (operand2 != null)
            {
                t.operand2 = t.operand2.substitute(e, newE);
            }
            if (operand1 != null)
            {
                t.operand1 = t.operand1.substitute(e, newE);
            }
            return(t);
        }
    }
コード例 #7
0
    void SetPracTranss()
    {
        List <Eq> cards = currentEquation.operand1.split();

        foreach (Eq x in cards)
        {
            Debug.Log(x.print());
        }
        for (int i = 0; i < Mathf.Min(cards.Count - 1, 5); i++)
        {
            PracTranss[i].GetComponent <PracTrans>().eq = cards[i + 1];
            PracTranss[i].GetComponent <PracTrans>().setEq();
        }
        for (int i = Mathf.Min(cards.Count - 1, 5); i < 5; i++)
        {
            PracTranss[i].GetComponent <PracTrans>().eq = new Eq("");
            PracTranss[i].GetComponent <PracTrans>().setEq();
        }
        if (yexist)
        {
            if (Random.Range(0, 1) < 0.5f)
            {
                answer = new Eq("d", new Eq("x"));
                isy    = false;
            }
            else
            {
                answer = new Eq("d", new Eq("y"));
                isy    = true;
            }
        }
        else
        {
            answer = new Eq("d", cards[Random.Range(1, cards.Count)]);
        }
        problem.text = currentFormula.text + "= ?  " + answer.print();
    }
コード例 #8
0
 public void setEq()
 {
     text.text = eq.print();
     selected.SetActive(false);
 }
コード例 #9
0
ファイル: Equation.cs プロジェクト: snuproject2019/diff
 public bool equals(Eq e)
 {
     return(this.print().Equals(e.print()));
 }
コード例 #10
0
ファイル: Equation.cs プロジェクト: snuproject2019/diff
 public string print()
 {
     return(lhs.print() + " \\rightarrow " + rhs.print());
 }