Dynamic allocation of limited memory resources in reinforcement learning