101 protected LinkedHashMap<MarketAPI, LuddicPathCellsIntel>
cells =
new LinkedHashMap<MarketAPI, LuddicPathCellsIntel>();
108 List<Pair<MarketAPI, Float>> marketAndScore =
new ArrayList<Pair<MarketAPI,Float>>();
110 for (MarketAPI market :
Global.
getSector().getEconomy().getMarketsCopy()) {
111 if (market.getEconGroup() !=
null)
continue;
112 if (market.getSize() < 4)
continue;
115 if (score >= minInterest) {
116 marketAndScore.add(
new Pair<MarketAPI, Float>(market, score));
120 int numActive = Math.round(total * fraction);
121 int numSleeper = numActive;
126 LinkedHashSet<MarketAPI>
active =
new LinkedHashSet<MarketAPI>();
127 LinkedHashSet<MarketAPI> sleeper =
new LinkedHashSet<MarketAPI>();
130 Collections.sort(marketAndScore,
new Comparator<Pair<MarketAPI, Float>>() {
131 public int compare(Pair<MarketAPI, Float> o1, Pair<MarketAPI, Float> o2) {
132 return (
int) Math.signum(o2.two - o1.two);
137 for (Pair<MarketAPI, Float> p : marketAndScore) {
138 if (count < numActive) {
140 }
else if (count < numActive + numSleeper) {
149 for (MarketAPI market :
new ArrayList<MarketAPI>(
cells.keySet())) {
152 if (!
active.contains(market) && !sleeper.contains(market)) {
164 cells.remove(market);
167 List<MarketAPI> sleeperList =
new ArrayList<MarketAPI>(sleeper);
168 for (
int i = sleeperList.size() - 1; i >= 0; i--) {
169 MarketAPI other = sleeperList.get(i);
171 if (otherIntel !=
null)
continue;
173 sleeper.remove(other);
178 List<MarketAPI> activeList =
new ArrayList<MarketAPI>(
active);
179 for (
int i = activeList.size() - 1; i >= 0; i--) {
180 MarketAPI other = activeList.get(i);
182 if (otherIntel !=
null)
continue;
195 for (MarketAPI market :
active) {
200 cells.put(market, intel);
209 for (MarketAPI market : sleeper) {
213 cells.put(market, intel);
220 if (market.getFactionId().equals(Factions.LUDDIC_PATH))
return 0f;
223 String aiCoreId = market.getAdmin().getAICoreId();
224 if (aiCoreId !=
null) {
228 for (Industry ind : market.getIndustries()) {
229 total += ind.getPatherInterest();
233 total +=
new Random(market.getName().hashCode()).nextFloat() * 0.1f;
236 if (market.getFactionId().equals(Factions.LUDDIC_CHURCH)) {
268 WeightedRandomPicker<StarSystemAPI> far =
new WeightedRandomPicker<StarSystemAPI>(
random);
269 WeightedRandomPicker<StarSystemAPI> picker =
new WeightedRandomPicker<StarSystemAPI>(
random);
272 if (system.hasTag(Tags.THEME_SPECIAL))
continue;
273 if (system.hasTag(Tags.THEME_HIDDEN))
continue;
275 float days =
Global.
getSector().getClock().getElapsedDaysSince(system.getLastPlayerVisitTimestamp());
276 if (days < 45f)
continue;
281 if (system.hasTag(Tags.THEME_MISC_SKIP)) {
283 }
else if (system.hasTag(Tags.THEME_MISC)) {
285 }
else if (system.hasTag(Tags.THEME_REMNANT_NO_FLEETS)) {
287 }
else if (system.hasTag(Tags.THEME_RUINS)) {
289 }
else if (system.hasTag(Tags.THEME_CORE_UNPOPULATED)) {
292 if (weight <= 0f)
continue;
294 float usefulStuff = system.getCustomEntitiesWithTag(Tags.OBJECTIVE).size() +
295 system.getCustomEntitiesWithTag(Tags.STABLE_LOCATION).size();
296 if (usefulStuff <= 0)
continue;
298 if (Misc.hasPulsar(system))
continue;
299 if (Misc.getMarketsInLocation(system).size() > 0)
continue;
301 float dist = system.getLocation().length();
311 far.add(system, weight * usefulStuff * distMult);
313 picker.add(system, weight * usefulStuff * distMult);
317 if (picker.isEmpty()) {
321 return picker.pick();