Esempio n. 1
0
    def checkTurn(self, iGameTurn):

        #turn automatically peace on between independent cities and all the major civs
        if (iGameTurn % 20 == 0):
            utils.restorePeaceHuman(iIndependent4, False)
        if (iGameTurn % 20 == 5):
            utils.restorePeaceHuman(iIndependent3, False)
        if (iGameTurn % 20 == 10):
            utils.restorePeaceHuman(iIndependent2, False)
        if (iGameTurn % 20 == 20):
            utils.restorePeaceHuman(iIndependent1, False)

        if (iGameTurn % 20 == 1 and iGameTurn > 40):
            utils.restorePeaceAI(iIndependent1, False)
        if (iGameTurn % 20 == 6 and iGameTurn > 40):
            utils.restorePeaceAI(iIndependent2, False)
        if (iGameTurn % 20 == 11 and iGameTurn > 40):
            utils.restorePeaceAI(iIndependent3, False)
        if (iGameTurn % 20 == 16 and iGameTurn > 40):
            utils.restorePeaceAI(iIndependent4, False)

        #turn automatically war on between independent cities and some AI major civs
        if (iGameTurn % 20 == 2
                and iGameTurn > 40):  #1 turn after restorePeace()
            utils.minorWars(iIndependent1)
        if (iGameTurn % 20 == 7
                and iGameTurn > 40):  #1 turn after restorePeace()
            utils.minorWars(iIndependent2)
        if (iGameTurn % 20 == 12
                and iGameTurn > 40):  #1 turn after restorePeace()
            utils.minorWars(iIndependent3)
        if (iGameTurn % 20 == 17
                and iGameTurn > 40):  #1 turn after restorePeace()
            utils.minorWars(iIndependent4)

        if (iGameTurn == sd.getNextTurnAIWar()):

            iCiv, iTargetCiv = self.pickCivs()
            if (iTargetCiv >= 0 and iTargetCiv <= iNumTotalPlayers):
                self.initWar(iCiv, iTargetCiv, iGameTurn, iMaxInterval,
                             iMinInterval)
                return
            else:
                print("AIWars iTargetCiv missing", iCiv)
                iCiv, iTargetCiv = self.pickCivs()
                if (iTargetCiv >= 0 and iTargetCiv <= iNumTotalPlayers):
                    self.initWar(iCiv, iTargetCiv, iGameTurn, iMaxInterval,
                                 iMinInterval)
                    return
                else:
                    print("AIWars iTargetCiv missing again", iCiv)

            #make sure we don't miss this
            print("Skipping AIWar")
            sd.setNextTurnAIWar(iGameTurn + iMinInterval + gc.getGame(
            ).getSorenRandNum(iMaxInterval - iMinInterval, 'random turn'))
    def checkTurn(self, iGameTurn):

        #turn automatically peace on between independent cities and all the major civs
        if iGameTurn % 20 == 7:
            utils.restorePeaceHuman(iIndependent2, False)
        elif iGameTurn % 20 == 14:
            utils.restorePeaceHuman(iIndependent, False)
        if iGameTurn % 60 == 55 and iGameTurn > utils.getTurns(50):
            utils.restorePeaceAI(iIndependent, False)
        elif iGameTurn % 60 == 30 and iGameTurn > utils.getTurns(50):
            utils.restorePeaceAI(iIndependent2, False)
        #turn automatically war on between independent cities and some AI major civs
        if iGameTurn % 13 == 6 and iGameTurn > utils.getTurns(
                50):  #1 turn after restorePeace()
            utils.minorWars(iIndependent)
        elif iGameTurn % 13 == 11 and iGameTurn > utils.getTurns(
                50):  #1 turn after restorePeace()
            utils.minorWars(iIndependent2)
        if iGameTurn % 50 == 24 and iGameTurn > utils.getTurns(50):
            utils.minorWars(iCeltia)

        for tConquest in lConquests:
            self.checkConquest(tConquest)

        if iGameTurn == data.iNextTurnAIWar:
            self.planWars(iGameTurn)

        for iLoopPlayer in range(iNumPlayers):
            data.players[iLoopPlayer].iAggressionLevel = tAggressionLevel[
                iLoopPlayer] + gc.getGame().getSorenRandNum(
                    2, "Random aggression")
	def checkTurn(self, iGameTurn):

		print "Check AI wars"

		#turn automatically peace on between independent cities and all the major civs
		if iGameTurn % 20 == 7:
			utils.restorePeaceHuman(iIndependent2, False)
		elif iGameTurn % 20 == 14:
			utils.restorePeaceHuman(iIndependent, False)
		if iGameTurn % 60 == 55 and iGameTurn > utils.getTurns(50):
			utils.restorePeaceAI(iIndependent, False)
		elif iGameTurn % 60 == 30 and iGameTurn > utils.getTurns(50):
			utils.restorePeaceAI(iIndependent2, False)
		#turn automatically war on between independent cities and some AI major civs
		if iGameTurn % 13 == 6 and iGameTurn > utils.getTurns(50): #1 turn after restorePeace()
			utils.minorWars(iIndependent)
		elif iGameTurn % 13 == 11 and iGameTurn > utils.getTurns(50): #1 turn after restorePeace()
			utils.minorWars(iIndependent2)
		if iGameTurn % 50 == 24 and iGameTurn > utils.getTurns(50):
			utils.minorWars(iCeltia)
			utils.minorWars(iSeljuks)
		
		self.checkConquest(tConquestGreeceMesopotamia)
		self.checkConquest(tConquestGreeceEgypt)
		self.checkConquest(tConquestGreecePersia, tConquestGreeceMesopotamia)
		
		self.checkConquest(tConquestRomeCarthage)
		self.checkConquest(tConquestRomeGreece)
		self.checkConquest(tConquestRomeAnatolia, tConquestRomeGreece)
		self.checkConquest(tConquestRomeCelts)
		self.checkConquest(tConquestRomeEgypt)
		
		self.checkConquest(tConquestSpainMoors)
		
		if iGameTurn == data.iNextTurnAIWar:
			self.planWars(iGameTurn)
			
		for iLoopPlayer in range(iNumPlayers):
			data.players[iLoopPlayer].iAggressionLevel = tAggressionLevel[iLoopPlayer] + gc.getGame().getSorenRandNum(2, "Random aggression")
Esempio n. 4
0
	def checkTurn(self, iGameTurn):

		print "Check AI wars"

		#turn automatically peace on between independent cities and all the major civs
		if iGameTurn % 20 == 7:
			utils.restorePeaceHuman(iIndependent2, False)
		elif iGameTurn % 20 == 14:
			utils.restorePeaceHuman(iIndependent, False)
		if iGameTurn % 60 == 55 and iGameTurn > utils.getTurns(50):
			utils.restorePeaceAI(iIndependent, False)
		elif iGameTurn % 60 == 30 and iGameTurn > utils.getTurns(50):
			utils.restorePeaceAI(iIndependent2, False)
		#turn automatically war on between independent cities and some AI major civs
		if iGameTurn % 13 == 6 and iGameTurn > utils.getTurns(50): #1 turn after restorePeace()
			utils.minorWars(iIndependent)
		elif iGameTurn % 13 == 11 and iGameTurn > utils.getTurns(50): #1 turn after restorePeace()
			utils.minorWars(iIndependent2)
		if iGameTurn % 50 == 24 and iGameTurn > utils.getTurns(50):
			utils.minorWars(iCeltia)
			utils.minorWars(iSeljuks)
		
		self.checkConquest(tConquestGreeceMesopotamia)
		self.checkConquest(tConquestGreeceEgypt)
		self.checkConquest(tConquestGreecePersia, tConquestGreeceMesopotamia)
		
		self.checkConquest(tConquestRomeCarthage)
		self.checkConquest(tConquestRomeGreece)
		self.checkConquest(tConquestRomeAnatolia, tConquestRomeGreece)
		self.checkConquest(tConquestRomeCelts)
		self.checkConquest(tConquestRomeEgypt)
		
		self.checkConquest(tConquestSpainMoors)
		
		if iGameTurn == data.iNextTurnAIWar:
			self.planWars(iGameTurn)
			
		for iLoopPlayer in range(iNumPlayers):
			data.players[iLoopPlayer].iAggressionLevel = tAggressionLevel[iLoopPlayer] + gc.getGame().getSorenRandNum(2, "Random aggression")
    def checkTurn(self, iGameTurn):
        #checkturn入口
        #a=PlayerTypes.NO_PLAYER
        #a=gc.AI_considerOfferThreshold(4,13)
        #utils.show(str(a))
        #a=gc.CvPlayerAI().AI_considerOffer_Threshold()
        #gc = CyGlobalContext()
        #a=gc.getPlayer(0).AI_considerOffer_Threshold()
        #utils.show(str(gc.getMAX_PLAYERS()))
        #import TradeUtil
        #a=TradeUtil.getTradeableBonuses111(14,3)#3是中国,14是拜占庭,在AD1700剧本中均存活
        #utils.show(str(a))
        #utils.show(str(TradeUtil.canTrade(13,3)))
        #BugUtil.logToScreen('aa')#可以使用
        #DiplomacyUtil.onTributeDemanded(1,12,0)#回调函数,失败了
        #a=CvTeamAI().AI_isWarPossible()   #utils.show(str(gc.getPlayer(3).getDemandTributeAttitudeThreshold()))
        ###import MapDrawer
        ###MapDrawer.createMaps()  #事实证明这个函数没什么用,生成一堆数组
        #入口结束
        #turn automatically peace on between independent cities and all the major civs
        if iGameTurn % 20 == 7:
            utils.restorePeaceHuman(iIndependent2, False)
        elif iGameTurn % 20 == 14:
            utils.restorePeaceHuman(iIndependent, False)
        if iGameTurn % 60 == 55 and iGameTurn > utils.getTurns(50):
            utils.restorePeaceAI(iIndependent, False)
        elif iGameTurn % 60 == 30 and iGameTurn > utils.getTurns(50):
            utils.restorePeaceAI(iIndependent2, False)
        #turn automatically war on between independent cities and some AI major civs
        if iGameTurn % 13 == 6 and iGameTurn > utils.getTurns(
                50):  #1 turn after restorePeace()
            utils.minorWars(iIndependent)
        elif iGameTurn % 13 == 11 and iGameTurn > utils.getTurns(
                50):  #1 turn after restorePeace()
            utils.minorWars(iIndependent2)
        if iGameTurn % 50 == 24 and iGameTurn > utils.getTurns(50):
            utils.minorWars(iCeltia)

        for tConquest in lConquests:
            self.checkConquest(tConquest)

        if iGameTurn == data.iNextTurnAIWar:
            self.planWars(iGameTurn)

        for iLoopPlayer in range(iNumPlayers):
            data.players[iLoopPlayer].iAggressionLevel = tAggressionLevel[
                iLoopPlayer] + gc.getGame().getSorenRandNum(
                    2, "Random aggression")
    def checkTurn(self, iGameTurn):

        iHuman = utils.getHumanID()

        #turn automatically peace on between independent cities and all the major civs
        if (iGameTurn % 20 == 5):
            utils.restorePeaceHuman(iIndependent3, False)
        if (iGameTurn % 20 == 10):
            utils.restorePeaceHuman(iIndependent2, False)
        if (iGameTurn % 20 == 20):
            utils.restorePeaceHuman(iIndependent, False)

        if (iGameTurn % 20 == 1 and iGameTurn > 40):
            utils.restorePeaceAI(iIndependent, False)
        if (iGameTurn % 20 == 6 and iGameTurn > 40):
            utils.restorePeaceAI(iIndependent2, False)
        if (iGameTurn % 20 == 11 and iGameTurn > 40):
            utils.restorePeaceAI(iIndependent3, False)

        #turn automatically war on between independent cities and some AI major civs
        if (iGameTurn % 20 == 2
                and iGameTurn > 40):  #1 turn after restorePeace()
            utils.minorWars(iIndependent)
        if (iGameTurn % 20 == 7
                and iGameTurn > 40):  #1 turn after restorePeace()
            utils.minorWars(iIndependent2)
        if (iGameTurn % 20 == 12
                and iGameTurn > 40):  #1 turn after restorePeace()
            utils.minorWars(iIndependent3)

        # just another AI war function
        if iGameTurn % 7 == 0 and iGameTurn > 0:
            print "AI War function"
            for iLoopPlayer in range(iNumPlayers):
                iCiv = sd.getCivilization(iLoopPlayer)
                # alive, not human, not at war, 10 turns after spawn
                if iLoopPlayer != iHuman and gc.getPlayer(iLoopPlayer).isAlive(
                ) and iGameTurn > con.tBirth[iCiv]:
                    print("iLoopPlayer", iLoopPlayer)
                    if utils.getWarCount(iLoopPlayer) != 0:
                        print "already at war"
                    else:
                        # has a target
                        if sd.getWarTarget(iLoopPlayer, 0) != -1:
                            print "has a target"
                            # target is due
                            if iGameTurn >= sd.getWarTarget(iLoopPlayer, 1):
                                print "target is due"
                                # reset if dead or vassal
                                if not (gc.getPlayer(
                                        sd.getWarTarget(iLoopPlayer, 0)).
                                        isAlive()) or not utils.canDeclareWar(
                                            iLoopPlayer,
                                            sd.getWarTarget(iLoopPlayer, 0)):
                                    print "dead or vassal"
                                    sd.setWarTarget(iLoopPlayer, 0, -1)
                                # else declare war
                                elif sd.getWarTarget(iLoopPlayer, 2) == True:
                                    print("declare total war, target=",
                                          sd.getWarTarget(iLoopPlayer, 0))
                                    gc.getTeam(
                                        gc.getPlayer(
                                            iLoopPlayer).getTeam()).declareWar(
                                                sd.getWarTarget(
                                                    iLoopPlayer, 0), True,
                                                WarPlanTypes.WARPLAN_TOTAL)
                                    sd.setWarTarget(iLoopPlayer, 0, -1)
                                    break
                                else:
                                    print("declare limited war, target=",
                                          sd.getWarTarget(iLoopPlayer, 0))
                                    gc.getTeam(
                                        gc.getPlayer(
                                            iLoopPlayer).getTeam()).declareWar(
                                                sd.getWarTarget(
                                                    iLoopPlayer, 0), True,
                                                WarPlanTypes.WARPLAN_LIMITED)
                                    sd.setWarTarget(iLoopPlayer, 0, -1)
                                    break
                            # target not yet due
                            else:
                                print "target not yet due"
                                continue
                        # has no target
                        else:
                            print "no target, checking"
                            self.checkAIWars(iLoopPlayer, iGameTurn)