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 inside Rust.

Overview

The entity-gym-rs crate provides a high-level API that allows neural network agents to interact directly with Rust data structures.

use entity_gym_rs::agent::{Agent, AgentOps, Obs, Action, Featurizable};

// We can derive an `Action` trait on enums with only unit variants to allow it to be used as a categorical action.
#[derive(Action, Debug)]
enum Move { Up, Down, Left, Right }

// The `Featurizable` trait converts data structures into a format that can be processed by neural networks.
// It can be automatically derived for any struct that contains, only primitive number types, booleans, or
// other `Featurizable` types.
#[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");

    // The neural network agents supported by entity-gym can process observations consisting
    // of any number of `Featurizable` objects.
    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 get an action from an agent, we simple call the `act` method with the observation we constructed.
    let action = agent.act::<Move>(obs);
    println!("{:?}", action);
}

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.4.3.tar.gz (27.3 kB view hashes)

Uploaded Source

Built Distributions

entity_gym_rs-0.4.3-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl (447.1 kB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ x86-64

entity_gym_rs-0.4.3-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl (454.6 kB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ x86-64

entity_gym_rs-0.4.3-cp310-none-win_amd64.whl (375.0 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

entity_gym_rs-0.4.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl (448.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.5+ x86-64

entity_gym_rs-0.4.3-cp39-none-win_amd64.whl (375.1 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

entity_gym_rs-0.4.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (448.9 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.5+ x86-64

entity_gym_rs-0.4.3-cp39-cp39-macosx_10_7_x86_64.whl (410.0 kB view hashes)

Uploaded CPython 3.9 macOS 10.7+ x86-64

entity_gym_rs-0.4.3-cp38-none-win_amd64.whl (374.7 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

entity_gym_rs-0.4.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (448.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.5+ x86-64

entity_gym_rs-0.4.3-cp38-cp38-macosx_10_7_x86_64.whl (409.8 kB view hashes)

Uploaded CPython 3.8 macOS 10.7+ x86-64

entity_gym_rs-0.4.3-cp37-none-win_amd64.whl (374.8 kB view hashes)

Uploaded CPython 3.7 Windows x86-64

entity_gym_rs-0.4.3-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (448.5 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.5+ x86-64

entity_gym_rs-0.4.3-cp37-cp37m-macosx_10_7_x86_64.whl (409.6 kB view hashes)

Uploaded CPython 3.7m macOS 10.7+ x86-64

Supported by

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