コード例 #1
0
ファイル: BasicRule.cs プロジェクト: dsmiller95/plantbuilder
        public BasicRule(
            ParsedRule parsedInfo,
            int branchOpenSymbol,
            int branchCloseSymbol)
        {
            _targetSymbolWithParameters = parsedInfo.coreSymbol;
            ruleGroupIndex = parsedInfo.ruleGroupIndex;

            possibleOutcomes = new RuleOutcome[] {
                new RuleOutcome(1, parsedInfo.replacementSymbols)
            };

            conditionalChecker = parsedInfo.conditionalMatch;


            backwardsMatchBuilder = new SymbolSeriesPrefixBuilder(parsedInfo.backwardsMatch);

            forwardsMatchBuilder = new SymbolSeriesSuffixBuilder(parsedInfo.forwardsMatch);
            forwardsMatchBuilder.BuildGraphIndexes(branchOpenSymbol, branchCloseSymbol);


            CapturedLocalParameterCount = _targetSymbolWithParameters.parameterLength +
                                          backwardsMatchBuilder.targetSymbolSeries.Sum(x => x.parameterLength) +
                                          forwardsMatchBuilder.targetSymbolSeries.Sum(x => x.parameterLength);
        }
コード例 #2
0
ファイル: BasicRule.cs プロジェクト: dsmiller95/plantbuilder
        /// <summary>
        /// Create a new basic rule with multiple random outcomes.
        /// It is garenteed and required that all of the stochastic rules will capture the
        /// same parameters
        /// </summary>
        /// <param name="parsedRules"></param>
        public BasicRule(IEnumerable <ParsedStochasticRule> parsedRules, int branchOpenSymbol, int branchCloseSymbol)
        {
            possibleOutcomes = parsedRules
                               .Select(x =>
                                       new RuleOutcome(x.probability, x.replacementSymbols)
                                       ).ToArray();
            var firstOutcome = parsedRules.First();

            _targetSymbolWithParameters = firstOutcome.coreSymbol;
            ruleGroupIndex = firstOutcome.ruleGroupIndex;

            conditionalChecker = firstOutcome.conditionalMatch;

            backwardsMatchBuilder = new SymbolSeriesPrefixBuilder(firstOutcome.backwardsMatch);

            forwardsMatchBuilder = new SymbolSeriesSuffixBuilder(firstOutcome.forwardsMatch);
            forwardsMatchBuilder.BuildGraphIndexes(branchOpenSymbol, branchCloseSymbol);

            CapturedLocalParameterCount = _targetSymbolWithParameters.parameterLength +
                                          backwardsMatchBuilder.targetSymbolSeries.Sum(x => x.parameterLength) +
                                          forwardsMatchBuilder.targetSymbolSeries.Sum(x => x.parameterLength);
        }