rust-sokoban icon indicating copy to clipboard operation
rust-sokoban copied to clipboard

Box can move in situation where it shouldn't move

Open danieldeankon opened this issue 5 years ago • 2 comments

Steps to reproduce:

  • Get local copy of directory listed at https://github.com/iolivia/rust-sokoban/tree/master/code/rust-sokoban-c02-03
  • Change contents of const MAP in main.rs to
    N N W W W W W W
    W W W . . . . W
    W . P W B . . W
    W . . . . . . W 
    W . . . . . . W
    W . . . . . . W
    W . . S . . . W
    W . . . . . . W
    W W W W W W W W
  • Build and run the game
  • Press the right arrow key
  • Observe: https://cdn.discordapp.com/attachments/739458870853894215/739459125720776704/sokoban-bug.mp4

I was able to stop the behaviour by changing the match expression on line 173 to

                            match immov.get(&pos) {
                                Some(id) => {
                                    to_move.clear();
                                    break
                                },
                                None => break,
                            }

I haven't tested rigorously to see whether or not this introduces any new unwanted behaviour, but it seems to not do so.

danieldeankon avatar Aug 02 '20 12:08 danieldeankon

Since the attached video seems corrupt, here's the result:

image

where the box is moved even though it is obstructed by a wall.

L-F-Stack-Exchange avatar Aug 03 '20 06:08 L-F-Stack-Exchange

This fix also prevents multiple of the same sounds playing at the same time when audio is introduced. When this happens it appears that the sounds suddenly got louder, but that's just what happens when the same sound is played simultaneously.

desttinghim avatar Aug 08 '20 12:08 desttinghim