-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
519 additions
and
320 deletions.
There are no files selected for viewing
74 changes: 0 additions & 74 deletions
74
crates/beet_ml/src/environments/frozen_lake/frozen_lake_environment.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
crates/beet_ml/src/environments/frozen_lake/frozen_lake_scene.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use crate::prelude::*; | ||
use bevy::prelude::*; | ||
|
||
pub fn spawn_frozen_lake_scene( | ||
commands: &mut Commands, | ||
map: &FrozenLakeMap, | ||
grid_to_world: &GridToWorld, | ||
assets: &Res<FrozenLakeAssets>, | ||
bundle: impl Bundle + Clone, | ||
) { | ||
let tile_scale = Vec3::splat(grid_to_world.cell_width); | ||
for x in 0..map.num_cols() { | ||
for y in 0..map.num_rows() { | ||
let mut pos = grid_to_world.world_pos(UVec2::new(x, y)); | ||
pos.y -= grid_to_world.cell_width; | ||
commands.spawn(( | ||
SceneBundle { | ||
scene: assets.tile.clone(), | ||
transform: Transform::from_translation(pos) | ||
.with_scale(tile_scale), | ||
..default() | ||
}, | ||
bundle.clone(), | ||
)); | ||
} | ||
} | ||
|
||
let object_scale = Vec3::splat(grid_to_world.cell_width * 0.5); | ||
|
||
for (index, cell) in map.cells().iter().enumerate() { | ||
let grid_pos = map.index_to_position(index); | ||
let mut pos = grid_to_world.world_pos(grid_pos); | ||
match cell { | ||
FrozenLakeCell::Hole => { | ||
pos.y += grid_to_world.cell_width * 0.25; // this asset is a bit too low | ||
commands.spawn(( | ||
SceneBundle { | ||
scene: assets.hazard.clone(), | ||
transform: Transform::from_translation(pos) | ||
.with_scale(object_scale), | ||
..default() | ||
}, | ||
bundle.clone(), | ||
)); | ||
} | ||
FrozenLakeCell::Goal => { | ||
commands.spawn(( | ||
SceneBundle { | ||
scene: assets.goal.clone(), | ||
transform: Transform::from_translation(pos) | ||
.with_scale(object_scale), | ||
..default() | ||
}, | ||
bundle.clone(), | ||
)); | ||
} | ||
FrozenLakeCell::Ice => {} | ||
FrozenLakeCell::Agent => { /*spawns on episode */ } | ||
} | ||
{} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.