Implement a function extract_optimal_policy that extracts the optimal policy, state-value function, and advantage function from a given Q-value table.
In reinforcement learning, an agent learns a Q-value function Q(s, a) that estimates the expected cumulative reward of taking action a in state s and then following the optimal policy. Once Q-values are known, we can derive several useful quantities:
Given a Q-value table as a 2D numpy array of shape (num_states, num_actions), return a dictionary containing:
'optimal_actions': a list of integers, one per state, indicating the optimal action index'state_values': a list of floats (rounded to 4 decimal places), one per state, giving V*(s)'advantages': a nested list of floats (rounded to 4 decimal places) with the same shape as Q, giving A(s, a) for all state-action pairs