@Subscribe public void handleGameLoad(GameStateChange gameStateChange) { if (gameStateChange.getStatusChange() == EGameStatusChange.GAME_LOADED) { int nbShips = 0; for (IAIPlayer player : aiPlayers) { nbShips += player.getFleet().size(); } for (IPlayer player : players) { nbShips += player.getFleet().size(); } updateSegmentSize(nbShips); } } }
@Override public boolean isSelectable(IAIPlayer player, INavigableVessel vessel) { // There are at least 4 ships if (player.getFleet().size() < 4) { return false; } List<ICity> citiesWithTradingOffice = map.getAllReachableCities(vessel).stream() .filter(city -> player.findTradingOffice(city).isPresent()) .collect(Collectors.toList()); // This city should not yet be supplied for (ICity city : citiesWithTradingOffice) { List<ITradeStategyHint> hints = player.getPlayerContext().getHints(city); for (ITradeStategyHint hint : hints) { if (hint instanceof CentralStorageStrategyHint) { CentralStorageHintContext hintContext = (CentralStorageHintContext) hint.getContext(); return hintContext.getDistributingVessels().isEmpty(); } } } return false; } }
@Override public boolean isSelectable(IAIPlayer player, INavigableVessel vessel) { // There are at least 4 ships if (player.getFleet().size() < 4) { return false; } List<ICity> citiesWithTradingOffice = map.getAllReachableCities(vessel).stream() .filter(city -> player.findTradingOffice(city).isPresent()) .collect(Collectors.toList()); // This city should not yet be supplied for (ICity city : citiesWithTradingOffice) { List<ITradeStategyHint> hints = player.getPlayerContext().getHints(city); for (ITradeStategyHint hint : hints) { if (hint instanceof CentralStorageStrategyHint) { CentralStorageHintContext hintContext = (CentralStorageHintContext) hint.getContext(); return hintContext.getSupplyingVessels().isEmpty(); } } return true; } return false; } }
@Override public EShipType shouldBuildShipType(IAIPlayer player) { // Which ships can be built in hometown ICity where = getBuildLocation(player); List<EShipType> shipTypes = new ArrayList<>(Arrays.asList(where.getCityState().getShipyardState().getBuildableShipTypes())); int fleetCapacity = getFleetCapacity(player.getFleet()); int maxTotalCargoCapacity = getMaxTotalCargoCapacity(); double capacityOfMaxPercent = fleetCapacity *1.0 / maxTotalCargoCapacity; // if total capacity is below 70% of the max capacity => Holk if (capacityOfMaxPercent >= 0.7) { return biggestShipType(shipTypes); } // if total capacity is below 30% of the max capacity => Cog if (capacityOfMaxPercent <= 0.3) { shipTypes.remove(EShipType.HOLK); } // if total capacity is below 10% of the max capacity => Crayer if (capacityOfMaxPercent <= 0.1) { shipTypes.remove(EShipType.COG); } // if total capacity is below 5% of the max capacity => Snaikka if (capacityOfMaxPercent <= 0.05) { shipTypes.remove(EShipType.CRAYER); } return biggestShipType(shipTypes); }
return false; List<IShip> fleet = player.getFleet(); if (fleet.size() >= maxFeetSize) { return false;
IProductionConsumptionKnowledge knowlege = player.getProductionAndConsumptionKnowledge(); knowlege.updateKnowledge(hometown); List<IShip> shipList = player.getFleet(); for (IShip ship : shipList) { try {
ITradeStep buy = tradeStepFactory.createAggregatedBuyTradingOfficeTradeStep(office, hometown, wares); buy.execute(); INavigableVessel nearestVessel = player.getFleet().get(0); double minDistance = Double.MAX_VALUE; Point2D coord = hometown.getCoordinates();