I don't know what is happening but I'm going to assume you're writing an automated solver for ChuChu Rocket! puzzles until proven otherwise
https://www.youtube.com/watch?v=BPhm3BwKWVE
Heh :) ... No, this is actually yet another of my countless attempts at pixel-based image transitions. In this notebook I'm exploring the movement of groups of pixels. The basic rules are that each pixel can only be moved on step at a time, and that no two pixels can be swapped.