In general, I don't worry much about defense until mid-game. It's fairly easy (at least on Monarch) to keep the AIs warring with each other and not with you. Of course this means giving in to a lot of demands, particularly from your nearest neighbours, but if I can keep them off my back, I don't worry about the ones who are farther away. The AI sucks at doing long distance warfare, and doesn't keep reinforcements coming, so it's easy to shatter their stack and then get them to take peace. Library? As soon as I get writing, provided I have a worker, a granary, and enough troops to keep off barbs. Those take priority. But the library is pretty close behind that. For this particular game: Spoiler : I didn't really build an army for defensive purposes till I had Janissaries. The library I built as soon as the granary was done. Being in a corner with near neighbours meant I didn't have barb problems at all.