diff --git a/MARL/env/.gridworld_v3.py b/MARL/env/.gridworld_v3.py new file mode 100644 index 0000000..04cef6b --- /dev/null +++ b/MARL/env/.gridworld_v3.py @@ -0,0 +1,34 @@ +import matplotlib.pyplot as plt +import numpy as np +import warnings +warnings.filterwarnings('ignore') + +SIZE = (14,14) +class CrossRoadGridWorld(): + def __init__(self, size=(14,14)): + super(CrossRoadGridWorld, self).__init__() + self.state = np.zeros(size) + self.size = size + self.init_state = self.get_init_state() + if size[0] <= 4 or size[1] <= 4: + raise ValueError("Size error, the grid size must be larger than 4*4") + self.title = "Cross Road Grid World" + self.length = size[0] + self.width = size[1] + + def reset(self): + self.state = self.get_init_state() + + def get_init_state(self): + #plot the horizon block + init_state = np.zeros((self.size)) + for i in range(self.size[0]): + for j in [self.size[1]//2-1, self.size[1]//2]: + init_state[i,j] = 200 + + #plot the vertical block + for i in [self.size[0]//2-1, self.size[0]//2]: + for j in range(self.size[1]): + init_state[i,j] = 200 + + return init_state