I have build environment in Tkinter, how to create observation space using this environment. I could not understand how to use grid coordinates in array to make observation space, self.observation_space = spaces.Box(np.array([]), np.array([]), dtype=np.int), code is given. I will be thankful if anyone help.
enter code here
# Setting the sizes for the environment
pixels = 40 # pixels
env_height =9 # grid height
env_width = 9 # grid width
# Global variable for dictionary with coordinates for the final route
a = {}
# Creating class for the environment
class Environment(tk.Tk, object):
def __init__(self):
super(Environment, self).__init__()
self.action_space = ['up', 'down', 'left', 'right']
self.n_actions = len(self.action_space)
self.title('RL Q-learning. Sichkar Valentyn')
self.geometry('{0}x{1}'.format(env_height * pixels, env_height * pixels))
self.build_environment()
print(self.geometry('{0}x{1}'.format(env_height * pixels, env_height * pixels)))
# Dictionaries to draw the final route
self.d = {}
self.f = {}
# Key for the dictionaries
self.i = 0
# Writing the final dictionary first time
self.c = True
# Showing the steps for longest found route
self.longest = 0
# Showing the steps for the shortest route
self.shortest = 0
# Function to build the environment
def build_environment(self):
self.canvas_widget = tk.Canvas(self, bg='black',
height=env_height * pixels,
width=env_width * pixels)
# Uploading an image for background
# img_background = Image.open("images/bg.png")
# self.background = ImageTk.PhotoImage(img_background)
# # Creating background on the widget
# self.bg = self.canvas_widget.create_image(0, 0, anchor='nw', image=self.background)
# Creating grid lines
for column in range(0, env_width * pixels, pixels):
x0, y0, x1, y1 = column, 0, column, env_height * pixels
self.canvas_widget.create_line(x0, y0, x1, y1, fill='grey')
for row in range(0, env_height * pixels, pixels):
x0, y0, x1, y1 = 0, row, env_height * pixels, row
self.canvas_widget.create_line(x0, y0, x1, y1, fill='grey')
self.canvas_widget.pack()
if __name__ == '__main__':
env = Environment()