Esempio n. 1
0
        public TwoTermExpression(string input)
        {
            int lowestPriorityOperator      = 257;
            int lowestPriorityOperatorIndex = -1;

            for (int i = 2; i < input.Length; i += 3)
            {
                if ((int)input[i] < lowestPriorityOperator)
                {
                    lowestPriorityOperator      = (int)input[i];
                    lowestPriorityOperatorIndex = i;
                }
            }
            string partA = input.Substring(0, lowestPriorityOperatorIndex);
            string partB = input.Substring(lowestPriorityOperatorIndex + 1);

            if (partA.Length == 2)
            {
                termA = new PieceStatement(partA);
            }
            else
            {
                termA = new TwoTermExpression(partA);
            }
            if (partB.Length == 2)
            {
                termB = new PieceStatement(partB);
            }
            else
            {
                termB = new TwoTermExpression(partB);
            }
            boolOperator = lowestPriorityOperator;
        }
Esempio n. 2
0
 public TwoTermExpression(IBooleanResolvable _a, IBooleanResolvable _b, Random rng, int _operator = -1)
 {
     termA = _a;
     termB = _b;
     termA.increaseOperatorPriority();
     termB.increaseOperatorPriority();
     if (_operator < 0)
     {
         boolOperator = rng.Next(0, 15); // random number min 0 max 15
         // consider reorganizing the operators to cut down on fill time
         while (boolOperator == (int)Operators.T ||
                boolOperator == (int)Operators.F ||
                boolOperator == (int)Operators.P ||
                boolOperator == (int)Operators.Q ||
                boolOperator == (int)Operators.T ||
                boolOperator == (int)Operators.NotP ||
                boolOperator == (int)Operators.NotQ)
         {
             boolOperator = rng.Next(0, 15); // I think those operators are logically worthless here
         }
     }
     else
     {
         boolOperator = _operator;
     }
 }
Esempio n. 3
0
 public Rule(IBooleanResolvable _proposition, int _winCount = 0, int _lossCount = 0, int _drawCount = 0)
 {
     proposition = _proposition;
     winCount    = _winCount;
     lossCount   = _lossCount;
     hit         = false;
 }