예제 #1
0
        public static LSystemStepper FloatSystem(
            IEnumerable <string> rules,
            string[] globalParameters = null,
            string includedCharacters = "[]ABCDEFD",
            int branchOpenSymbol      = '[',
            int branchCloseSymbol     = ']')
        {
            var compiledRules = RuleParser.CompileRules(
                rules,
                out var nativeRuleData,
                branchOpenSymbol, branchCloseSymbol,
                globalParameters
                );

            var customSymbols = new CustomRuleSymbols
            {
                branchOpenSymbol  = branchOpenSymbol,
                branchCloseSymbol = branchCloseSymbol
            };

            return(new LSystemStepper(
                       compiledRules,
                       nativeRuleData,
                       customSymbols,
                       globalParameters?.Length ?? 0,
                       includedContextualCharactersByRuleIndex: new[] { new HashSet <int>(includedCharacters.Select(x => (int)x)) }
                       ));
        }
예제 #2
0
 public void RuleCompilationFailsWhenSuffixContextsMatchSemanticallyButNotLiterally()
 {
     Assert.Throws <LSystemRuntimeException>(() =>
     {
         var compiledRules = RuleParser.CompileRules(new string[] {
             "A > B[C]D -> AB",
             "A > B[C][D] -> CA",
         }, out var nativeData, '[', ']');
     });
 }
예제 #3
0
 public void RuleCompilationFailsWhenContextMatchesOfDifferentTypesTryToShareProbability()
 {
     Assert.Throws <LSystemRuntimeException>(() =>
     {
         var compiledRules = RuleParser.CompileRules(new string[] {
             "P(0.5) | A > B -> AB",
             "P(0.5) | A > BC -> CA",
         }, out var nativeData, '[', ']');
     });
 }
예제 #4
0
 public void RuleCompilationFailsWhenContextMatchesOfDifferentTypesMatchSamePattern()
 {
     Assert.Throws <LSystemRuntimeException>(() =>
     {
         var compiledRules = RuleParser.CompileRules(new string[] {
             "C < A > B[C][D] -> AB",
             "C < A > B[C][D] -> CA",
         }, out var nativeData, '[', ']');
     });
 }
예제 #5
0
 public void RuleCompilationFailsWhenConflictingRules()
 {
     Assert.Throws <LSystemRuntimeException>(() =>
     {
         var compiledRules = RuleParser.CompileRules(new string[] {
             "A -> AB",
             "A -> CA",
         }, out var nativeData, '[', ']');
     });
 }