basic functions for reinforcement learning