You can do nine gems in 3 moves

you can do a while true loop and hero.moveXY(32, 48) but i think you can do the rest