Planning and Learning by Analogical Reasoning