Agents in dynamic contexts, a system for learning plans