mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Fix for conflict in random number sources when restarting loaded game.
This commit is contained in:
parent
84617c5083
commit
412e3b43a7
1 changed files with 4 additions and 3 deletions
|
@ -1966,8 +1966,8 @@ class Game(object):
|
||||||
def changed(self, restart=False):
|
def changed(self, restart=False):
|
||||||
if self.gstats.updated < 0:
|
if self.gstats.updated < 0:
|
||||||
return 0 # already won or lost
|
return 0 # already won or lost
|
||||||
if self.gstats.loaded > 0:
|
# if self.gstats.loaded > 0:
|
||||||
return 0 # loaded games account for no stats
|
# return 0 # loaded games account for no stats
|
||||||
if not restart:
|
if not restart:
|
||||||
if self.gstats.restarted > 0:
|
if self.gstats.restarted > 0:
|
||||||
return 1 # game was restarted - always ask
|
return 1 # game was restarted - always ask
|
||||||
|
@ -3263,7 +3263,8 @@ class Game(object):
|
||||||
initial_seed = random__int2str(pload(int))
|
initial_seed = random__int2str(pload(int))
|
||||||
game.random = construct_random(initial_seed)
|
game.random = construct_random(initial_seed)
|
||||||
state = pload()
|
state = pload()
|
||||||
if not (isinstance(game.random, random2.Random) and
|
if (game.random is not None and
|
||||||
|
not isinstance(game.random, random2.Random) and
|
||||||
isinstance(state, int)):
|
isinstance(state, int)):
|
||||||
game.random.setstate(state)
|
game.random.setstate(state)
|
||||||
# if not hasattr(game.random, "origin"):
|
# if not hasattr(game.random, "origin"):
|
||||||
|
|
Loading…
Add table
Reference in a new issue