# Policy function π in Reinforcement learning unclear

I have one question about policy function in Reinforcement learning.

in fact this function indicates which action should be done in each state? Or

this function indicate for get the specific reward in each state, which action shoud be selected?

or something else?

A policy $\pi$ maps each state to an action. Generalizations of this allow for a stochastic mapping (each state to an action with given probability). Given a policy you can estimate or compute the expected reward (or cost) at any state. An optimal policy is simply one that produces the most reward overall.