pub struct World { /* private fields */ }
Implementations§
Source§impl World
impl World
pub fn new( grid: Vec<Vec<Tile>>, gem_positions: Vec<Position>, random_start_positions: Vec<Vec<Position>>, void_positions: Vec<Position>, exit_positions: Vec<Position>, walls_positions: Vec<Position>, source_positions: Vec<Position>, lasers_positions: Vec<Position>, ) -> Self
pub fn n_agents(&self) -> usize
pub fn n_laser_colours(&self) -> usize
pub fn seed(&mut self, seed: u64)
pub fn get_config(&self) -> WorldConfig
Sourcepub fn world_string(&self) -> String
pub fn world_string(&self) -> String
The world string, taking into account the fact that some tiles may have changed (laser direction or colour).
pub fn agents(&self) -> &Vec<Agent>
pub fn agents_positions(&self) -> &Vec<Position>
pub fn gems_positions(&self) -> Vec<Position>
pub fn gems(&self) -> Vec<&Gem>
pub fn sources(&self) -> Vec<(Position, &LaserSource)>
pub fn lasers(&self) -> Vec<(Position, &Laser)>
pub fn set_exit_positions( &mut self, exits: Vec<Position>, ) -> Result<(), ParseError>
pub fn exits_positions(&self) -> Vec<Position>
pub fn n_gems(&self) -> usize
Sourcepub fn available_actions(&self) -> &Vec<Vec<Action>>
pub fn available_actions(&self) -> &Vec<Vec<Action>>
The available actions for each agent.
The actions available to agent n
are located in world.available_actions()[n]
.
Sourcepub fn available_joint_actions(&self) -> Vec<Vec<Action>>
pub fn available_joint_actions(&self) -> Vec<Vec<Action>>
Compute the available joint actions for all agents. The joint actions are all the possible combinations of the available actions for each agent. The result is a matrix of shape (x, n_agents) where x is the number of joint actions.
pub fn n_gems_collected(&self) -> usize
pub fn n_agents_arrived(&self) -> usize
pub fn width(&self) -> usize
pub fn height(&self) -> usize
pub fn walls(&self) -> Vec<Position>
pub fn starts(&self) -> Vec<Position>
pub fn possible_starts(&self) -> Vec<Vec<Position>>
pub fn void_positions(&self) -> Vec<Position>
Sourcepub fn all_states(
&self,
restrict_to_alive_agents: bool,
) -> impl Iterator<Item = WorldState> + '_
pub fn all_states( &self, restrict_to_alive_agents: bool, ) -> impl Iterator<Item = WorldState> + '_
Iterator over all the possible states of the World. NOT YET TESTED
Sourcepub fn tiles(&self) -> Vec<(Position, &Tile)>
pub fn tiles(&self) -> Vec<(Position, &Tile)>
Creates an iterator over all tiles in the grid with their (i, j) coordinates
pub fn at(&self, pos: &Position) -> Option<&Tile>
pub fn at_mut(&mut self, pos: &Position) -> Option<&mut Tile>
pub fn reset(&mut self)
Sourcepub fn step(
&mut self,
actions: &[Action],
) -> Result<Vec<WorldEvent>, RuntimeWorldError>
pub fn step( &mut self, actions: &[Action], ) -> Result<Vec<WorldEvent>, RuntimeWorldError>
Perform one step in the environment and return the corresponding reward.
pub fn get_state(&self) -> WorldState
pub fn set_state( &mut self, state: &WorldState, ) -> Result<Vec<WorldEvent>, RuntimeWorldError>
pub fn get_level(level: usize) -> Result<Self, ParseError>
pub fn from_file(file: &str) -> Result<Self, ParseError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for World
impl !RefUnwindSafe for World
impl !Send for World
impl !Sync for World
impl Unpin for World
impl !UnwindSafe for World
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more