Discovering the Structure of a Reactive Environment by Exploration