private Tech AIBaseSelectNextTech( StrategicAI ai, List <PlayerTechInfo> desiredTech = null, Dictionary <string, int> familyWeights = null) { Tech tech = (((Tech)null ?? this.AISelectPartialTech(ai)) ?? AIResearchFramework.AISelectBinaryResponseTech(ai)) ?? this.AISelectDefaultTech(ai, desiredTech, familyWeights); Tech researchingTech = AIResearchFramework.AIGetResearchingTech(ai); if (tech != null && tech != researchingTech) { if (this._log != null) { if (researchingTech != null) { this._log.Print(string.Format("\n >>> {0} (replacing {1})\n", (object)tech.Id, (object)researchingTech.Id)); } else { this._log.Print(string.Format("\n >>> {0}\n", (object)tech.Id)); } } return(tech); } if (this._log != null) { this._log.ClearRecord(); } return((Tech)null); }
private Tech AISelectPartialTech(StrategicAI ai) { Tech tech1 = (Tech)null; if (AIResearchFramework.AIGetResearchingTech(ai) == null) { List <Tech> techList = AIResearchFramework.AISelectAvailableTechs(ai, new AIResearchModes?(), new TechFamilies?()); if (techList.Count > 0) { int num = 0; foreach (Tech tech2 in techList) { int techProgress = AIResearchFramework.AIGetTechProgress(ai, tech2); if (techProgress > num) { num = techProgress; tech1 = tech2; } } } } if (this._log != null && tech1 != null) { this._log.Print(string.Format("Resuming {0}", (object)tech1.Id)); } return(tech1); }
private static bool AICanSelectBinaryResponseTech(StrategicAI ai) { Tech researchingTech = AIResearchFramework.AIGetResearchingTech(ai); if (researchingTech != null) { return(AIResearchFramework.AIGetTurnsToComplete(ai, researchingTech) > 5); } return(true); }
private Tech AISelectDefaultTech( StrategicAI ai, List <PlayerTechInfo> desiredTech = null, Dictionary <string, int> familyWeights = null) { if (this._log != null) { this._log.Print("{"); bool flag = true; foreach (AITechStyleInfo techStyleInfo in ai.TechStyles.TechStyleInfos) { if (!flag) { this._log.Print(","); } else { flag = false; } this._log.Print(techStyleInfo.TechFamily.ToString()); } this._log.Print("}"); } Tech tech1 = (Tech)null; if (AIResearchFramework.AIGetResearchingTech(ai) == null && tech1 == null) { AIStance stance = this.AIGetStance(ai); int phase = this.AIGetPhase(ai); List <AIResearchModes> phasedRhythm = this.AIGetPhasedRhythm(this.AIGetRhythm(stance), phase); IEnumerable <AIResearchFramework.TechBeat> prospects = this.AIGetProspects(ai, this.AIGetTechBeats(this.AIGetAvailableTechs(ai), phasedRhythm, (List <PlayerTechInfo>)null)); List <AIResearchFramework.TechBeat> culledProspects = this.AIGetCulledProspects(ai, prospects); if (this._log != null) { this._log.Print(string.Format(" (phase {0}) {1}/{2} prospects: ", (object)phase, (object)AIResearchFramework.AIGetResearchModeSymbol(phasedRhythm[0]), (object)stance)); this.LogProspects(ai, (IList <AIResearchModes>)phasedRhythm, (IEnumerable <AIResearchFramework.TechBeat>)culledProspects); if (App.Log.Level >= Kerberos.Sots.Engine.LogLevel.Verbose) { this._log.Print(string.Format(" ... (phase {0}) {1}/{2} ALL prospects: ", (object)phase, (object)AIResearchFramework.AIGetResearchModeSymbol(phasedRhythm[0]), (object)stance)); this.LogProspects(ai, (IList <AIResearchModes>)phasedRhythm, prospects); } } if (culledProspects.Any <AIResearchFramework.TechBeat>()) { if (desiredTech != null && culledProspects.Any <AIResearchFramework.TechBeat>((Func <AIResearchFramework.TechBeat, bool>)(x => desiredTech.Any <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(y => y.TechFileID == x.Tech.Id))))) { culledProspects.RemoveAll((Predicate <AIResearchFramework.TechBeat>)(x => !desiredTech.Any <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(y => y.TechFileID == x.Tech.Id)))); } if (familyWeights != null) { List <Weighted <Tech> > weightedList = new List <Weighted <Tech> >(); foreach (Tech tech2 in culledProspects.Select <AIResearchFramework.TechBeat, Tech>((Func <AIResearchFramework.TechBeat, Tech>)(x => x.Tech)).ToList <Tech>()) { int num; if (familyWeights.TryGetValue(tech2.Family, out num)) { weightedList.Add(new Weighted <Tech>() { Value = tech2, Weight = num }); } } if (weightedList.Count > 0) { tech1 = WeightedChoices.Choose <Tech>(ai.Random, (IEnumerable <Weighted <Tech> >)weightedList); } } if (tech1 == null) { tech1 = ai.Random.Choose <AIResearchFramework.TechBeat>((IList <AIResearchFramework.TechBeat>)culledProspects).Tech; } } } return(tech1); }