
666 Глава 19
self.state2grid_dict = {s: (s // num_cols, s % num_cols)
for s in range(nS)}
# Состояние: кл ад
gold_cell = (num_rows // 2, num_cols - 2)
# Состояние: ло вушки
trap_cells = [((gold_cell[0] + 1), gold_cell[1]),
(gold_cell[0], gold_cell[1] - 1),
((gold_cell[0] - 1), gold_cell[1])]
gold_state = self.grid2state_dict[gold_cell]
trap_states = [self.grid2state_dict[(r, c)]
for (r, c) in trap_cells]
self.terminal_states = [gold_state] + trap_states
print(self.terminal_states)
# Построение ве роятности перех ода
P = defaultdict(dict)
for s in range(nS):
row, col = self.state2grid_dict[s]
P[s] = defaultdict(list) ...