Implement loading rng seeds for easier debugging
parent
4cfda05982
commit
30261597f1
|
@ -3,4 +3,5 @@ data/
|
|||
test*
|
||||
math_ext.py
|
||||
.idea
|
||||
__pycache__/
|
||||
__pycache__/
|
||||
*.rng
|
16
main.py
16
main.py
|
@ -1,7 +1,9 @@
|
|||
import view
|
||||
import pygame
|
||||
import players
|
||||
|
||||
import random
|
||||
import pickle
|
||||
import sys
|
||||
|
||||
class GameScreen(view.PygView):
|
||||
|
||||
|
@ -53,6 +55,18 @@ class GameScreen(view.PygView):
|
|||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
if sys.argv[1] == "--seed":
|
||||
with open(sys.argv[2], 'rb') as f:
|
||||
# The protocol version used is detected automatically, so we do not
|
||||
# have to specify it.
|
||||
rng_state = pickle.load(f)
|
||||
random.setstate(rng_state)
|
||||
|
||||
rng_state = random.getstate()
|
||||
with open('last_game_rng.rng', 'wb') as f:
|
||||
pickle.dump(rng_state, f)
|
||||
|
||||
main_view = GameScreen(640, 400, clear_colour=(255, 0, 0))
|
||||
|
||||
main_view.run()
|
|
@ -396,7 +396,7 @@ class Player(cards.Deck):
|
|||
"""
|
||||
if game_state == GameState.POINT_CHECK:
|
||||
if self.AI:
|
||||
self.AI.request_reshuffle()
|
||||
return self.AI.request_reshuffle()
|
||||
if input("Low points hand detected! Reshuffle?").lower() == 'y':
|
||||
return self.request_reshuffle()
|
||||
if game_state == GameState.BIDDING:
|
||||
|
|
Loading…
Reference in New Issue