Title: Hands-on Rust: monster pyramids due to simultaneous movement (page 157)
Hi @herbert ,
The explanation on the random movement system includes checking whether a monster is already present to avoid having several monsters occur in the same location. It seems to me that there is a bug. Monsters can occur in the same position. I believe the reason is because they both “state” their intent to move during the same turn, but the change in their component is placed in the command buffer. A monster’s changes are not flushed before the next monster gets to move, so they can run into each other.
This occurs in my own code (I rebuild from memory after reading), but I’ve checked the official source code for the book and I’m seeing the same issue there. I think it might be possible to avoid this by mutating a monster’s Point component directly rather than updating via the command buffer, but I’m still new to Rust and the borrow checker isn’t making this easy.