From a166818ea312c83489d9397165bd16aa61fe5438 Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Tue, 6 Oct 2020 19:14:55 -0400 Subject: Info cleanup --- .../java/bjc/dicelang/dicev2/ReduceDieMod.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'dice/src/main/java/bjc/dicelang/dicev2/ReduceDieMod.java') diff --git a/dice/src/main/java/bjc/dicelang/dicev2/ReduceDieMod.java b/dice/src/main/java/bjc/dicelang/dicev2/ReduceDieMod.java index 266e270..070c510 100644 --- a/dice/src/main/java/bjc/dicelang/dicev2/ReduceDieMod.java +++ b/dice/src/main/java/bjc/dicelang/dicev2/ReduceDieMod.java @@ -2,12 +2,35 @@ package bjc.dicelang.dicev2; import java.util.function.LongBinaryOperator; +/** + * Die pool which performs a reduction. + * + * @author Ben Culkin + * + */ public class ReduceDieMod extends Die { + /** + * The die pool. + */ public final Die[] dice; + /** + * The reduction operation. + */ public final LongBinaryOperator fold; + + /** + * The initial value for the reduction. + */ public final long initial; + /** + * Create a new reducing die pool. + * + * @param fold The reduction operation. + * @param initial The initial value for the reduction. + * @param dice The die pool. + */ public ReduceDieMod(LongBinaryOperator fold, long initial, Die... dice) { super(); @@ -17,10 +40,12 @@ public class ReduceDieMod extends Die { this.initial = initial; } + @Override public long[] roll() { return new long[] { rollSingle() }; } + @Override public long rollSingle() { long res = initial; @@ -33,6 +58,7 @@ public class ReduceDieMod extends Die { return res; } + @Override public boolean canOptimize() { for(Die die : dice) { if(!die.canOptimize()) return false; @@ -41,6 +67,7 @@ public class ReduceDieMod extends Die { return true; } + @Override public long optimize() { long res = 0; -- cgit v1.2.3