[][src]Struct coliseum::space::Discrete

pub struct Discrete(pub u32);

The Discrete space allows a fixed range of non-negative numbers, so in this case valid actions are either 0 or 1.

Examples

Discrete contains actions 0..Discrete(N-1)

use coliseum::space::{Discrete, Space};

let N = 10;
let discrete = Discrete(N);

// what's the idiomatic way to avoid cloning here?
assert!(discrete.clone().sample() < 10);
assert!(!discrete.clone().contains(10));

We can represent N*2 states for Discrete{N}

use coliseum::space::{Discrete, Space};
let discrete = Discrete(3);

let sample: (u32, u32, u32) = match discrete.sample() {
    0 => (1, 0, 0),
    1 => (0, 1, 0),
    2 => (0, 0, 1),
    _ => panic!("This is out of bounds!")
};

assert_eq!(sample.0 + sample.1 + sample.2, 1)

Trait Implementations

impl Environment<Discrete, u32, Discrete, u32> for RockPaperScissors[src]

Examples

use coliseum::env;
use env::{Environment, State};
use env::rock_paper_scissors::RockPaperScissors;

let mut game = RockPaperScissors::default();
game.reset();

// our player loves rock
let agent = || 1;

loop {
    let State { reward, done, .. } = game.step(agent());

    if done {
        break;
    }
}

fn reset(&mut self) -> u32[src]

impl Space<u32> for Discrete[src]

fn sample(self) -> u32[src]

Draws a random item from [0, u32]

fn contains(self, sample: u32) -> bool[src]

Checks if the sample is part of the set

impl Clone for Discrete[src]

impl Copy for Discrete[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,