replace nextRNGInt(999999) with nextRNGInt()

master
melvinzhang 2015-03-10 21:00:36 +08:00
parent b3b5c0cd72
commit 32b1518b51
6 changed files with 10 additions and 15 deletions

View File

@ -129,7 +129,7 @@ public class DeckStrCal {
// Set the random seed
if (seed != 0) {
MagicRandom.setRNGState(seed);
seed = MagicRandom.nextRNGInt(Integer.MAX_VALUE) + 1;
seed = MagicRandom.nextRNGInt() + 1;
}
// Set number of games.

View File

@ -125,7 +125,7 @@ public class FiremindQueueWorker {
// Set the random seed
if (seed != 0) {
MagicRandom.setRNGState(seed);
seed = MagicRandom.nextRNGInt(Integer.MAX_VALUE) + 1;
seed = MagicRandom.nextRNGInt() + 1;
}
// Set number of games.

View File

@ -506,7 +506,7 @@ public class MagicGame {
public void showRandomizedHiddenCards() {
getOpponent(scorePlayer).showRandomizedHandAndLibrary();
scorePlayer.getLibrary().shuffle(MagicRandom.nextRNGInt(999999));
scorePlayer.getLibrary().shuffle(MagicRandom.nextRNGInt());
scorePlayer.getLibrary().setAIKnown(true);
}

View File

@ -371,7 +371,7 @@ public class MagicPlayer extends MagicObjectImpl implements MagicTarget, MagicMa
}
// shuffle library
library.shuffle(MagicRandom.nextRNGInt(999999));
library.shuffle(MagicRandom.nextRNGInt());
library.setAIKnown(true);
// put cards into hand
@ -389,16 +389,7 @@ public class MagicPlayer extends MagicObjectImpl implements MagicTarget, MagicMa
library.add(new MagicCard(cardDefinition,this,id));
}
//library order depends on player index, game no, random seed
final long seed = magic.model.MurmurHash3.hash(new long[] {
2 * index - 1,
MagicGame.getCount(),
(System.getProperty("rndSeed") != null) ?
Long.parseLong(System.getProperty("rndSeed")) :
System.currentTimeMillis()
});
library.initialShuffle(seed);
library.initialShuffle(MagicRandom.nextRNGInt());
for (int count = handSize; count > 0 && !library.isEmpty(); count--) {
addCardToHand(library.removeCardAtTop());

View File

@ -53,4 +53,8 @@ public class MagicRandom extends Random {
public static int nextRNGInt(final int n) {
return RNG.nextInt(n);
}
public static int nextRNGInt() {
return RNG.nextInt(Integer.MAX_VALUE);
}
}

View File

@ -50,7 +50,7 @@ public class SampleHandScreen
for (MagicCardDefinition magicCardDef : deck) {
library.add(new MagicCard(magicCardDef, null, 0));
}
library.shuffle(MagicRandom.nextRNGInt(999999));
library.shuffle(MagicRandom.nextRNGInt());
if (library.size() >= 7) {
final List<MagicCard> hand = library.subList(0, 7);
Collections.sort(hand);