Fixed a rare bug in AI_cityTradeVal which could cause a seg-fault.

When evaluating bonuses, AI_cityTradeVal wasn't checking if the bonus
could be seen by the other team before evaluating what the other team
could see - and since AI_bonusVal assumes the argument isn't NO_BONUS,
this could cause a seg-fault or an unpredictable evaluation.

This bug was due to my previous changes.
Corrected a mistake in the final spread condition of AI_bestReligion.

The calculation of the extent that the religion has spread was using the
maximum of the target cities and the player's cities, which meant that
players with fewer cities than the target may be unable to reach the
spread requirements even if the religion was in all of their cities.

I've changed it to use the _minimum_, of
(1.5*target cities + 1, current cities + 1).
Byzantine hippodromes now allow two artists.

Before this change, the hippodrome was the only unique building which
had a disadvantage over the base building. I've changed it to allow two
artists so that it matches theatres and other theatre replacements.

(This change removes some of the flavour of the building, but I think it
was a bit unfair that the byzantine couldn't get these artists.)
Fixed a mistake with essentially disabled the plot danger cache.

In my recent changes to the danger cache, I'd mistakenly told
CvPlayerAI::AI_getPlotDanger and AI_getAnyPlotDanger danger to set the
cache if iRange is smaller than the cached range rather than larger -
this basically meant that the cache was never used.
Corrected an inconsistency the move flags used in AI_greatPersonMove.

Invisible units (ie. great spies) were still using
MOVE_NO_ENEMY_TERRITORY when looking for 'slow' missions, but not when
actually executing those missions. This could create some pathfinding
inefficiency, and could potentially cause the invisible great person to
get stuck in enemy territory.

Also removed some danger / enemy unit checks. These checks shouldnt' be
applied to invisible units, and they're already handled in generatePath
anyway.

(The area check in this function is also already handled in generatePath
- but double-checking the area has become a kind of convention since
bbai erroneously decided efficiency would be improved by putting it
everywhere.)
Added some plot culture dependence to CvCity::getLiberationPlayer.

Originally the liberation player depended almost entirely on how far the
city is from the capitals of other players. I've tweaked this so that it
has some dependence on the plot culture as well - but the distance from
the capital is still the dominant component.

I've also replaced some large if blocks with if! continue conditions, to
flatten the code so that it is more readable (as is consistent with the
style I've used elsewhere).
Blocked CvCityAI::AI_bestUnit from considering some units for humans

Awhile back, I blocked CvCityAI::AI_bestUnit from considering certain
units types, including UNITAI_EXPLORE and WORKER, based on the fact that
the usual AI mechanisms choosing and avoiding those units don't work
properly for human players.

I've now added WORKER_SEA and EXPLORE_SEA to the list of blocked units.
Presumably I'd simply forgotten to include them last time. (And in the
mean time, automated city governors have been building far too many
EXPLORE_SEA units.)
Tweaked the 'free city culture' in CvCity::doPlotCultureTimes100

The free culture no longer requires that the real culture rate be
greater than zero. (I don't remember any justification for that
condition.)

To compensate for the addition free culture that otherwise cultureless
cities will now get, I've reduced the magnitude of the free culture from
600 to 400.
Made some style / structure adjustments to CvTeamAI::AI_doWar

Some huge 'if' blocks have been changed into 'if! continue', as is the
style I've been using in other parts of the code.

Some loop variables have been changed from ints to enums (and renamed),
for some additional type safety; CvPlayerAI references are now used in
place of GET_PLAYER in a few places.

The aim of these style adjustments is to make it easier to read the
code, to spot bugs and to implement future changes. Hopefully I didn't
make any mistakes while making these changes.
Fixed a minor bug in AI_doWar relating to automatic peace deals.

The bug was that when making a peace deal, 'break' was used instead of
'continue', which meant that the AI would ignore peace conditions with
other teams after making peace with any one team.

(This was a very long-standing bug from the original BtS code and bbai
code. The bug was made more obviously visible by my style adjustments.)
Adjusted CvTeamAI::AI_doWar to handle war preparations of vassals

Previously, war preparation strategies (WARPLAN_PREPARING_TOTAL /
LIMITED) were handled the same way for all teams. This doesn't make
sense for vassal teams however, as the vassal is unable to actually
declare war and so there is no sense in upgrading from
WARPLAN_PREPARING_TOTAL to WARPLAN_TOTAL. So instead this has been
changed so that vassals of human teams will have their warplans simply
time-out, and that vassals of AI teams will keep the warplans for as
long as their AI master does.

I've also made a tweak to CvTeam::declareWar so that prepare_total
becomes total when appropriate. I suspect this change will make no
difference whatsoever due to the conditions and circumstances that come
before it, but it's done now nevertheless.

(Note: currently this will have no effect, because vassals never use
those preparation warplans. However, I'm just about to implement changes
which allow players to tell their vassals to prepare for war, so it will
soon be important.)
CvTeam::canEventuallyDeclareWar is now exposed to Python.

I'll need this soon for diplomacy changes.
Players can now tell their AI allies start war preparations.

Human players can now tell their AI team members and AI vassals to start
preparing for war against a particular team. When used, the AI will
adopt WARPLAN_PREPARING_TOTAL, and when war is eventually declared this
will be changed to WARPLAN_TOTAL. There is also a diplomacy option to
tell these AI allies to cancel the war preparations.

(Note: if this feature is not used the AI will use WARPLAN_DOGPILE, as
usual. The AI cannot currently switch between different warplans once
war is declared.)

These changes includes new diplomacy options in the "let's discuss
something else screen", new text for these diplomacy options and AI
responses, and a new type of 'diplomacy event' to be handled by the DLL.

(Note: The new diplomacy text was translated by a computer, and I
haven't verified that it's correct or appropriate.)
Fixed a bug in the evaluation of prerequisite buildings.

The code to count how many cities could build the prereq was wrong,
because it was checking CvCity::canBuild for the wrong city. And there
was a similar mistake for the evaluation of the building that the prereq
was for.
CvSelectionGroupAI::AI_sumStrength now includes first strikes.

First strikes were ignored in this function. Now the effect of first
strikes is now estimated in the same way as in AI_localAttackStrength.
Blocked the AI from considering very early wars.

The AI will no longer consider starting a new war if less than 30 turns
have past (scaled by game speed based on 'ibarbPercent'), and if there
are fewer cities globally than half of the total cities target. ie.
Number of civs * target number of cities / 2. (Generally, I expect that
the turns limit will expire before the cities target is reached - except
perhaps in advanced start games, or in games where players start with
additional settlers or something like that.)

Note that in the original BtS AI there was a convoluted set of
conditions, based around AI_STRATEGY_GET_BETTER_UNITS, which prevented
the AI from starting early wars. Quite a long time ago I changed the
conditions of that AI strategy, and one of the side effects of my change
was that it no longer prevented early wars. That was an unintended side
effect, and so I'm addressing it now.
Fixed the effect of MOVE_IGNORE_DANGER in CvSelectionGroup::doTurn.

There was a typo which meant that units would use a reduced danger range
if they weren't meant to ignore danger, rather than using the reduced
range when they _were_ meant to ignore danger.
Fixed an invalid assert.

Barbarians can choose techs without having a city. I've weakened an
assert in AI_techBuildingValue to reflect this.
Made some structural changes to CvPlayerAI::AI_baseBonusVal

The motivation for these changes was that I wanted to make the AI's
resource trading a bit smarter. In particular, I wanted them to not
value strategic resources as highly if they already have another
resource to fulfil the same requirements. (eg. don't value copper as
highly if they already have iron.)

Unfortunately, after writing the changes I realised that they were
likely to cause OOS problems. So I've commented out the parts of the
code that I think could cause problems - and this means there is very
little functional difference from the original code. The only reason I'm
keeping the new code at all is that I might want to use it in the future
if I ever change the cache system such that OOS is no longer a problem.
Rewrote most of AI_assaultSeaTransport.

The AI will now be able to consider amphibious attack landings on
non-city plots. Previously the AI would never do this, and the fact that
it would never do it was easy for players to exploit.

The AI now uses a full strength comparison for evaluating their
amphibious attacks, rather than just counting units.

Added a generalised unit hash function, CvUnitAI::AI_unitBirthmarkHash,
for when we need a hash that depends on something other than a plot.
(ie. when we don't want to use AI_unitPlotHash.)