WASD or arrows to move the blue guy. Space to mine rocks. The goal is to get all the NPCs into the best homes you can. If you don’t like how everything spawned, reset by clicking the green flag. Also, don't build on the sky. There will be consequences.
Thanks to @GORPHITE for coding help. Couldn’t have done it without them. Also thanks to griffpatch's snap-to-grid program.