Rust bindings for the entity-gym library
Project description
EntityGym for Rust
EntityGym is a Python library that defines a novel entity-based abstraction for reinforcement learning environments which enables highly ergonomic and efficient training of deep reinforcement learning agents. This crate provides bindings that allows Rust programs to be used as EntityGym training environments, and to load and run neural networks agents trained with Entity Neural Network Trainer natively in pure Rust applications.
Overview
The core abstraction in entity-gym-rs is the Agent trait.
It defines a high-level API for neural network agents which allows them to directly interact with Rust data structures.
To use any of the Agent implementations provided by entity-gym-rs, you just need to derive the Action and Featurizable traits, which define what information the agent can observe and what actions it can take:
- The
Actiontrait allows a Rust type to be returned as an action by anAgent. This trait can be derived automatically for enums with only unit variants. - The
Featurizabletrait converts objects into a format that can be processed by neural networks. It can be derived for most fixed-sizestructs, and forenums with unit variants.Agents can observe collections containing any number ofFeaturizableobjects.
Example
Basic example that demonstrates how to construct an observation and sample a random action from an Agent:
use entity_gym_rs::agent::{Agent, AgentOps, Obs, Action, Featurizable};
#[derive(Action, Debug)]
enum Move { Up, Down, Left, Right }
#[derive(Featurizable)]
struct Player { x: i32, y: i32 }
#[derive(Featurizable)]
struct Cake {
x: i32,
y: i32,
size: u32,
}
fn main() {
// Creates an agent that acts completely randomly.
let mut agent = Agent::random();
// Alternatively, load a trained neural network agent from a checkpoint.
// let mut agent = Agent::load("agent");
// Construct an observation with one `Player` entity and two `Cake entities.
let obs = Obs::new(0.0)
.entities([Player { x: 0, y: 0 }])
.entities([
Cake { x: 4, y: 0, size: 4 },
Cake { x: 10, y: 42, size: 12 },
]);
// To obtain an action from an agent, we simple call the `act` method
// with the observation we constructed.
let action = agent.act::<Move>(obs);
println!("{:?}", action);
}
For a more complete example that includes training a neural network to play Snake, see examples/bevy_snake.
Docs
- bevy_snake: Example of how to use entity-gym-rs in a Bevy game.
- bevy-snake-ai: More complex Bevy application with adversarial training of multiple agents to create AI opponents.
- EntityGym Rust API Docs: Rust API reference.
- If you have any questions, you can also get help on our discord server
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file entity_gym_rs-0.7.0.tar.gz.
File metadata
- Download URL: entity_gym_rs-0.7.0.tar.gz
- Upload date:
- Size: 28.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08e3b5f4362cee55ae0b2e06264acad5fca90d694fba4cac25e72f60e34f9586
|
|
| MD5 |
c51757f36c451fcef2317ad15bd3cdee
|
|
| BLAKE2b-256 |
99d1bec6f06073ee9a295ea78428c1b0c14b1738feb701154916ab9dd6f68dc8
|
File details
Details for the file entity_gym_rs-0.7.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 448.5 kB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b92882c3a885390881a8e2dc650b8a0c380e8b819f6ca77e9e938bfefce730c
|
|
| MD5 |
95286c6bce416f5f5962f55f83c42ad8
|
|
| BLAKE2b-256 |
618dc1145ebe5243e4ae6a58c702a5fcbecba029e6bc5acab9b35d6dd9a8d274
|
File details
Details for the file entity_gym_rs-0.7.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 445.9 kB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d11a2cfa842e883931355854f422ca50f17d845daed9cf7cd5ba03d7429bf41e
|
|
| MD5 |
bf51af27831c62c0fde419e9831f4139
|
|
| BLAKE2b-256 |
017c48279dc113520b3f11ae76b58344fa41de71aae8ff60cddeca13dd00b2e6
|
File details
Details for the file entity_gym_rs-0.7.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 452.1 kB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5aa402e9bfb1cbc0feb63bec7eac7fc5bdf4479761e20db20e94b9cfa4ca2e09
|
|
| MD5 |
c9fd028011b76b209cc111adb1cb2180
|
|
| BLAKE2b-256 |
692602750b83f550f6d2f239acc4843d4f4c3a79d3973a39bbd5ba7d3d54aba6
|
File details
Details for the file entity_gym_rs-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 448.4 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba89d30c19ff3d40b880302b6e9d8d9ed71b82ff2ca8dd4a2dffa03bd7c918ab
|
|
| MD5 |
e87db1096d1c6b5c32fe20c3ff8360ce
|
|
| BLAKE2b-256 |
b191d4d56906411eb3bda2c5ab67222136d7ce12014863f8413e7b2ad7a8652f
|
File details
Details for the file entity_gym_rs-0.7.0-cp310-none-win_amd64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-cp310-none-win_amd64.whl
- Upload date:
- Size: 373.0 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64d7486288e7ce3a67b3d85af8da270ab31999ed4b4034401fb3da1bb1aca2fe
|
|
| MD5 |
75eb96eab2690e8bad4c5a06a70006c8
|
|
| BLAKE2b-256 |
e06d81aff17241c023cf5e6b13023c3e48a8f07f896156108eeae5a68ee8549a
|
File details
Details for the file entity_gym_rs-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 448.4 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9017c08801de9f9a8461a1680154d37e2f6a024465e6e5b0bf538c145d6d55a5
|
|
| MD5 |
d14e9d44d78e50bc1484cf3abc9c47c5
|
|
| BLAKE2b-256 |
6b6e71e0e0bb8adb5bfdb19c0a15c6a6ab771dec4f30e65416fd7a454100d4b6
|
File details
Details for the file entity_gym_rs-0.7.0-cp310-cp310-macosx_10_7_x86_64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-cp310-cp310-macosx_10_7_x86_64.whl
- Upload date:
- Size: 409.6 kB
- Tags: CPython 3.10, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96bfd0a1bbe7925d835f0a2a2c1214dff95f74cef9e1b37f7601249599b0915d
|
|
| MD5 |
2f3e97f281a2dfb30622af1cf546675d
|
|
| BLAKE2b-256 |
5f40be31ccff5942e208ddf5047d89d7698ddb2b1d75bd949fb07731625037c7
|
File details
Details for the file entity_gym_rs-0.7.0-cp39-none-win_amd64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-cp39-none-win_amd64.whl
- Upload date:
- Size: 372.9 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91a4e493a33d739a371dc5bed500613a5ac03d6e754974702c19ae2c8de6f413
|
|
| MD5 |
f26da48c76f513a5dc26482655f84575
|
|
| BLAKE2b-256 |
d242c22f6691366cbb349bc3329480f730858fad35d9b3f3398ddead02d39f4a
|
File details
Details for the file entity_gym_rs-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 448.8 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
784af06f6ecc08813f2511bbbfa8b45eb24c161f9ccc6ff003abaf7663932d5a
|
|
| MD5 |
744c0d061b4291ba4037964d9859a32e
|
|
| BLAKE2b-256 |
7d048c79997ce5a81da40e6a413fb028dea85307fb31503828a6cb1dd12a5f79
|
File details
Details for the file entity_gym_rs-0.7.0-cp39-cp39-macosx_10_7_x86_64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-cp39-cp39-macosx_10_7_x86_64.whl
- Upload date:
- Size: 409.5 kB
- Tags: CPython 3.9, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92614fe35ffa088d97a58699bc35f3e3a56e2a4df8a8d56c280925ced1ba00df
|
|
| MD5 |
ed989807a0ee05df35655ac9b683c555
|
|
| BLAKE2b-256 |
434c2add76c869544acc6b0bb712a066960a2535932011eb067c691fb9fd8c18
|
File details
Details for the file entity_gym_rs-0.7.0-cp38-none-win_amd64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-cp38-none-win_amd64.whl
- Upload date:
- Size: 372.5 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03d897a9d6308a7861ae7b003928b6976ee0bfd1d843e5266aa322a9bd7c121a
|
|
| MD5 |
b8fc11c101ed8dfb5dd6015deae33f63
|
|
| BLAKE2b-256 |
42937d1aaf5d30cdb1516153cbe224f5e6d8a09d21a47850316fc06cc7e9306d
|
File details
Details for the file entity_gym_rs-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 448.3 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92b0b088ae121cb09082e28dbbe21448e05494a2593fcee29ac9d868f70d86a4
|
|
| MD5 |
752f4b996c635f11b2576365c0fc3f6c
|
|
| BLAKE2b-256 |
e05fb36a9da2e9b0e8fde3d009f49e7602ec8bc726be032f7369e48c3e8f143e
|
File details
Details for the file entity_gym_rs-0.7.0-cp38-cp38-macosx_10_7_x86_64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-cp38-cp38-macosx_10_7_x86_64.whl
- Upload date:
- Size: 409.5 kB
- Tags: CPython 3.8, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6c7b31bb3617dddfebb76df2579d866380154f9c2158842d5278c76fba92b5c
|
|
| MD5 |
f018b42e1f399bf256e957132ed22d35
|
|
| BLAKE2b-256 |
609c9cdbcc68abe8501cbcbb9a614a1986d39e8c8c31da8a93b5e6d43aca72f9
|
File details
Details for the file entity_gym_rs-0.7.0-cp37-none-win_amd64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-cp37-none-win_amd64.whl
- Upload date:
- Size: 372.6 kB
- Tags: CPython 3.7, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3ffd9f7743ce71295b28a21460914507ca7db5c1df957ec943f79dd84a65550
|
|
| MD5 |
acf1327226e2263a98a7a4661aaca202
|
|
| BLAKE2b-256 |
ac5de0a600d06b8e7d7e54c27421307f18375de3c83d2c3492baebb6c751417d
|
File details
Details for the file entity_gym_rs-0.7.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 448.6 kB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0403e28e5e4ada359ac8d21812d584b502f9558882921b54f1c94e49e3753841
|
|
| MD5 |
f2eff064af50eb2af6512a5f0c5ad8cd
|
|
| BLAKE2b-256 |
819a1bc5c8998fbbf3d4c47d47d761810df2cb381fae1831b35c4c11fc4a4857
|
File details
Details for the file entity_gym_rs-0.7.0-cp37-cp37m-macosx_10_7_x86_64.whl.
File metadata
- Download URL: entity_gym_rs-0.7.0-cp37-cp37m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 409.3 kB
- Tags: CPython 3.7m, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb9ed43109c341ee734472906e65b6f47abffb279d241082e9961302b6d7e940
|
|
| MD5 |
1acd15e03acdee68d91438622af3b06e
|
|
| BLAKE2b-256 |
5117b9d4144aad19c38474d9ed00258ed24ae199885441a7a142618a5bd4f539
|