Revision: 9235
http://sourceforge.net/p/vassalengine/svn/9235
Author: uckelman
Date: 2016-10-22 23:02:07 +0000 (Sat, 22 Oct 2016)
Log Message:
-----------
Additional fix for Bug 11404: Missed two uses of Random.nextFloat()
which cause modulo bias.
Modified Paths:
--------------
VASSAL-src/trunk/src/VASSAL/build/module/RandomTextButton.java
VASSAL-src/trunk/src/VASSAL/build/module/dice/DieServer.java
Modified: VASSAL-src/trunk/src/VASSAL/build/module/RandomTextButton.java
===================================================================
--- VASSAL-src/trunk/src/VASSAL/build/module/RandomTextButton.java 2016-10-08 02:25:09 UTC (rev 9234)
+++ VASSAL-src/trunk/src/VASSAL/build/module/RandomTextButton.java 2016-10-22 23:02:07 UTC (rev 9235)
@@ -108,7 +108,7 @@
final StringBuilder result = new StringBuilder();
int total = addToTotal;
for (int i = 0; i < nDice; ++i) {
- int roll = (int) (ran.nextFloat() * nSides + 1);
+ int roll = ran.nextInt(nSides) + 1;
// take the face value from user defined faces
if (isNumeric) {
Modified: VASSAL-src/trunk/src/VASSAL/build/module/dice/DieServer.java
===================================================================
--- VASSAL-src/trunk/src/VASSAL/build/module/dice/DieServer.java 2016-10-08 02:25:09 UTC (rev 9234)
+++ VASSAL-src/trunk/src/VASSAL/build/module/dice/DieServer.java 2016-10-22 23:02:07 UTC (rev 9235)
@@ -164,7 +164,7 @@
String val = getReportPrefix(desc);
int total = 0;
for (int j = 0; j < nDice; ++j) {
- int result = (int) (ran.nextFloat() * nSides + 1) + plus;
+ final int result = ran.nextInt(nSides) + 1 + plus;
if (reportTotal) {
total += result;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
vassalengine-svn mailing list
vas...@li...
https://lists.sourceforge.net/lists/listinfo/vassalengine-svn
|