Skip to main content

Rust bindings for the entity-gym library

Project description

EntityGym for Rust

Crates.io PyPI MIT/Apache 2.0 Discord Docs Actions Status

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 an Agent. 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-size structs, and for enums with unit variants. Agents can observe collections containing any number of Featurizable 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

entity_gym_rs-0.5.0.tar.gz (27.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

entity_gym_rs-0.5.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (448.6 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

entity_gym_rs-0.5.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (445.9 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

entity_gym_rs-0.5.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (452.1 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

entity_gym_rs-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (448.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

entity_gym_rs-0.5.0-cp310-none-win_amd64.whl (373.0 kB view details)

Uploaded CPython 3.10Windows x86-64

entity_gym_rs-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (448.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

entity_gym_rs-0.5.0-cp310-cp310-macosx_10_7_x86_64.whl (409.6 kB view details)

Uploaded CPython 3.10macOS 10.7+ x86-64

entity_gym_rs-0.5.0-cp39-none-win_amd64.whl (372.9 kB view details)

Uploaded CPython 3.9Windows x86-64

entity_gym_rs-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (448.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

entity_gym_rs-0.5.0-cp39-cp39-macosx_10_7_x86_64.whl (409.6 kB view details)

Uploaded CPython 3.9macOS 10.7+ x86-64

entity_gym_rs-0.5.0-cp38-none-win_amd64.whl (372.6 kB view details)

Uploaded CPython 3.8Windows x86-64

entity_gym_rs-0.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (448.4 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

entity_gym_rs-0.5.0-cp38-cp38-macosx_10_7_x86_64.whl (409.5 kB view details)

Uploaded CPython 3.8macOS 10.7+ x86-64

entity_gym_rs-0.5.0-cp37-none-win_amd64.whl (372.6 kB view details)

Uploaded CPython 3.7Windows x86-64

entity_gym_rs-0.5.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (448.6 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

entity_gym_rs-0.5.0-cp37-cp37m-macosx_10_7_x86_64.whl (409.4 kB view details)

Uploaded CPython 3.7mmacOS 10.7+ x86-64

File details

Details for the file entity_gym_rs-0.5.0.tar.gz.

File metadata

  • Download URL: entity_gym_rs-0.5.0.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.13.3

File hashes

Hashes for entity_gym_rs-0.5.0.tar.gz
Algorithm Hash digest
SHA256 ff370cd89fcbee1f69221b23ebfbb5fb6868ef1b13e54e0d4cafe6a4b1d66f22
MD5 319c3b8204bc09ba67f78c0fd822eeee
BLAKE2b-256 a7f1989876aaeea7c2ba69ac2416f8537b7646a9eb9779d82e044c1ddacfbc8f

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fed6e0d173dd863b3c81bb94ea9626b92a76b47403f13d7ffd62f1cd0d5f7fec
MD5 6121e037484407fce9be1d74df2aa7be
BLAKE2b-256 fd98c08732bdf5bc9322e5cb53a59061a88285c1f0952b2eab3869bd5e9271ff

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 11ffcc91fcf576e5a80cdc9f92078dab5dcbabab8423729c6d6ae53d52622c39
MD5 91ce23f6cee55e97a2591b78a6f86279
BLAKE2b-256 029f3d95192c0533ed02f859492fb89763a915185692ccf31ffdaf40cb56aa3f

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f5b76ed81a3210d7ae48e64c2b3a76d0baff7c2ffbe39f6821419cb9de8c4787
MD5 c3d7f9070292a17dbd1a7fa6d1d188ad
BLAKE2b-256 b502b5674554d5f39e6e52b6728e4895f7d326f2c27544542ba69e8a52ea4b62

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3ef29c3e4d603091d7a176b1622089b02449ba61f44e648180d73f952b2d51ec
MD5 9955b79aef510275c852f781d8ce35e2
BLAKE2b-256 edb41212184df5759aeda10d2e531a736a81f5c0fdbf38663bf8c6ea96bedb5c

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 ec449307206ed7b14a2683dca797f84d8dc59998225a5ab001a61ff52bfbecee
MD5 ad001628a1da8d02ae530b553c124fc4
BLAKE2b-256 3959e57db8bc738a249e5544a909dda01cde2161643dde56949fe0188b01e82e

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 36364dd0943e54bfa561fc71eae1af031bc838c62dad9b10516e57c2ead93306
MD5 2b5869d39f903080d7c853c610d8c4d7
BLAKE2b-256 f34b1b66ed1fd8d6775b56f7223c8b19ec5280f90c15206de367d8e59cd1a5c0

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-cp310-cp310-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 9528b76344f4d4c0b04e82670d56c02eec80b99876df1ad6014877e4e6c7050a
MD5 9b371103127db73029a0da9422a0a628
BLAKE2b-256 7bac03240e8fc0e1be063f8aeec61b31ae2b619f57dc6d9c3a0fa06d819c18cf

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-cp39-none-win_amd64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 596829300ec93ceb0e6c746e2f1f3c1bf60161ae6c1e612b84e72a1f68c2e370
MD5 aed8790070bf94b461b98b961fc34317
BLAKE2b-256 fc6e1048e902e8a34b2655448d2957ec2c0847daf28108b6d2bfad0f5fb3525a

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9e638a4ad618269756a54bead12f2f7028b169960f6f2eee8b0ed5d93ce4d49e
MD5 e610e04b4f878de016c0cb440f45c91d
BLAKE2b-256 cff39dc144493b08c373e423eb9a463f7eaa54b0ab27c62465e917a6ba1d8dba

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 b02eecde5fa8e3e94884aed8ce83ccc80313528fecc6873036e21eb591fa3dd6
MD5 8fb05408a5080339ef5441a5f8ff7336
BLAKE2b-256 599d6a761a2a258d79514521f3cefcf42283c8cf67176177fc002a95535ca29d

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-cp38-none-win_amd64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 a61472ab0d6f6cdd4f499d88e4b5cd071e8e57bf7c709d44dab74c6fd3ffb78f
MD5 d1af3ba44a460002a1c919612d086db5
BLAKE2b-256 db9baa84d7ecf6ed0384ebe66b935e3ce928e3e789c7372c58319c888df2507e

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 658fbb0df26e0e96bace2695f3cb88d9b320ea0fe0e45a2991a39eace44857d0
MD5 6c49c37c0a615a79af12e20056d4bd56
BLAKE2b-256 664600208542ee1164252c09789da53bee4f2e736f1671b00cf516f3226041bf

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 ea0025f27440d7669fa407c210d8c6288d8853ad053c428309d776c5cdf891c8
MD5 82d8ae42bf4b1b962c888feec79665aa
BLAKE2b-256 d05448e9da28f0b3619978ded3f4ac1172dac5bddf3f5e7dc8decdfda8d295a3

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-cp37-none-win_amd64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 19acba611a8f2e532aa25aa20c1e076bea3fd40163bee5e36dd7e424359a4aa8
MD5 78dbec42708d071872a435f084060b42
BLAKE2b-256 a90f1f19d02d551c45a358fdf60a00810f0dad5a0b838b97fe3165c12dd8d856

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 232cce53ee80e16614721057d28e4c449f99c1e5f0b3518c7dba7187789002e2
MD5 0bd28f41985faabef7db00a8038dd61c
BLAKE2b-256 f53fd01f4ffd72e12cbf7349ddb526e11c909cd68a644740f7a5b1441e854f8f

See more details on using hashes here.

File details

Details for the file entity_gym_rs-0.5.0-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for entity_gym_rs-0.5.0-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 5704084ee22b8ff4fbe6a9430a80b974f7b5e44073f30d911ea64f3ecd1b0c9b
MD5 9363c59e85d0949aefdc45dbca9ea5b6
BLAKE2b-256 bdb15221f9212f881f2ae8ea1e8425f13518391c5340385e83f32f3437ba6065

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page