Implement the every-visit Monte Carlo method for estimating state values from sampled episodes.
Unlike the first-visit variant which only considers the return from the first occurrence of a state within an episode, the every-visit method uses the return from every occurrence of a state. This means if a state appears multiple times in an episode, each visit contributes a separate return estimate for that state.
Given a list of episodes, a number of states, and a discount factor gamma, compute the estimated value for each state by averaging all observed returns across all visits in all episodes.
Each episode is represented as a list of (state, reward) tuples, where the reward at index i is the reward received after leaving the state at index i.
States that are never visited should have a value of 0.0.