Package: irll-crafting
Crafting - An environement builder for hierarchical ML researchBut what is Crafting ?Crafting is NOT an environment, it's an environment builder.Crafting allows to generate arbitrarily hierarchical environments for machine learning research purposes.It uses the classic reinforcement learning framework, the player is in a state and can take actions to update the state.A Crafting environment is a sandbox environment composed of
items, zones, and transformations.The main example of Crafting environment is the MineCrafting environment
that mimics the (complex) hierarchies of the popular game Minecraft.You can use Crafting to create your own customized environments.
For more examples, seeexamples.InstallationUsing pip.Without optional dependencies:pipinstallirll-craftingWith all optional dependencies:pipinstallirll-crafting[all]All crafting environments can use a common graphical user interface.
With gui requirements:pipinstallirll-crafting[gui]Environment can also be obtained throught the gym interface:
With gym requirements:pipinstallirll-crafting[gym]Build from source (for contributions)gitclonehttps://github.com/IRLL/Crafting.gitInstall crafting as an editable packagepipinstall-e.[all]Install dev requirementspipinstall-rrequirements-dev.txtCheck installation by running testspytestQuickstartPlay MineCrafting yourself! (need gui dependencies)Using the command line interface:craftingminecraftSee more options with:crafting--helpUsing the programmatic interface:fromcraftingimportMineCraftingEnv,get_human_actionenv=MineCraftingEnv()# or env: MineCraftingEnv = gym.make("MineCrafting-NoReward-v1")n_episodes=2for_inrange(n_episodes):env.reset()done=Falsetotal_reward=0whilenotdone:env.render()action=get_human_action(env)print(f"Human pressed:{env.world.transformations[action]}")_observation,reward,done,_info=env.step(action)total_reward+=rewardprint(f"SCORE:{total_reward}")Run MineCrafting with autonomous agentsUsing the programmatic interface, any Crafting environment can easily be interfaced with any agent.importnumpyasnpfromcraftingimportMineCraftingEnvdefrandom_legal_agent(observation,action_is_legal):action=np.random.choice(np.nonzero(action_is_legal)[0])returnactionenv=MineCraftingEnv(max_step=10)done=Falseobservation=env.reset()whilenotdone:action_is_legal=env.action_masks()action=random_legal_agent(observation,action_is_legal)_observation,_reward,done,_info=env.step(action)Other crafting environmentsSeecrafting.examples.fromcraftingimportTowerCrafting,RecursiveCrafting,RandomCraftingtower_env=TowerCrafting(height=3,width=2)# or tower_env = gym.make("TowerCrafting-v1", height=3, width=2)recursive_env=RecursiveCrafting(n_items=6)# or recursive_env = gym.make("RecursiveCrafting-v1", n_items=6)random_env=RandomCrafting(n_items_per_n_inputs={0:2,1:5,2:10},seed=42)# or random_env = gym.make("RandomCrafting-v1", n_items_per_n_inputs={0:2, 1:5, 2:10}, seed=42)More about CraftingAdd a Purpose to the playerSeecrafting.purpose.Get a solving behavior for any given taskSeecrafting.solving_behaviors.Details of the environment stateSeecrafting.state.Plot the underlying requirements graphSeecrafting.requirements.Create your own customized Crafting environmentSeecrafting.env.Find everything in thedocumentation: