I made my own independent implementation in C#.
This does a breadth-first search of all legally reachable states, where a "move" is defined as moving a single piece any distance.
I would imagine that other possible definitions of "move" may exist, for example:
- the same piece may be moved multiple times e.g. "around a corner" as a single move.
- a piece that is not immediately adjacent to a gap may be "moved" by pushing the pieces between it and the gap.
It is not clear what definition of "move" the original puzzle setter intended.
My code confirms 222 as the minimum number of moves (of a single piece any distance in a single direction) to reach the solved state.
When I redefined a "move" to allow any number of pieces to be moved simultaneously by the same amount in the same direction, it found a solution in 146 moves. This included some "mega moves" like this:
After move 120: piece(s) at 32,39,37 by 1 Left to cover 36:
##################
╔═╗╔════╗╔═╗╔═╗###
║ ║╚════╝╚═╝║ ║###
║ ║╔════╗╔══╝ ║###
╚═╝╚════╝╚════╝###
╔════╗╔═══════╗###
╚════╝╚═══════╝###
╔═╗╔═╗ ╔════╗###
║ ║║ ║ ╚════╝###
║ ║║ ╚══╗ ╔═╗###
╚═╝╚════╝ ╚═╝###
╔════╗╔════╗ ###
╚════╝╚════╝ ###
##################
After move 121: piece(s) at 15,20,27,34 by 1 Down to cover 40:
##################
╔═╗╔════╗╔═╗ ###
║ ║╚════╝╚═╝ ###
║ ║╔════╗ ╔═╗###
╚═╝╚════╝ ║ ║###
╔════╗ ╔══╝ ║###
╚════╝ ╚════╝###
╔═╗╔═╗╔═══════╗###
║ ║║ ║╚═══════╝###
║ ║║ ╚══╗╔════╗###
╚═╝╚════╝╚════╝###
╔════╗╔════╗╔═╗###
╚════╝╚════╝╚═╝###
##################
After move 122: piece(s) at 19,12,8,9,14 by 1 Right to cover 15:
##################
╔═╗╔════╗╔═╗###
║ ║╚════╝╚═╝###
║ ║╔════╗╔═╗###
╚═╝╚════╝║ ║###
╔════╗╔══╝ ║###
╚════╝╚════╝###
╔═╗╔═╗╔═══════╗###
║ ║║ ║╚═══════╝###
║ ║║ ╚══╗╔════╗###
╚═╝╚════╝╚════╝###
╔════╗╔════╗╔═╗###
╚════╝╚════╝╚═╝###
##################
When I instead redefined a move to allow a single piece to be moved in multiple directions, it found a solution in 191 moves.
It is thus unclear what exact rule set must be used to have the solution "in 187 moves" as stated in the question, but my first modification allows this with some margin. Perhaps if the rules of which pieces can move "together" are tightened somewhat (e.g. perhaps the first and last "mega moves" would need to be split as they can't be done by pushing a single piece and having that piece push the others) we'd get something closer to the 187 move target, but as I considered how to implement that, it started to get a bit "complicated".
Returning to the "original" definition of a move, when I remove the termination condition, it also confirms 6288084 (mentioned in the comments of Graham's answer) as the number of unique states that can be reached with legal moves. Of those, there are 12 states that can be reached only after 436 moves! (printed as 11 by the program which doesn't count the state currently being processed)
See links to source code and program output including the first solution found after 222 moves (looks better if pasted into something that doesn't put gaps between the lines), and to the source code modified to allow moves to be combined (with the two merge types as described above, controlled by AllowableMergeType
), and its output for a 146 move solution.
A summary of the 222-step solution found based on a tidied up copy of the program output (as there are fewer empty squares than pieces, I used the empty squares to track the moves rather than the pieces, so each move is described by the number of an empty square that is covered, and the direction that a piece is moved in order to cover it - e.g. "Down to 39" means that the piece directly above empty square 39 is moved down just far enough to cover square 39):
Starting state with square numbers labelled:
##################
╔═╗╔═══════╗╔═╗### <== squares 6 to 10
║ ║╚═══════╝║ ║###
║ ╚══╗╔═╗╔══╝ ║### <== squares 12 to 16
╚════╝║ ║╚════╝###
╔════╗║ ║╔════╗### <== squares 18 to 22
╚════╝╚═╝╚════╝###
╔════╗╔═╗╔════╗### <== squares 24 to 28
╚════╝║ ║╚════╝###
╔════╗║ ║╔════╗### <== squares 30 to 34
╚════╝╚═╝╚════╝###
╔═╗ 3 3 3 ╔═╗### <== squares 36 to 40
╚═╝ 7 8 9 ╚═╝###
##################
Move 1: Left to 37
Move 2: Down to 38
Move 3: Down to 39
Move 4: Down to 33
Move 5: Right to 28
Move 6: Up to 24
Move 7: Up to 30
Move 8: Up to 31
Move 9: Up to 26
Move 10: Left to 36
Move 11: Down to 39
Move 12: Down to 33
Move 13: Down to 38
Move 14: Right to 28
Move 15: Down to 24
Move 16: Right to 26
Move 17: Up to 18
Move 18: Left to 30
Move 19: Right to 19
Move 20: Up to 18
Move 21: Left to 24
Move 22: Down to 26
Move 23: Down to 30
Move 24: Down to 24
Move 25: Left to 18
Move 26: Left to 25
Move 27: Up to 14
Move 28: Right to 32
Move 29: Right to 38
Move 30: Down to 36
Move 31: Down to 30
Move 32: Left to 24
Move 33: Up to 25
Move 34: Right to 32
Move 35: Up to 30
Move 36: Right to 31
Move 37: Down to 36
Move 38: Left to 24
Move 39: Up to 26
Move 40: Up to 18
Move 41: Up to 24
Move 42: Left to 36
Move 43: Left to 25
Move 44: Down to 38
Move 45: Right to 26
Move 46: Up to 14
Move 47: Left to 25
Move 48: Down to 27
Move 49: Down to 21
Move 50: Right to 15
Move 51: Right to 10
Move 52: Right to 14
Move 53: Right to 20
Move 54: Up to 6
Move 55: Left to 30
Move 56: Up to 18
Move 57: Left to 24
Move 58: Down to 30
Move 59: Left to 25
Move 60: Down to 27
Move 61: Right to 21
Move 62: Right to 19
Move 63: Right to 16
Move 64: Down to 24
Move 65: Left to 12
Move 66: Up to 14
Move 67: Left to 7
Move 68: Up to 10
Move 69: Up to 16
Move 70: Right to 28
Move 71: Down to 25
Move 72: Up to 20
Move 73: Right to 32
Move 74: Right to 38
Move 75: Down to 36
Move 76: Down to 18
Move 77: Left to 13
Move 78: Left to 6
Move 79: Left to 9
Move 80: Up to 10
Move 81: Up to 21
Move 82: Up to 27
Move 83: Right to 34
Move 84: Down to 32
Move 85: Down to 31
Move 86: Down to 24
Move 87: Left to 19
Move 88: Down to 21
Move 89: Down to 15
Move 90: Right to 10
Move 91: Left to 12
Move 92: Up to 6
Move 93: Up to 13
Move 94: Left to 12
Move 95: Left to 14
Move 96: Down to 20
Move 97: Left to 19
Move 98: Up to 14
Move 99: Right to 32
Move 100: Up to 26
Move 101: Left to 31
Move 102: Down to 33
Move 103: Down to 27
Move 104: Right to 21
Move 105: Right to 20
Move 106: Right to 14
Move 107: Up to 12
Move 108: Left to 24
Move 109: Up to 25
Move 110: Left to 31
Move 111: Down to 33
Move 112: Right to 27
Move 113: Right to 22
Move 114: Right to 21
Move 115: Up to 15
Move 116: Up to 20
Move 117: Right to 27
Move 118: Up to 25
Move 119: Up to 31
Move 120: Left to 37
Move 121: Down to 39
Move 122: Down to 33
Move 123: Right to 27
Move 124: Down to 28
Move 125: Down to 24
Move 126: Left to 19
Move 127: Down to 21
Move 128: Left to 12
Move 129: Down to 14
Move 130: Right to 9
Move 131: Up to 6
Move 132: Left to 12
Move 133: Up to 15
Move 134: Up to 10
Move 135: Right to 28
Move 136: Up to 21
Move 137: Up to 27
Move 138: Left to 26
Move 139: Down to 27
Move 140: Right to 22
Move 141: Up to 20
Move 142: Left to 26
Move 143: Left to 19
Move 144: Left to 20
Move 145: Down to 28
Move 146: Right to 16
Move 147: Up to 10
Move 148: Right to 16
Move 149: Up to 13
Move 150: Up to 12
Move 151: Up to 24
Move 152: Left to 36
Move 153: Left to 38
Move 154: Down to 40
Move 155: Right to 22
Move 156: Left to 25
Move 157: Down to 27
Move 158: Down to 20
Move 159: Right to 16
Move 160: Down to 14
Move 161: Right to 9
Move 162: Up to 6
Move 163: Left to 19
Move 164: Down to 22
Move 165: Right to 16
Move 166: Right to 14
Move 167: Up to 6
Move 168: Left to 24
Move 169: Left to 26
Move 170: Down to 28
Move 171: Right to 22
Move 172: Left to 30
Move 173: Up to 18
Move 174: Left to 24
Move 175: Left to 26
Move 176: Down to 32
Move 177: Right to 28
Move 178: Down to 24
Move 179: Left to 18
Move 180: Up to 21
Move 181: Right to 28
Move 182: Up to 26
Move 183: Left to 24
Move 184: Left to 25
Move 185: Up to 27
Move 186: Up to 28
Move 187: Right to 40
Move 188: Down to 36
Move 189: Right to 38
Move 190: Down to 36
Move 191: Left to 24
Move 192: Down to 30
Move 193: Down to 24
Move 194: Left to 18
Move 195: Down to 21
Move 196: Down to 16
Move 197: Left to 15
Move 198: Left to 20
Move 199: Up to 10
Move 200: Right to 34
Move 201: Up to 27
Move 202: Right to 34
Move 203: Down to 30
Move 204: Down to 24
Move 205: Left to 18
Move 206: Left to 26
Move 207: Down to 28
Move 208: Right to 16
Move 209: Up to 15
Move 210: Right to 26
Move 211: Up to 10
Move 212: Up to 16
Move 213: Up to 27
Move 214: Right to 33
Move 215: Up to 24
Move 216: Left to 30
Move 217: Up to 33
Move 218: Right to 40
Move 219: Down to 36
Move 220: Left to 30
Move 221: Up to 33
Move 222: Right to 39
After move 222: Right to 39:
##################
╔═╗╔═╗╔════╗╔═╗###
║ ║║ ║╚════╝╚═╝###
║ ║║ ╚══╗╔═╗╔═╗###
╚═╝╚════╝║ ║║ ║###
╔════╗╔══╝ ║║ ║###
╚════╝╚════╝╚═╝###
╔═╗╔════╗╔════╗###
╚═╝╚════╝╚════╝###
╔════╗ ╔════╗###
╚════╝ ╚════╝###
╔═══════╗ ###
╚═══════╝ ###
##################
In this implementation I didn't specifically model the pieces - merely the connections to adjacent cells in the position that each piece is currently resting, so all pieces of the same shape are inherently indistinguishable.
I later thought to print out the 12 "most complicated" states, which take 436 of this type of move to reach. There were the following (together with the mirror images of each):
##################
╔════╗ ╔═╗╔═╗###
╚════╝ ║ ║╚═╝###
╔═╗╔════╗║ ╚══╗###
╚═╝╚════╝╚════╝###
╔═╗╔═══════╗ ###
║ ║╚═══════╝ ###
║ ║╔═╗╔════╗ ###
╚═╝║ ║╚════╝ ###
╔══╝ ║╔═╗╔════╗###
╚════╝║ ║╚════╝###
╔════╗║ ║╔════╗###
╚════╝╚═╝╚════╝###
##################
##################
╔════╗╔═╗╔════╗###
╚════╝╚═╝╚════╝###
╔═╗ ╔═╗╔════╗###
╚═╝ ║ ║╚════╝###
╔═╗╔══╝ ║╔════╗###
║ ║╚════╝╚════╝###
║ ║╔═══════╗ ###
╚═╝╚═══════╝ ###
╔════╗╔═╗╔═╗ ###
╚════╝║ ║║ ║ ###
╔════╗║ ║║ ╚══╗###
╚════╝╚═╝╚════╝###
##################
##################
╔════╗╔═╗╔════╗###
╚════╝╚═╝╚════╝###
╔═╗╔═╗╔═╗╔════╗###
║ ║╚═╝║ ║╚════╝###
║ ║╔══╝ ║╔════╗###
╚═╝╚════╝╚════╝###
╔════╗╔═══════╗###
╚════╝╚═══════╝###
╔════╗╔═╗╔═╗ ###
╚════╝║ ║║ ║ ###
║ ║║ ╚══╗###
╚═╝╚════╝###
##################
##################
╔════╗╔═╗╔════╗###
╚════╝╚═╝╚════╝###
╔═╗ ╔═╗╔════╗###
╚═╝ ║ ║╚════╝###
╔═╗╔══╝ ║╔════╗###
║ ║╚════╝╚════╝###
║ ║ ╔═══════╗###
╚═╝ ╚═══════╝###
╔════╗╔═╗╔═╗ ###
╚════╝║ ║║ ║ ###
╔════╗║ ║║ ╚══╗###
╚════╝╚═╝╚════╝###
##################
##################
╔════╗╔════╗ ###
╚════╝╚════╝ ###
╔═╗╔═╗╔═╗╔════╗###
╚═╝╚═╝║ ║╚════╝###
╔═╗╔══╝ ║╔════╗###
║ ║╚════╝╚════╝###
║ ║╔═══════╗ ###
╚═╝╚═══════╝ ###
╔════╗╔═╗╔═╗ ###
╚════╝║ ║║ ║ ###
╔════╗║ ║║ ╚══╗###
╚════╝╚═╝╚════╝###
##################
##################
╔════╗╔════╗ ###
╚════╝╚════╝ ###
╔═╗╔═╗╔═╗╔════╗###
╚═╝╚═╝║ ║╚════╝###
╔═╗╔══╝ ║╔════╗###
║ ║╚════╝╚════╝###
║ ║ ╔═══════╗###
╚═╝ ╚═══════╝###
╔════╗╔═╗╔═╗ ###
╚════╝║ ║║ ║ ###
╔════╗║ ║║ ╚══╗###
╚════╝╚═╝╚════╝###
##################