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
Action
trait 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
Featurizable
trait converts objects into a format that can be processed by neural networks. It can be derived for most fixed-sizestruct
s, and forenum
s with unit variants.Agent
s can observe collections containing any number ofFeaturizable
objects.
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
File details
Details for the file entity_gym_rs-0.8.0.tar.gz
.
File metadata
- Download URL: entity_gym_rs-0.8.0.tar.gz
- Upload date:
- Size: 52.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5d6d95c286e078ac34427886b7c79926e75907c586444d3b0063c361d10667f |
|
MD5 | cd8a907417b4c7918645cd1c6b614536 |
|
BLAKE2b-256 | f0fe6cf356a563a4f58eac180e92d2e43a0795d552f84c0170951e9670ace78a |
File details
Details for the file entity_gym_rs-0.8.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 448.0 kB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e6e9d31fdafda135dee05677346aa7dfd882c310e4f4240f575adeff4cf0aa4 |
|
MD5 | d9843e11073d94d0271cb245102bb1e0 |
|
BLAKE2b-256 | e5b8e38e310f2eb9263ef42a2266a54a237b4144b7c77d001cfa77079a238835 |
File details
Details for the file entity_gym_rs-0.8.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 448.3 kB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9d2b8db3b526db28fc540e0ab107b4a9bd667c07ff6af7cc158dd826aa9cb3a |
|
MD5 | 098f460742a2ea0dfada2d171718ec16 |
|
BLAKE2b-256 | fc0b7979d0ee5b6907ae8ade5b0fd239527820818b9c1a2bfd91b2b88d1ecf5e |
File details
Details for the file entity_gym_rs-0.8.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 452.2 kB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43e35e71611b79ad7ed049cb4be0af7334bcb1d644e7220b7decdbd335d36bfa |
|
MD5 | 71ffcbcd80353593e91dac0ff2732a79 |
|
BLAKE2b-256 | 619e262dd1722d67810efffeb4bdc2fc91c801a305507a13800cfeb8468d9787 |
File details
Details for the file entity_gym_rs-0.8.0-cp311-none-win_amd64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp311-none-win_amd64.whl
- Upload date:
- Size: 366.9 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a217322199ca13cf666e5b2d8b364eeda73cfe7e0b0129827afa957a5645fc0 |
|
MD5 | 439e037a18b3d0d934c1202a9f128f8d |
|
BLAKE2b-256 | 2bef3db210ba309d9edfd87a41e2a5b5f2aa3cff65355131f324c909c72719e5 |
File details
Details for the file entity_gym_rs-0.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 445.3 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1d9c01788f5aacd2619ac0991e0ce0767b8915d842901e695cf808ccd1aff18 |
|
MD5 | 2c253c909dd36448fc2147ff3b00af3b |
|
BLAKE2b-256 | 50efece34666cdf4873690ab167c2f9da2e0ca1e6b89f9de947f8e48eda10bbc |
File details
Details for the file entity_gym_rs-0.8.0-cp311-cp311-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp311-cp311-macosx_10_7_x86_64.whl
- Upload date:
- Size: 407.0 kB
- Tags: CPython 3.11, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 156ab58cd68702a169706e988fcd109ec1f6a65e82b5e010d03b29b267cdf87c |
|
MD5 | 7cb7d668b07762f1cf2df0053d02101c |
|
BLAKE2b-256 | 5987c32f66d5241e1db43b39a58180fefd4eac70421179f2de5ae13dc495b7a0 |
File details
Details for the file entity_gym_rs-0.8.0-cp310-none-win_amd64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp310-none-win_amd64.whl
- Upload date:
- Size: 366.9 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99454e3c836d7667be267332b0a6af5bb6029dd2b5687b6558d8915058414893 |
|
MD5 | 9f2171f836c8638d81015e8b1a358c6c |
|
BLAKE2b-256 | ac4c7f2dc73ca034ee22cd93760913321996dac3709b012e0d00e6f98196a562 |
File details
Details for the file entity_gym_rs-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 445.3 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1ba1d604bdeebef70e26deb482f2c6495a1ff99c9f6acad24f043aaa21ff83d |
|
MD5 | 76d826207cdb5e8cb8179bd4b0b91a49 |
|
BLAKE2b-256 | 6a210cff6b6818c8e78e322f5df1a12ab254f2e59d79ac3da4ed8e70261b2138 |
File details
Details for the file entity_gym_rs-0.8.0-cp310-cp310-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp310-cp310-macosx_10_7_x86_64.whl
- Upload date:
- Size: 407.0 kB
- Tags: CPython 3.10, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07a3e5d5f77d6381c8ad41aa0fe5e04da7a0f296532c59429bef8ab1e5453058 |
|
MD5 | 589319542f33d5b6eee07701931c668e |
|
BLAKE2b-256 | 3763fb7c002c51ee3184373a76dc84e3b7e31c6b1cd3e12ca172b0b863dc7e56 |
File details
Details for the file entity_gym_rs-0.8.0-cp39-none-win_amd64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp39-none-win_amd64.whl
- Upload date:
- Size: 366.9 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3035cb090492560b1a1dc59bf7888c4627b2dd8554865a682651cf01332cf42a |
|
MD5 | cfbd5037ebf88af7aedf88c93f3e9f2b |
|
BLAKE2b-256 | 8e20f514f27062a50bc2687b9f47d9697b5472b37ef99849f88da50e37ef707d |
File details
Details for the file entity_gym_rs-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 445.7 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24a95806e1fb6e314600e09edcf3009b2e56ccf2c8cb2494f1c89144db97528e |
|
MD5 | 097940b9d2162943104190dc19494ba7 |
|
BLAKE2b-256 | 8d6cbcc073ccca6101a961a84b09787c93abc0bc75c2964b7c92104b4c38925b |
File details
Details for the file entity_gym_rs-0.8.0-cp39-cp39-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp39-cp39-macosx_10_7_x86_64.whl
- Upload date:
- Size: 407.0 kB
- Tags: CPython 3.9, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee384eaddf8007fee8f2a23f7600ac52f5624a39cce8970bb4b591b970cfd75e |
|
MD5 | 9e0e85712586d840cdb71adf2e0b5e36 |
|
BLAKE2b-256 | a49aa2816952d22d822de4d409d64f8c244a06bf3cb3162fc02f9a8b4c04a18e |
File details
Details for the file entity_gym_rs-0.8.0-cp38-none-win_amd64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp38-none-win_amd64.whl
- Upload date:
- Size: 366.5 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19f9f53c4ee350a40d326392cdf79a218613a065736f17e063fb9578616ab796 |
|
MD5 | 87475eef8c9869c2811297debe468c8e |
|
BLAKE2b-256 | 5d0fc3f2c511cb4087d032de36d0ce6e7613a1f54e7632eb650e5c6b720878ec |
File details
Details for the file entity_gym_rs-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 445.1 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd6819dca7007295f46c1dc99f5644abb2ba52d204ad81ef34c9ebcebb56138e |
|
MD5 | 5e8d54ab865299693f9193185ab453f3 |
|
BLAKE2b-256 | 90ca52dd31f354367860a0119420239863a541d9738cc142e63acbfb1b16bf7f |
File details
Details for the file entity_gym_rs-0.8.0-cp38-cp38-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp38-cp38-macosx_10_7_x86_64.whl
- Upload date:
- Size: 407.2 kB
- Tags: CPython 3.8, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f325cf64169ea85e3b3b3e2666526ee22078dd4f40da6967ca398ecfd81765f |
|
MD5 | 5e291254de476d58a720306bf634ccd7 |
|
BLAKE2b-256 | 8ddf78c9621e2d5c3ab14dde923bdd7d3e67ec60c90708670999c242588ed91e |
File details
Details for the file entity_gym_rs-0.8.0-cp37-none-win_amd64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp37-none-win_amd64.whl
- Upload date:
- Size: 366.4 kB
- Tags: CPython 3.7, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 956c9a07427427a377e6ad4f344f9915638155cf64e6cdb337d3f3127d1dafc3 |
|
MD5 | aa88d743681557d40d7e2e7ba11de0c8 |
|
BLAKE2b-256 | d2e9fed70a3481f54e023069ecaad83976aa7505a72d8032b22c77419ad8fef7 |
File details
Details for the file entity_gym_rs-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 445.4 kB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18d8252861aaf38fc8b4fb030eee9090773b6aa8959cfae72c8cbb31a1e0127c |
|
MD5 | fde0a01eb40c405e66bb5dda415f4c35 |
|
BLAKE2b-256 | 5eac1a0185a516001e8b291ff4528b9e3a26843edab62a556fd3cf171ee40ef0 |
File details
Details for the file entity_gym_rs-0.8.0-cp37-cp37m-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: entity_gym_rs-0.8.0-cp37-cp37m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 407.4 kB
- Tags: CPython 3.7m, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.13.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac9a06b2ba2b956e7d34a043957432966812d1698665728be9630f6108fdad30 |
|
MD5 | 3d3793cfd1f3b759c532b8e942bde031 |
|
BLAKE2b-256 | 8ed63a4492fc61e0873374a786577cd38c0b42850e430d1d528384962e3f5348 |