[][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.


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);

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]


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

let mut game = RockPaperScissors::default();

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

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

    if done {

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>, 

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

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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

impl<T> BorrowMut<T> for T where
    T: ?Sized

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

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