private void LogProspects( StrategicAI ai, IList <AIResearchModes> phasedRhythm, IEnumerable <AIResearchFramework.TechBeat> prospects) { if (this._log == null) { return; } foreach (AIResearchFramework.TechBeat prospect in prospects) { this._log.Print(string.Format("{0}/{1} ({2}{3}); ", (object)AIResearchFramework.AIGetResearchModeSymbol(phasedRhythm[prospect.Beat]), (object)prospect.Tech.Id, (object)AIResearchFramework.AICalcTechCost(ai, prospect.Tech), this.AIIsShortTermTech(ai, prospect.Tech) ? (object)"" : (object)"*")); } }
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); }
private Tech AISelectDefaultTechPass( StrategicAI ai, AIResearchModes?mode, TechFamilies?family) { List <Tech> list = AIResearchFramework.AISelectAvailableTechs(ai, mode, family).OrderBy <Tech, int>((Func <Tech, int>)(x => AIResearchFramework.AICalcTechCost(ai, x))).ToList <Tech>(); if (list.Count > 0) { list.Insert(0, list[0]); } if (this._log != null) { this._log.Print(string.Format(" {0} prospects: ", mode.HasValue ? (object)string.Format("{0}/{1}", (object)AIResearchFramework.AIGetResearchModeSymbol(mode.Value), (object)ai.Game.GameDatabase.GetAIInfo(ai.Player.ID).Stance.ToString()) : (object)"ALL")); foreach (Tech tech in list) { int num = AIResearchFramework.AICalcTechCost(ai, tech); this._log.Print(string.Format("{0} ({1}); ", (object)tech.Id, (object)num)); } } return(AIResearchFramework.AISelectFavoriteTech(ai, (IList <Tech>)list)); }