public int GetCostValue(Attack a) { Mathos.Parser.MathParser parser = new Mathos.Parser.MathParser(); parser.LocalVariables.Add("LVL", LVL); parser.LocalVariables.Add("HP", HP); return((int)parser.Parse(a.costFormula)); }
/////////////////////////////////////////////////////////////////////////////////// #region funcs private string CalcRes(string s) { Mathos.Parser.MathParser parser = new Mathos.Parser.MathParser(); parser.OperatorList = new List <string>() { "˄", "˅", "⊕", "→", "←", "↔", "↓", "|", "-" }; // operators parse parser.OperatorAction.Add("˄", delegate(decimal x1, decimal x2) { return(F1Conjunction(x1, x2)); }); parser.OperatorAction.Add("˅", delegate(decimal x1, decimal x2) { return(F7Disjunction(x1, x2)); }); parser.OperatorAction.Add("⊕", delegate(decimal x1, decimal x2) { return(F6SumMod2(x1, x2)); }); parser.OperatorAction.Add("→", delegate(decimal x1, decimal x2) { return(F13Implication(x1, x2)); }); parser.OperatorAction.Add("←", delegate(decimal x1, decimal x2) { return(F11ImplicationInvert(x1, x2)); }); parser.OperatorAction.Add("↔", delegate(decimal x1, decimal x2) { return(F9Equivalence(x1, x2)); }); parser.OperatorAction.Add("↓", delegate(decimal x1, decimal x2) { return(F8Peirce(x1, x2)); }); parser.OperatorAction.Add("|", delegate(decimal x1, decimal x2) { return(F14Sheffer(x1, x2)); }); // function parse (NotX) parser.LocalFunctions.Add("!", delegate(decimal[] input) { return(F12NotX1(input[0])); }); return(Convert.ToString(parser.Parse(s))); }
public static double parse(string expr) { //try //{ return(Convert.ToDouble(parser.Parse(expr))); //} //catch (Exception e) //{ // Trace.WriteLine(e.Message + "\n"); // return 0.0; //} }
//расчёт точек для построения кривой private PointF[] GetPoints(double a, double b, int numberOfPoints, string func) { double step = Math.Abs(b - a) / numberOfPoints; PointF[] points = new PointF[numberOfPoints]; for (int i = 0; i <= numberOfPoints; i++) { string x = Convert.ToString(a + i * step); parser.ProgrammaticallyParse("let x = " + x.ToString().Replace(",", ".")); if (i == numberOfPoints) { points[i - 1] = new PointF(float.Parse(x), (float)parser.Parse(func.Replace(",", "."))); } else { points[i] = new PointF(float.Parse(x), (float)parser.Parse(func.Replace(",", "."))); } } return(points); }
/// <summary> /// Returns the value from an attack, based on the attack's formula /// </summary> /// <param name="attack"> Attack of object </param> /// <returns> Integer amount </returns> public int GetAttackValue(Attack a) { Mathos.Parser.MathParser parser = new Mathos.Parser.MathParser(); parser.LocalVariables.Add("LVL", LVL); parser.LocalVariables.Add("HP", HP); parser.LocalVariables.Add("CHP", CHP); parser.LocalVariables.Add("MP", MP); parser.LocalVariables.Add("CMP", CMP); parser.LocalVariables.Add("STR", STR); parser.LocalVariables.Add("DEX", DEX); parser.LocalVariables.Add("INT", INT); parser.LocalVariables.Add("LUK", LUK); parser.LocalVariables.Add("PATK", PATK); parser.LocalVariables.Add("MATK", MATK); parser.LocalVariables.Add("PDEF", PDEF); parser.LocalVariables.Add("MDEF", MDEF); return((int)parser.Parse(a.damageFormula)); }
public void UnaryOperators() { var mp = new Mathos.Parser.MathParser(); var result = mp.Parse("-sin(5)"); }
public void UnaryOperators() { var mp = new Mathos.Parser.MathParser(); var result = mp.Parse("-sin(5)"); }