Crafting - An environement builder for hierarchical ML research
But 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, see examples.
Installation
Using pip.
Without optional dependencies:
pip install irll-crafting
With all optional dependencies:
pip install irll-crafting[all]
All crafting environments can use a common graphical user interface. With gui requirements:
pip install irll-crafting[gui]
Environment can also be obtained throught the gym interface: With gym requirements:
pip install irll-crafting[gym]
Build from source (for contributions)
git clone https://github.com/IRLL/Crafting.git
Install crafting as an editable package
pip install -e .[all]
Install dev requirements
pip install -r requirements-dev.txt
Check installation by running tests
pytest
Quickstart
Play MineCrafting yourself! (need gui dependencies)
Using the command line interface:
crafting minecraft
See more options with:
crafting --help
Using the programmatic interface:
from crafting import MineCraftingEnv, get_human_action
env = MineCraftingEnv()
# or env: MineCraftingEnv = gym.make("MineCrafting-NoReward-v1")
n_episodes = 2
for _ in range(n_episodes):
env.reset()
done = False
total_reward = 0
while not done:
env.render()
action = get_human_action(env)
print(f"Human pressed: {env.world.transformations[action]}")
_observation, reward, done, _info = env.step(action)
total_reward += reward
print(f"SCORE: {total_reward}")
Run MineCrafting with autonomous agents
Using the programmatic interface, any Crafting environment can easily be interfaced with any agent.
import numpy as np
from crafting import MineCraftingEnv
def random_legal_agent(observation, action_is_legal):
action = np.random.choice(np.nonzero(action_is_legal)[0])
return action
env = MineCraftingEnv(max_step=10)
done = False
observation = env.reset()
while not done:
action_is_legal = env.action_masks()
action = random_legal_agent(observation, action_is_legal)
_observation, _reward, done, _info = env.step(action)
Other crafting environments
See crafting.examples.
from crafting import TowerCrafting, RecursiveCrafting, RandomCrafting
tower_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 Crafting
Add a Purpose to the player
See crafting.purpose.
Get a solving behavior for any given task
See crafting.solving_behaviors.
Details of the environment state
See crafting.state.
Plot the underlying requirements graph
Create your own customized Crafting environment
See crafting.env.
Find everything in the documentation:
Metadata
Release files for irll-crafting 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| irll-crafting-1.0.7.tar.gz | 7.4 MB | Without provenance | Details for irll-crafting-1.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| irll_crafting-1.0.7-py3-none-any.whl | Python 3 | none | any | Details for irll_crafting-1.0.7-py3-none-any.whl |
Total release size: 11.2 MB
Release files / irll-crafting-1.0.7.tar.gz
| Download URL | irll-crafting-1.0.7.tar.gz |
|---|---|
| Size | 7.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e597f306bf00f158be07c3371426f64c82c4e2d29640723d46bd4ca545c94fa4
|
|
BLAKE2b-256 checksum How to use checksums |
b3c556d42d116d4e7ae521dae40a0379cac3d9c5b53a83ec52742568fa88fad9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / irll_crafting-1.0.7-py3-none-any.whl
| Download URL | irll_crafting-1.0.7-py3-none-any.whl |
|---|---|
| Size | 3.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
07b80c61855e0c866b09b7385df92db12b256b70af019c44428c373eda71b7de
|
|
BLAKE2b-256 checksum How to use checksums |
cf053938d6bf78b0737094d379da943c790baba1aca68ba27d514cd202760e70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for irll-crafting 1.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.