def assess_ship_design_role(design): parts = [fo.getPartType(partname) for partname in design.parts if partname and fo.getPartType(partname)] if any(p.partClass == fo.shipPartClass.colony and p.capacity == 0 for p in parts): if design.speed > 0: return ShipRoleType.CIVILIAN_OUTPOST else: return ShipRoleType.BASE_OUTPOST if any(p.partClass == fo.shipPartClass.colony and p.capacity > 0 for p in parts): if design.speed > 0: return ShipRoleType.CIVILIAN_COLONISATION else: return ShipRoleType.BASE_COLONISATION if any(p.partClass == fo.shipPartClass.troops for p in parts): if design.speed > 0: return ShipRoleType.MILITARY_INVASION else: return ShipRoleType.BASE_INVASION if design.speed == 0: if not parts or parts[0].partClass == fo.shipPartClass.shields: # ToDo: Update logic for new ship designs return ShipRoleType.BASE_DEFENSE else: return ShipRoleType.INVALID stats = foAI.foAIstate.get_design_id_stats(design.id) rating = stats['attack'] * (stats['structure'] + stats['shields']) if rating > 0: # positive attack stat return ShipRoleType.MILITARY if any(p.partClass == fo.shipPartClass.detection for p in parts): return ShipRoleType.CIVILIAN_EXPLORATION else: # if no suitable role found, use as (bad) scout as it still has inherent detection return ShipRoleType.CIVILIAN_EXPLORATION
def assess_ship_design_role(design): parts = [fo.getPartType(partname) for partname in design.parts if partname and fo.getPartType(partname)] if any(p.partClass == fo.shipPartClass.colony and p.capacity == 0 for p in parts): if design.speed > 0: return AIShipRoleType.SHIP_ROLE_CIVILIAN_OUTPOST else: return AIShipRoleType.SHIP_ROLE_BASE_OUTPOST if any(p.partClass == fo.shipPartClass.colony and p.capacity > 0 for p in parts): if design.speed > 0: return AIShipRoleType.SHIP_ROLE_CIVILIAN_COLONISATION else: return AIShipRoleType.SHIP_ROLE_BASE_COLONISATION if any(p.partClass == fo.shipPartClass.troops for p in parts): if design.speed > 0: return AIShipRoleType.SHIP_ROLE_MILITARY_INVASION else: return AIShipRoleType.SHIP_ROLE_BASE_INVASION if design.speed == 0: if not parts or parts[0].partClass == fo.shipPartClass.shields: # ToDo: Update logic for new ship designs return AIShipRoleType.SHIP_ROLE_BASE_DEFENSE else: return AIShipRoleType.SHIP_ROLE_INVALID stats = foAI.foAIstate.get_design_id_stats(design.id) rating = stats['attack'] * (stats['structure'] + stats['shields']) if rating > 0: # positive attack stat return AIShipRoleType.SHIP_ROLE_MILITARY if any(p.partClass == fo.shipPartClass.detection for p in parts): return AIShipRoleType.SHIP_ROLE_CIVILIAN_EXPLORATION else: # if no suitable role found, use as (bad) scout as it still has inherent detection return AIShipRoleType.SHIP_ROLE_CIVILIAN_EXPLORATION
def inspect_ai_interface(): capital_id = PlanetUtilsAI.get_capital() universe = fo.getUniverse() fleets_int_vector = universe.fleetIDs fleet = universe.getFleet(list(fleets_int_vector)[0]) ship = universe.getShip(list(universe.shipIDs)[0]) design = fo.getShipDesign(ship.designID) empire = fo.getEmpire() tech = fo.getTech('SHP_WEAPON_2_1') tech_spec = list(tech.unlockedItems)[0] part_id = list(empire.availableShipParts)[0] part_type = fo.getPartType(part_id) prod_queue = empire.productionQueue fo.issueEnqueueShipProductionOrder( list(empire.availableShipDesigns)[0], capital_id) research_queue = empire.researchQueue fo.issueEnqueueTechOrder('SHP_WEAPON_1_2', -1) planet = universe.getPlanet(capital_id) building = list(planet.buildingIDs)[0] inspect( fo, universe, fleet, planet, universe.getSystem(planet.systemID), ship, empire, design, tech, tech_spec, fo.getFieldType('FLD_ION_STORM'), fo.getBuildingType('BLD_SHIPYARD_BASE'), fo.getGalaxySetupData(), fo.getHullType('SH_XENTRONIUM'), fo.getPartType('SR_WEAPON_1_1'), fo.getSpecial('MODERATE_TECH_NATIVES_SPECIAL'), fo.getSpecies('SP_ABADDONI'), fo.getTech('SHP_WEAPON_4_1'), fo.diplomaticMessage(1, 2, fo.diplomaticMessageType.acceptProposal), fleets_int_vector, part_type, prod_queue, prod_queue.allocatedPP, prod_queue[0], research_queue, research_queue[0], empire.getSitRep(0), universe.getBuilding(building), ) exit(1) # exit game to main menu no need to play anymore.
def inspect_FreeOrionAIInterface(): capital_id = PlanetUtilsAI.get_capital() universe = fo.getUniverse() fleets_int_vector = universe.fleetIDs fleet = universe.getFleet(list(fleets_int_vector)[0]) ship = universe.getShip(list(universe.shipIDs)[0]) design = fo.getShipDesign(ship.designID) empire = fo.getEmpire() tech = fo.getTech('SHP_WEAPON_2_1') tech_spec = list(tech.unlockedItems)[0] part_id = list(empire.availableShipParts)[0] part_type = fo.getPartType(part_id) prod_queue = empire.productionQueue fo.issueEnqueueShipProductionOrder(list(empire.availableShipDesigns)[0], capital_id) research_queue = empire.researchQueue fo.issueEnqueueTechOrder('SHP_WEAPON_1_2', -1) planet = universe.getPlanet(capital_id) building = list(planet.buildingIDs)[0] inspect( fo, universe, fleet, planet, universe.getSystem(planet.systemID), ship, empire, design, tech, tech_spec, fo.getFieldType('FLD_ION_STORM'), fo.getBuildingType('BLD_SHIPYARD_BASE'), fo.getGalaxySetupData(), fo.getHullType('SH_XENTRONIUM'), fo.getPartType('SR_WEAPON_1_1'), fo.getSpecial('MODERATE_TECH_NATIVES_SPECIAL'), fo.getSpecies('SP_ABADDONI'), fo.getTech('SHP_WEAPON_4_1'), fo.diplomaticMessage(1, 2, fo.diplomaticMessageType.acceptProposal), fleets_int_vector, part_type, prod_queue, prod_queue.allocatedPP, prod_queue[0], research_queue, research_queue[0], empire.getSitRep(0), universe.getBuilding(building), ) exit(1) # exit game to main menu no need to play anymore.
def inspect_ai_interface(): capital_id = PlanetUtilsAI.get_capital() universe = fo.getUniverse() fleets_int_vector = universe.fleetIDs fleet = universe.getFleet(list(fleets_int_vector)[0]) ship = universe.getShip(list(universe.shipIDs)[0]) design = fo.getShipDesign(ship.designID) empire = fo.getEmpire() tech = fo.getTech('SHP_WEAPON_2_1') tech_spec = list(tech.unlockedItems)[0] part_id = list(empire.availableShipParts)[0] part_type = fo.getPartType(part_id) prod_queue = empire.productionQueue fo.issueEnqueueShipProductionOrder(list(empire.availableShipDesigns)[0], capital_id) research_queue = empire.researchQueue fo.issueEnqueueTechOrder('SHP_WEAPON_1_2', -1) planet = universe.getPlanet(capital_id) building = list(planet.buildingIDs)[0] color = empire.colour part_meters = ship.partMeters meter = planet.getMeter(fo.meterType.population) inspect( fo, instances=[ meter, part_meters, color, universe, fleet, planet, universe.getSystem(planet.systemID), ship, empire, design, tech, tech_spec, fo.getFieldType('FLD_ION_STORM'), fo.getBuildingType('BLD_SHIPYARD_BASE'), fo.getGalaxySetupData(), fo.getHullType('SH_XENTRONIUM'), fo.getPartType('SR_WEAPON_1_1'), fo.getSpecial('MODERATE_TECH_NATIVES_SPECIAL'), fo.getSpecies('SP_ABADDONI'), fo.getTech('SHP_WEAPON_4_1'), fo.diplomaticMessage(1, 2, fo.diplomaticMessageType.acceptPeaceProposal), fleets_int_vector, part_type, prod_queue, prod_queue.allocatedPP, prod_queue[0], research_queue, research_queue[0], empire.getSitRep(0), universe.getBuilding(building) ], classes_to_ignore=( 'IntSet', 'StringSet', 'IntIntMap', 'ShipSlotVec', 'VisibilityIntMap', 'IntDblMap', 'IntBoolMap', 'ItemSpecVec', 'PairIntInt_IntMap', 'IntSetSet', 'StringVec', 'IntPairVec', 'IntFltMap', 'MeterTypeStringPair', 'MeterTypeMeterMap', 'universeObject', # this item cannot be get from generate orders 'diplomaticStatusUpdate', ), path='AI' ) exit(1) # exit game to main menu no need to play anymore.