The problem was that the board was too large to rotate 180 degrees. When I switched the shape from Grid to Square, it worked. To make it work for the provided background images, I replaced imagerotate() with imageflip(), which could get the same effect as rotating by 180 degrees by simply mirroring the image across both dimensions. Because this used fewer resources, it could handle the images provided for this game.
The problem was that the board was too large to rotate 180 degrees. When I switched the shape from Grid to Square, it worked. To make it work for the provided background images, I replaced imagerotate() with imageflip(), which could get the same effect as rotating by 180 degrees by simply mirroring the image across both dimensions. Because this used fewer resources, it could handle the images provided for this game.