Implement shortcut_maze_exploration(grid_rows, grid_cols, walls_phase1, walls_phase2, change_step, start, goal, total_steps, alpha, gamma, epsilon, kappa, n_planning, seed): a tabular Dyna-Q+ agent in a grid maze whose walls change during training.
Environment
0=up, 1=down, 2=left, 3=right; moving into a wall or off the grid leaves the agent in place.walls_phase1 on steps t < change_step and walls_phase2 afterwards (t counts from 0).goal gives reward 1.0 and the next step starts from start; every other transition gives 0.0.Each step t = 0 .. total_steps - 1 (Q defaults to 0), using only rng = np.random.RandomState(seed) in this call order:
rng.random() < epsilon, take rng.randint(4); else list the actions tied for the max Q in index order (tolerance 1e-12) and take best[rng.randint(len(best))].model[(s,a)] = (s', r) and last_visit[(s,a)] = t.n_planning times: pick a stored pair by rng.randint(len(model)) into the keys in insertion order, read its (s', r), and apply the same update with reward (planning does not change last_visit).goal, count an episode and reset to start.Return a dict: 'episodes_completed' (int), 'total_reward' (float), 'cumulative_reward' (list, running total after each step).