Skip to content

Commit e972ae5

Browse files
committed
Move check to prevent starting simulations if all have been completed before printing startSimulation message.
1 parent 34649a3 commit e972ae5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ def simulatePrisoners():
177177
startSim = checkpoint.get("last_simulation") + 1
178178
rng = random.Random(config["CONFIG"].get("seed", None))
179179
rng.setstate(checkpoint.get("rng_state"))
180+
if startSim >= config["CONFIG"]["num_simulations"]:
181+
print("All simulations have already been completed.")
182+
return
180183
print(f"Resuming from simulation {startSim}.")
181184
else:
182185
startSim = 0
@@ -185,9 +188,6 @@ def simulatePrisoners():
185188
checkpoint = {"last_simulation": -1, "rng_state": rng.getstate()}
186189
print("Starting new simulations.")
187190

188-
if startSim >= config["CONFIG"]["num_simulations"]:
189-
print("All simulations have already been completed.")
190-
return
191191

192192
for sim in range(startSim, config["CONFIG"]["num_simulations"]):
193193
prisoners = {i: [0, False] for i in range(config["CONFIG"]["num_prisoners"])}
@@ -216,6 +216,7 @@ def simulatePrisoners():
216216

217217
if __name__ == "__main__":
218218
base_dir = os.path.dirname(os.path.abspath(__file__))
219+
config = None
219220
while True:
220221
print(f"\nChoose an option:")
221222
print(f"1. Create new simulation")

0 commit comments

Comments
 (0)