Hands-on Rust: Various Typos/Notes B3.0

The last issue in this set is more serious so I thought I would get it in in case you have not already had it reported.

p207 Instructions
Updating the Map
“Open systems/movement.rs and apply the following changes:”
I see no difference in the first code snippet from the previous code.
Subsequently I realized you were probably trying to show a few more lines to show a change to
#[resource] map: &mut Map,
(adding mut so we can update map.revealed_tiles)

p210 typo
“Red tints could represent heat signatures in a suspenseful &lquot;bug hunt&rquot; game.”

p213 Instructions
There has been no mention (so far) of replacing the code for placing YALA in the build function with a call to find most distant. The refactor is mentioned but not really completed.
mb.amulet_start = mb.find_most_distant();

p215 - p217 Instructions
Ran into more serious trouble. Reference Implemetation was not working as expected. Got to a working state as follows:
First, on p215 the code snippet includes monster_spawns which is not in the previous MapBuilder struct (but is in your code). So instructions are missing this change to mod.rs.
Second, there is no instruction to add the following to mod.rs
mod empty;
use empty::EmptyArchitect;
(it is in your code archive)
And without that, acrhitect cannot be set to EmptyArchitect in the build function.
Once I got that in, when I tried it, I got no monsters or amulet spawned.
I got the amulet to spawn if I set the spawn point to be something other than the player position:
mb.amulet_start = Point::new((SCREEN_WIDTH/2)+1, (SCREEN_HEIGHT/2)+1);
I got the monsters to spawn once I copied
map_builder.monster_spawns
.iter()
.for_each(|pos| spawn_monster(&mut ecs, &mut rng, *pos));
from your archive code into main.rs.
So that needs to be added to the instructions as well.

1 Like

I experimented with the amulet spawn some more and the find_most_distant is returning point 0,0.
If you move the player top left, you can move one up one tile and left one tile and win the game.
(You should be out of bounds and not be able to this)
So, the amulet is spawning, just off the visible map.
So it seems there is an off-by-one bug in the display that was not apparent when there were walls preventing us getting there.

1 Like

Oh, and that may well be my code, not yours. I’m trying to find it.

1 Like

I extracted the code from
/code/MoreInterestingDungeons/traits/
And I am seeing the same behavior. (Amulet is not visible at pos 0,0 and player can go 1 pos left and up (out-of-bounds) to win the game.)

1 Like

Found the issue here in other errta messages.
I added
fn in_bounds(&self, point: Point) -> bool {
self.in_bounds(point)
}
}
to the
impl Algorithm2D for Map {
and my out of bounds and amulet visibility problems are no more.

1 Like

Thanks for that! I merged the in_bounds fix into the next-beta last night, so that’ll be taken care of in the next beta. It fixed a number of corner cases, visibility being the most obvious one. I’ve logged the rest into the issue tracker; I think I’m out of time for beta 4, so these may be in beta 5.

1 Like