From: <dil...@us...> - 2013-09-07 19:24:13
|
Revision: 6405 http://sourceforge.net/p/freeorion/code/6405 Author: dilvish-fo Date: 2013-09-07 19:24:10 +0000 (Sat, 07 Sep 2013) Log Message: ----------- some AI code cleanup Modified Paths: -------------- trunk/FreeOrion/default/AI/AIstate.py trunk/FreeOrion/default/AI/FleetUtilsAI.py trunk/FreeOrion/default/AI/ProductionAI.py trunk/FreeOrion/default/AI/ResearchAI.py Modified: trunk/FreeOrion/default/AI/AIstate.py =================================================================== --- trunk/FreeOrion/default/AI/AIstate.py 2013-09-07 19:06:19 UTC (rev 6404) +++ trunk/FreeOrion/default/AI/AIstate.py 2013-09-07 19:24:10 UTC (rev 6405) @@ -553,7 +553,7 @@ total_enemy_weights += count continue structure_tally += count * max(mystructure, min(estats.get('attacks', {})) - myshields ) # - eshields = enemystats.get('shields', 0) + eshields = enemy_stats.get('shields', 0) tempattacktally=0 tempstruc = estats.get('structure', 1) total_enemy_weights += count * tempstruc Modified: trunk/FreeOrion/default/AI/FleetUtilsAI.py =================================================================== --- trunk/FreeOrion/default/AI/FleetUtilsAI.py 2013-09-07 19:06:19 UTC (rev 6404) +++ trunk/FreeOrion/default/AI/FleetUtilsAI.py 2013-09-07 19:24:10 UTC (rev 6405) @@ -8,7 +8,6 @@ __AIFleetMissionTypeNames = AIFleetMissionType() def clearShipDesignInfo(): - __designRoles.clear() __designStats.clear() def statsMeetReq(stats, reqs, reqName): Modified: trunk/FreeOrion/default/AI/ProductionAI.py =================================================================== --- trunk/FreeOrion/default/AI/ProductionAI.py 2013-09-07 19:06:19 UTC (rev 6404) +++ trunk/FreeOrion/default/AI/ProductionAI.py 2013-09-07 19:24:10 UTC (rev 6405) @@ -960,7 +960,7 @@ res=fo.issueRequeueProductionOrder(productionQueue.size -1, 0) # move to front print "Requeueing %s to front of build queue, with result %d"%(bldName, res) except: - print "problem queueing BLD_SOL_ORB_GEN at planet", useloc, "of system ", useSys + print "problem queueing BLD_SOL_ORB_GEN at planet", useLoc, "of system ", useSys pass bldName = "BLD_ART_BLACK_HOLE" @@ -1005,7 +1005,7 @@ res=fo.issueRequeueProductionOrder(productionQueue.size -1, 0) # move to front print "Requeueing %s to front of build queue, with result %d"%(bldName, res) except: - print "problem queueing %s at planet"%bldName, useloc, "of system ", useSys + print "problem queueing %s at planet"%bldName, useLoc, "of system ", useSys bldName = "BLD_BLACK_HOLE_POW_GEN" if empire.buildingTypeAvailable(bldName) and foAI.foAIstate.aggression > fo.aggression.cautious: @@ -1036,7 +1036,7 @@ res=fo.issueRequeueProductionOrder(productionQueue.size -1, 0) # move to front print "Requeueing %s to front of build queue, with result %d"%(bldName, res) except: - print "problem queueing BLD_BLACK_HOLE_POW_GEN at planet", useloc, "of system ", useSys + print "problem queueing BLD_BLACK_HOLE_POW_GEN at planet", useLoc, "of system ", useSys pass bldName = "BLD_ENCLAVE_VOID" @@ -1109,7 +1109,7 @@ res=fo.issueRequeueProductionOrder(productionQueue.size -1, 0) # move to front print "Requeueing %s to front of build queue, with result %d"%(bldName, res) except: - print "problem queueing BLD_NEUTRONIUM_EXTRACTOR at planet", useloc, "of system ", useSys + print "problem queueing BLD_NEUTRONIUM_EXTRACTOR at planet", useLoc, "of system ", useSys pass bldName = "BLD_NEUTRONIUM_FORGE" Modified: trunk/FreeOrion/default/AI/ResearchAI.py =================================================================== --- trunk/FreeOrion/default/AI/ResearchAI.py 2013-09-07 19:06:19 UTC (rev 6404) +++ trunk/FreeOrion/default/AI/ResearchAI.py 2013-09-07 19:24:10 UTC (rev 6405) @@ -213,88 +213,6 @@ idx = researchQueueList.index("SHP_WEAPON_4_2") res=fo.issueEnqueueTechOrder("SHP_WEAPON_4_2", max(0, idx-15) ) -def generateResearchOrders_old(): - "generate research orders" - - empire = fo.getEmpire() - print "Research Queue Management:" - print "" - print "Techs researched and available for use:" - completedTechs = getCompletedTechs() - for techname in completedTechs: - print " " + techname - print"" - - print "Techs currently in Research Queue:" - researchQueue = empire.researchQueue - researchQueueList = getResearchQueueTechs() - for element in researchQueue: - print " " + element.tech - print "" - - # get the highest research priorities - print "Research Queue Priorities:" - researchPriorities = {} - for priorityType in getAIPriorityResearchTypes(): - researchPriorities[priorityType] = foAI.foAIstate.getPriority(priorityType) - - sortedPriorities = researchPriorities.items() - sortedPriorities.sort(lambda x,y: cmp(x[1], y[1]), reverse=True) - topPriority = -1 - for evaluationPair in sortedPriorities: - if topPriority < 0: - topPriority = evaluationPair[0] - print " ID|Score: " + str(evaluationPair) - - print " Top Research Queue Priority: " + str(topPriority) - print "" - - if topPriority == AIPriorityType.PRIORITY_RESEARCH_LEARNING: - primaryLearningTechs = TechsListsAI.primaryLearningTechsList() - pLTsToEnqueue = (set(primaryLearningTechs)-(set(completedTechs)|set(researchQueueList))) - if not pLTsToEnqueue: - print "All primaryLearningTechs are enqueued or completed." - print"" - generateDefaultResearchOrders() - else: - for name in pLTsToEnqueue: - fo.issueEnqueueTechOrder(name, -1) - print " Enqueued Tech: " + name - print"" - generateDefaultResearchOrders() - elif topPriority == AIPriorityType.PRIORITY_RESEARCH_GROWTH: - primaryGroTechs = TechsListsAI.primaryGroTechsList() - pGTsToEnqueue = (set(primaryGroTechs)-(set(completedTechs)|set(researchQueueList))) - if not pGTsToEnqueue: - print "All primaryGrowthTechs are enqueued or completed." - print"" - generateDefaultResearchOrders() - else: - for name in pGTsToEnqueue: - fo.issueEnqueueTechOrder(name, -1) - print " Enqueued Tech: " + name - print "" - generateDefaultResearchOrders() - elif topPriority == AIPriorityType.PRIORITY_RESEARCH_PRODUCTION: - generateDefaultResearchOrders() - elif topPriority == AIPriorityType.PRIORITY_RESEARCH_CONSTRUCTION: - generateDefaultResearchOrders() - elif topPriority == AIPriorityType.PRIORITY_RESEARCH_ECONOMICS: - generateDefaultResearchOrders() - elif topPriority == AIPriorityType.PRIORITY_RESEARCH_SHIPS: - primaryShipsTechs = TechsListsAI.primaryShipsTechsList() - pSTsToEnqueue = (set(primaryShipsTechs)-(set(completedTechs)|set(researchQueueList))) - if not pSTsToEnqueue: - print "All primaryShipsTechs are enqueued or completed." - generateDefaultResearchOrders() - print "" - else: - for name in pSTsToEnqueue: - fo.issueEnqueueTechOrder(name, -1) - print " Enqueued Tech: " + name - print "" - generateDefaultResearchOrders() - def generateDefaultResearchOrders(): "generate default research orders" |