diff options
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/gen')
3 files changed, 11 insertions, 16 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gen/RandomGrammar.java b/BJC-Utils2/src/main/java/bjc/utils/gen/RandomGrammar.java index a764a08..7ed476e 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gen/RandomGrammar.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gen/RandomGrammar.java @@ -59,8 +59,7 @@ public class RandomGrammar<E> extends WeightedGrammar<E> { * @param cases * The cases to add for this rule. */ - public void makeRule(E rule, - IList<IList<E>> cases) { + public void makeRule(E rule, IList<IList<E>> cases) { if (cases == null) { throw new NullPointerException("Cases must not be null"); } diff --git a/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java b/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java index 78db7d8..fe10741 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java @@ -23,7 +23,7 @@ public class WeightedGrammar<E> { /** * The initial rule of the grammar */ - protected String initialRule; + protected String initialRule; /** * The rules currently in this grammar @@ -33,12 +33,12 @@ public class WeightedGrammar<E> { /** * The random number generator used for random numbers */ - private Random rng; + private Random rng; /** * All of the subgrammars of this grammar */ - protected IMap<E, WeightedGrammar<E>> subgrammars; + protected IMap<E, WeightedGrammar<E>> subgrammars; /** * Create a new weighted grammar. @@ -76,8 +76,7 @@ public class WeightedGrammar<E> { * @param cse * The case being added. */ - public void addCase(E ruleName, int probability, - IList<E> cse) { + public void addCase(E ruleName, int probability, IList<E> cse) { if (ruleName == null) { throw new NullPointerException("Rule name must be not null"); } else if (cse == null) { @@ -145,8 +144,7 @@ public class WeightedGrammar<E> { * The set of cases for the rule. * @return Whether or not the rule was succesfully added. */ - public boolean addRule(E name, - WeightedRandom<IList<E>> cases) { + public boolean addRule(E name, WeightedRandom<IList<E>> cases) { if (name == null) { throw new NullPointerException("Name must not be null"); } else if (cases == null) { @@ -222,16 +220,14 @@ public class WeightedGrammar<E> { * The rule to test. * @return A set of sentances generated by the specified rule. */ - public IList<IList<E>> generateDebugValues( - E ruleName) { + public IList<IList<E>> generateDebugValues(E ruleName) { if (ruleName == null) { throw new NullPointerException("Rule name must not be null"); } IList<IList<E>> returnedList = new FunctionalList<>(); - WeightedRandom<IList<E>> ruleGenerator = rules - .get(ruleName); + WeightedRandom<IList<E>> ruleGenerator = rules.get(ruleName); for (int i = 0; i < 10; i++) { returnedList.add(ruleGenerator.generateValue()); diff --git a/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedRandom.java b/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedRandom.java index 7c6af23..e345424 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedRandom.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedRandom.java @@ -26,14 +26,14 @@ public class WeightedRandom<E> { /** * The list of possible results to pick from */ - private IList<E> results; + private IList<E> results; /** * The source for any needed random numbers */ - private Random source; + private Random source; - private int totalChance; + private int totalChance; /** * Create a new weighted random generator with the specified source of |
