-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (30 loc) · 929 Bytes
/
Copy pathmain.py
File metadata and controls
40 lines (30 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sys
from simulation import Simulation
from utils.menu import show_main_menu
from world import Map
def main() -> None:
while True:
choice = show_main_menu()
if choice in ("1", "2"):
run_simulation(choice)
elif choice == "0":
print("Exit.")
break
else:
print("Invalid choice. Please try again.")
def run_simulation(choice: str) -> None:
"""Runs simulation in the selected mode."""
mode = "auto" if choice == "1" else "step"
world_map = Map()
sim = Simulation(world_map)
sim.start_simulation(mode=mode)
print("Return to main menu.")
def handle_keyboard_interrupt() -> None:
"""Handles keyboard interrupt."""
print("\nGame interrupted by user. Goodbye!")
sys.exit(0)
if __name__ == "__main__":
try:
main()
except (KeyboardInterrupt, EOFError):
handle_keyboard_interrupt()