Change line 61 back. The move should always be value as any adjacent valid location to the empty location will have a mover. With the way the offsets were arrived at, no invalid locations will be among them. Also, collision checking fails during the 'for' loop. That is why I rearranged the parts of the code -- to avoid collision checking when not needed.