Current algorithm is (mainly because the global structure wasn't changed when introducing intermediate checks):
1) Check for lemming movement: This (among other things) determines the end position for the lemming and does transitions to other actions (like becoming a walker/splatter when reaching the ground)
2) Determine the path the lemming took based on the starting and end position.
3) Check all intermediate pixels for trigger areas.
So in the fifth setup, the lemming transitions to a splatter, because he would reach the ground and splat if there wouldn't be a trigger area (cf. step 1). Then in step 3 the intermediate pixels are checked and the teleporter is found. But the lemming is already a splatter due to step 1.
The current algorithm works so well, because almost all objects fall into one of the following three categories:
- Objects that remove the lemming (like traps and exits). So it doesn't matter at all if there is a wrong transition that shouldn't happen.
- Objects that don't have any effect on the lemming movement (like buttons, pick-up skills) are obviously fine.
- Objects that only do changes that can be made before or after the movement and don't change anything (like flippers, due to never moving more than one pixel horizontally).
To fix this issue properly, I plan to implement the following changes:
- If a lemming will transition to a different action only at the end of his movement (e.g. splatting after falling, fallling after moving as a miner, ... contrary to starting a newly assigned skill or exploding), this is not applied immediately, but saved for the moment.
- The transition to the new action will only be applied after having checked all intermediate positions, except the very last position. The end position will then be checked after transitioning. If the lemming stops before reaching the expected end position, the transition will not be made.