ELSIM: End-to-end learning of reusable skills through intrinsic motivation