Endogenous change: On cooperation and water availability in two ancient societies