First, the agent interacts with the environment by performing an action.
The agent performs an action and moves from one state to another.
Then the agent will receive a reward based on the action it performed.
Based on the reward, the agent will understand whether the action is good or bad.
If the action was good, that is, if the agent received a positive reward, then the agent will prefer performing that action, else the agent will try performing other actions that can result in a positive reward. So reinforcement learning is basically a trial-and-error learning process.