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 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};
// The `Action` trait can be automatically derived for any enum with only unit variants.
#[derive(Action, Debug)]
enum Move { Up, Down, Left, Right }
// The `Featurizable` trait 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();
// To load an neural network agent from an enn-trainer checkpoint, you would use the `load` method instead.
// let mut agent = Agent::load("agent");
// An observation can be constructed from 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 },
]);
// The agent `act` method takes an observation and returns an action of the specified type.
let action = agent.act::<Move>(obs);
println!("{:?}", action);
}
Docs
- bevy_snake: Example of how to use entity-gym-rs in a Bevy game.
- bevy_multisnake: Example of more advanced Bevy integration and adversarial training with multiple agents.
- EntityGym Rust API Docs: Rust API reference.
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
entity_gym_rs-0.1.1.tar.gz
(26.1 kB
view hashes)
Built Distributions
Close
Hashes for entity_gym_rs-0.1.1-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c70c6d4cb09df336f6ce01124391f10697f0917a941c79b97ad04b0e2f241f74 |
|
MD5 | 26e702ed4c639bfccb1687fd5c4de6cf |
|
BLAKE2b-256 | 351bc92f1ee5b99e0bf8d24cbb0decb3878626020517d73f1c6f2239c3d8066b |
Close
Hashes for entity_gym_rs-0.1.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba281c910eac141d8e6cb7c3287792d16c6a9272e8eebf46fe2aa5f756b511c6 |
|
MD5 | 59245f8b1594105457f41bd17ab123ab |
|
BLAKE2b-256 | e3f946614866574082708ffbc1eaabf96e87c592ffd28ac513bf20161ce55963 |