-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu_component.py
74 lines (64 loc) · 2.18 KB
/
menu_component.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from tabulate import tabulate
from grid_component import GridComponent
import time
class MenuComponent:
def __init__(self, grid):
self.grid = grid
def display_main_menu_selection(self):
"""
Displays main menu for grid world. Returns user input from main menu selection.
Parameters:
Returns:
inp: (Integer): Integer of user input from main menu selection
"""
print()
print()
print("----------MARKOV DECISION PROBLEM ON GRID WORLD----------")
print()
print()
print("-----------CURRENT GRID WORLD----------")
print()
print("Parameters:")
print()
print("Rows = ", self.grid.parameters.row)
print("Columns = ", self.grid.parameters.col)
print("Reward = ", self.grid.parameters.reward)
print("Lambda = ", self.grid.parameters.lamb)
print("cw_0 probability = ", self.grid.parameters.cw_0)
print("cw_90 probability = ", self.grid.parameters.cw_90)
print("cw_180 probability = ", self.grid.parameters.cw_180)
print("cw_270 probability = ", self.grid.parameters.cw_270)
print("Walls = ", self.grid.parameters.walls)
print("End States = ", self.grid.parameters.end_states)
print()
print("Grid World Utility:")
print()
table = tabulate(self.grid.utility, tablefmt="fancy_grid")
print(table)
print()
print("Grid World Policy:")
print()
table = tabulate(self.grid.policy, tablefmt="fancy_grid")
print(table)
print()
print("Current Iteration: ", self.grid.iteration)
print()
print("----------MAIN MENU----------")
print()
print("Select one of the following options:")
print()
print("1. Compute Optimal MDP policy.")
print("2. Reset grid world.")
print("3. Quit.")
print()
print("> ", end="")
inp = input()
return inp
def display_calculate_sub_emnu(self):
print()
print()
print("For how many iterations?")
print()
print("> ", end="")
inp = input()
return inp