Dude, Brad, you're bad at your own game!
No offense, but OMG. I'm only going to do this because you are writing the AI, otherwise I would never be this critical of someone else's game. It's goddamn rude, I wouldn't like it and I don't like giving it. But feedback is what you need, and you made a lot of errors.
Errors in the tactical battle:
YOU MOVED FIRST. Don't. Reposition your troops so that the high def ones are up front and the low def ones are in the back. Let the AI walk and waste its AP moving towards you! Since it prioritizes nearby units unless there is a seriously weak option with a viable path (non-unit obstructions are ignored), it ensures that the targeting priority is managed according to your preferences. This also ensures that if the battle goes poorly, you can retreat in a single turn! Your familiar died before even attacking once because you didn't manage distance and placement! That meant you lost the ability to use that unit to absorb counter attacks and provide damage. It also crippled your group!
Once battle was joined you didn't focus your fire on a single target. This is a first order priority! It guarantees that you minimize counterattack possibilities, and maximize reduction in enemy offensive capabilities. This is the most efficient use of your HP, so do it!
You put a high atk zero def unit in the front line, and then used it to attack first against an enemy with good def who still had attacks remaining. Poor placement, poor management! Don't do this! Use your beefcakes to absorb retaliatory strikes, and then hit with your high attack units.
You didn't run away! It is trivial to escape a battle before the enemy can even reach you. It takes two turns to flee, maybe three. It is functionally impossible for an enemy to reach you before you make it to the exit. When that huge army hit you, you should have moved all your dudes to the exit. You would have then been moved two, three or even four squares away, and they would not have been able to reach you before you could escape on your next turn.
Strategic errors:
You had a familiar. Familiars are simply not worth the maintenance cost. They are also not worth the 10-15 turns it takes to research them in the early game. Having that silly thing and not having either heal or arcane arrow, both of which are worth another couple of units on the field, was a huge error. You also spent time research magic. Magic has one tech and one tree worth researching -- shard harvesting, and the arcane equipment line. You didn't have the money (or the crystal) for magic gear, and you already had shard harvesting. Furthermore, you had TWO air shards and almost certainly no fire shards. If you really wanted magic, the proper choice was the Book of Air. But, really, magic should not have been a priority. There is nothing in any of the elemental books that can come close to the damage and mana efficiency of arcane arrow, heal and magic blast or whatever it's called.
You didn't have teleport. If you had had teleport, you would have simply teleported away from that huge army and faced zero repercussions from your Pyrrhic victory. Teleport BREAKS THE GAME. My spell research is heal, level 2, magic arrow, teleport, level 3, magic blast. Once I have those four spells, I dismantle my arcane study things and build more libraries. Every other spell is a waste of time, pops and upkeep cost. There are no spells worth bothering with beyond those four -- although a case could be made for return, simply so that you can cast Imbue and then Return on exploring heroes who are too stupid for teleport.
Your units were poorly built! Basic staves and no armor? Your sov had armor, this means you had the ability to build troops with basic leather armor and oak spears, this means that if you are going to build a group it should have armor. Armor is, pound for pound, more important than attack. A unit can attack between three and six times in a turn. It can receive between three and twenty four attacks per turn, although six to nine is more likely for a unit. Back of the envelope calculation I use is a 2h weapon must provide at least atk => 2xshield def + 1h weap for me to take it. When the 2h == the adjusted damage of the 1h, I go with the cheaper option -- which is why the war staff is so superior to the mace+shield combo! It costs far less and provides an equivalent amount of utility!
If you had had a properly built unit at your tech level, it would have been 9x4 24 atk, 5x4 20 def. You would have roflstomped the AI with that unit.
You didn't build a study until you had a farm, a beacon, a hut and a workshop! This despite having, what, 15-20 materials? Plus several unexploited goodie huts nearby? That means you went 3+5+5+5+5 == 23 turns without a single point of research. Optimal build would have been hut + workshop, which would have put you at 10 turns, giving you an extra tech level.
You didn't explore before settling! Really, this is a Monty Hall problem, the right answer is always to switch unless you've got a gold mine, an iron mine and two food resources right on top of you. A refugee camp is, if I recall, worth 100 citizens, and a basic hut only holds 20 people. Since the SOP is three huts in the capital, moving towards it would have saved you 15 turns worth of building and 9 units of materials. This would have allowed you to start researching another 5 turns in advance, putting you a tech and a half ahead of the AI at minimum.
I don't know how many cities you had, but it looked like only two. If you have only two cities by the time you're pumping out munits, your priorities are wrong. Furthermore, based on the quick look at your late video city I'd say specialization was not a priority.
Alrighty then, I now feel like Super Douche. I hope that that helps with future AI builds.