示例#1
0
        private Proposition GenerateExpressionRecursively(Proposition result, int level)
        {
            if (!(result is UnaryConnective))
            {
                return(result);
            }

            int newLevel = level + 1;

            if (level >= 5)
            {
                newLevel = level + 4;
            }

            if (result is UnaryConnective)
            {
                // Generate a random left
                UnaryConnective connective = (UnaryConnective)result;
                connective.LeftSuccessor = GenerateProposition(level);

                GenerateExpressionRecursively(connective.LeftSuccessor, newLevel);
            }

            if (result is BinaryConnective)
            {
                // Generate a random right
                BinaryConnective connective = (BinaryConnective)result;
                connective.RightSuccessor = GenerateProposition(level);

                GenerateExpressionRecursively(connective.RightSuccessor, newLevel);
            }

            return(result);
        }
示例#2
0
        public override bool Equals(object obj)
        {
            // Means our data is the same or the obj reference
            if (!base.Equals(obj))
            {
                return(false);
            }
            if (GetType() != obj.GetType())
            {
                return(false);
            }

            UnaryConnective unaryConnective = (UnaryConnective)obj;

            return(unaryConnective.LeftSuccessor.Equals(LeftSuccessor));
        }
示例#3
0
        public static UnaryConnective CreateUnaryConnectiveWithRandomSymbol(char unaryConnectiveSymbol)
        {
            UnaryConnective unaryConnective = null;

            switch (unaryConnectiveSymbol)
            {
            case Negation.SYMBOL:
                unaryConnective = new Negation();
                break;

            default:
                throw new ArgumentNullException("Could not convert symbol into a connective!");
            }

            unaryConnective.LeftSuccessor = GetRandomProposition();

            return(unaryConnective);
        }