Practice.
The Great Pyramids were the ultimate example of Old Kingdom Egyptian architecture, but they weren’t a first attempt. The Nile valley is littered with older, smaller pyramids of varying design and complexity. There are some examples that had collapsed during construction or soon after completion. Bent pyramids, stepped pyramids, lots of techniques and designs being workshopped.
Eventually they got very good at both the design and construction, and built the world wonders we’re all familiar with.
Latest Answers