class_docstr: 1-dimensional grid-world implementation with 3 possible movement actions ("LEFT", "STAY", "RIGHT")
code: def _build(self):
      P = {}
      grid = np.arange(self.n_states).reshape(self.shape)
      it = np.nditer(grid, flags=["multi_index"])
  
      while not it.finished:
          s = it.iterindex
          y, x = it.multi_index
          P[s] = {a: [] for a in range(self.n_control)}
  
          next_right = s if x == (self.max_x - 1) else s + 1
          next_left = s if x == 0 else s - 1
          next_stay = s
  
          P[s][self.LEFT] = next_left
          P[s][self.STAY] = next_stay
          P[s][self.RIGHT] = next_right
  
          it.iternext()
  
      self.P = P
  
imports: import numpy
  import matplotlib.pyplot
  import seaborn
  from pymdp.envs import Env
label_desc: Use image node_id 7 for calling the DGridWorldEnv obj's underlying member method code with example usage: obj._build() without return types