|
From: <mp...@us...> - 2012-01-23 09:16:03
|
Revision: 9576
http://freecol.svn.sourceforge.net/freecol/?rev=9576&view=rev
Author: mpope
Date: 2012-01-23 09:15:52 +0000 (Mon, 23 Jan 2012)
Log Message:
-----------
Improve choice of AI colony scout.
Modified Paths:
--------------
freecol/trunk/src/net/sf/freecol/server/ai/AIColony.java
Modified: freecol/trunk/src/net/sf/freecol/server/ai/AIColony.java
===================================================================
--- freecol/trunk/src/net/sf/freecol/server/ai/AIColony.java 2012-01-22 11:58:30 UTC (rev 9575)
+++ freecol/trunk/src/net/sf/freecol/server/ai/AIColony.java 2012-01-23 09:15:52 UTC (rev 9576)
@@ -110,6 +110,20 @@
private static final Set<GoodsType> fullExport = new HashSet<GoodsType>();
private static final Set<GoodsType> partExport = new HashSet<GoodsType>();
+ // Comparator to favour expert scouts, then units with the SCOUT role,
+ // then least skillful.
+ private static final Comparator<Unit> scoutComparator
+ = new Comparator<Unit>() {
+ public int compare(Unit u1, Unit u2) {
+ boolean a1 = u1.hasAbility("model.ability.expertScout");
+ boolean a2 = u2.hasAbility("model.ability.expertScout");
+ if (a1 != a2) return (a1) ? -1 : 1;
+ a1 = u1.getRole() == Unit.Role.SCOUT;
+ a2 = u2.getRole() == Unit.Role.SCOUT;
+ if (a1 != a2) return (a1) ? -1 : 1;
+ return u1.getType().getSkill() - u2.getType().getSkill();
+ }
+ };
/**
* Creates a new <code>AIColony</code>.
@@ -488,6 +502,7 @@
explorers.add(u);
}
}
+ Collections.sort(explorers, scoutComparator);
for (Tile t : tile.getSurroundingTiles(1)) {
if (t.hasLostCityRumour()) {
Direction direction = tile.getDirection(t);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|