/// <summary>
 /// Create an expression of the specified type, using the specified pattern.
 /// </summary>
 /// <param name="type">The expression type.</param>
 /// <param name="pattern">The expression pattern.</param>
 public static IExpression Create(Expression.Type type, string pattern)
 {
     if (type == Type.RegularExpression)
     {
         return(new RegexExpression(pattern));
     }
     if (pattern.StartsWith("r:"))
     {
         return(new RegexExpression(pattern.Substring(2)));
     }
     return(new NamePartExpression(pattern));
 }
Exemplo n.º 2
0
        void UpdateExpression(List <int> list)
        {
            int winChances = 0, loseChances = 0, tieChances = 0;
            int goodValue = 0, badValue = 0;

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] >= 300)
                {
                    winChances++;
                }
                else if (list[i] <= -300)
                {
                    loseChances++;
                }
                else if (list[i] == 0)
                {
                    tieChances++;
                }
                if (list[i] > 0)
                {
                    goodValue++;
                }
                else if (list[i] < 0)
                {
                    badValue++;
                }
            }
            if (winChances > 0 && winChances <= 2) //easy win
            {
                expression = Expression.Type.think_closetowin;
            }
            if (winChances > 2) //so easy, let's fool him
            {
                expression = Expression.Type.think_bigwin;
            }
            if (winChances > 0 && (loseChances > 0 || tieChances > 0) && Math.Abs(winChances - loseChances) <= 1) //close match
            {
                expression = Expression.Type.think_closegame;
            }
            if (winChances == 0 && loseChances > 0) //lose
            {
                expression = Expression.Type.think_closetolose;
            }
            if (winChances == 0 && loseChances == 0) //early to judge
            {
                expression = (goodValue + badValue) % 2 == 0 ? Expression.Type.think_earlytojudge : Expression.Type.think_earlytojudge2;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Configure bounded layer rules.
 /// </summary>
 /// <param name="expType">Expression type.</param>
 public static IConfiguration Configure(Expression.Type expType = Expression.Type.NamePart)
 {
     return(new Configuration(expType));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BoundedLayers.Models.Configuration"/> class.
 /// </summary>
 /// <param name="expType">Expression type.</param>
 public Configuration(Expression.Type expType)
 {
     _expType = expType;
 }