return ( - if else , def (self, , )"""return dictionary of { : if ( , )= other probabilities are zero corners are tricky because different actions result in same state ""if in self fling_statesreturn {( , ) (self x_dim- , ): ( ,self y_dim- ): (self x_dim- ,self y_dim- ): res dict(for ai in self actionss self intended_next( ,aips if ai== else if in resoccurs in corners res[ +ps elseres[ ps return res def (self, , )if in self rewarding_statesreturn self rewarding_states[selse( ,ys rew rewards from crashingif == #on bottom rew +- if ='downelse - if ==self y_dim- #on top rew +- if ='upelse - if == #on left rew +- if ='leftelse - if ==self x_dim- #on right rew +- if ='rightelse - return rew value iteration this implements value iteration this uses indexes of the states and actions (not the namesthe value function is represented so [sis the value of state with index function is represented so [ ][ais the value for doing action with index state with index similarly policy is represented as list where pi[ ]where is the index of statereturns the index of the action mdpproblem py -(continued def vi(selfn)version june