Algorithm for stone construction