So, digging away all the dirt would suffice, too? Or shall there be a certain 'ground' level (could be visualized through a fitting background)?
Puzzle solved or not?
Code:
------ initial ground level
<- all empty space
P
###### Blocks(Dirt/Rock/Boulder...); new ground level
###### No gems left.