public void MineralOptimizationByNikita(ResponseObservation observation, List <Action> actions) { var hatas = observation.Observation.RawData.Units.Where(d => d.UnitType == UnitTypes.HATCHERY && d.Alliance == Alliance.Self).ToList(); if (hatas.Count() < 2) { return; } foreach (var h in hatas) { if (h.AssignedHarvesters <= h.IdealHarvesters) { continue; } var boringHata = observation.Observation.RawData.Units.Where(d => d.UnitType == UnitTypes.HATCHERY && d.Alliance == Alliance.Self && d.IdealHarvesters > d.AssignedHarvesters).FirstOrDefault(); if (boringHata == null) { return; } var drones = observation.Observation.RawData.Units.Where(d => d.UnitType == UnitTypes.DRONE && d.Alliance == Alliance.Self); foreach (var d in drones) { if (IsNeightbors(d, h) && d.Orders.Where(a => a.AbilityId == 1183).Any()) { var bse = Bases.Where(b => b.BaseId == boringHata.Tag).FirstOrDefault(); Unit mineralSent = GetClosestMineral(observation, boringHata.Pos); var command = new ActionRawUnitCommand { AbilityId = 1183, TargetWorldSpacePos = new Point2D { X = mineralSent.Pos.X, Y = mineralSent.Pos.Y }, QueueCommand = true, TargetUnitTag = mineralSent.Tag }; command.UnitTags.Add(d.Tag); actions.Add(new Action { ActionRaw = new ActionRaw { UnitCommand = command } }); return; } } } }
private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { if ((CX_DeclKind.CX_DeclKind_LastCXXRecord < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstCXXRecord)) { throw new ArgumentException(nameof(handle)); } _bases = new Lazy <IReadOnlyList <CXXBaseSpecifier> >(() => CursorChildren.OfType <CXXBaseSpecifier>().ToList()); _ctors = new Lazy <IReadOnlyList <CXXConstructorDecl> >(() => Methods.OfType <CXXConstructorDecl>().ToList()); _destructor = new Lazy <CXXDestructorDecl>(() => Methods.OfType <CXXDestructorDecl>().SingleOrDefault()); _friends = new Lazy <IReadOnlyList <FriendDecl> >(() => Decls.OfType <FriendDecl>().ToList()); _methods = new Lazy <IReadOnlyList <CXXMethodDecl> >(() => Decls.OfType <CXXMethodDecl>().ToList()); _vbases = new Lazy <IReadOnlyList <CXXBaseSpecifier> >(() => Bases.Where((@base) => @base.IsVirtual).ToList()); }
internal void Start() { if (WarState == WarState.Started) { throw new InvalidOperationException("War already started"); } //if (Started) // throw new InvalidOperationException(); //Started = true; WarState = WarState.Started; StartedAt = DateTime.UtcNow; foreach (var b in Bases.Where(b => b != null)) { b.ResetTime(); } }
/// <summary> /// Adjust the bases /// </summary> public void Adjust(IInanimateTemplate basis, decimal movement) { IEnumerable <IEconomicBasis> myBases = Bases.Where(basi => basi.ItemType == basis); foreach (IEconomicBasis basi in myBases) { basi.Adjustment *= movement; if (movement > 1) { basi.Trend += 1; } else if (movement < 1) { basi.Trend -= 1; } } }
private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { if ((CX_DeclKind.CX_DeclKind_LastCXXRecord < handle.DeclKind) || (handle.DeclKind < CX_DeclKind.CX_DeclKind_FirstCXXRecord)) { throw new ArgumentException(nameof(handle)); } _bases = new Lazy <IReadOnlyList <CXXBaseSpecifier> >(() => CursorChildren.OfType <CXXBaseSpecifier>().ToList()); _ctors = new Lazy <IReadOnlyList <CXXConstructorDecl> >(() => Methods.OfType <CXXConstructorDecl>().ToList()); _dependentLambdaCallOperator = new Lazy <FunctionTemplateDecl>(() => TranslationUnit.GetOrCreate <FunctionTemplateDecl>(Handle.DependentLambdaCallOperator)); _describedClassTemplate = new Lazy <ClassTemplateDecl>(() => TranslationUnit.GetOrCreate <ClassTemplateDecl>(Handle.DescribedClassTemplate)); _destructor = new Lazy <CXXDestructorDecl>(() => TranslationUnit.GetOrCreate <CXXDestructorDecl>(Handle.Destructor)); _friends = new Lazy <IReadOnlyList <FriendDecl> >(() => Decls.OfType <FriendDecl>().ToList()); _instantiatedFromMemberClass = new Lazy <CXXRecordDecl>(() => TranslationUnit.GetOrCreate <CXXRecordDecl>(Handle.InstantiatedFromMember)); _lambdaCallOperator = new Lazy <CXXMethodDecl>(() => TranslationUnit.GetOrCreate <CXXMethodDecl>(Handle.LambdaCallOperator)); _lambdaContextDecl = new Lazy <Decl>(() => TranslationUnit.GetOrCreate <Decl>(Handle.LambdaContextDecl)); _lambdaStaticInvoker = new Lazy <CXXMethodDecl>(() => TranslationUnit.GetOrCreate <CXXMethodDecl>(Handle.LambdaStaticInvoker)); _methods = new Lazy <IReadOnlyList <CXXMethodDecl> >(() => Decls.OfType <CXXMethodDecl>().ToList()); _mostRecentNonInjectedDecl = new Lazy <CXXRecordDecl>(() => TranslationUnit.GetOrCreate <CXXRecordDecl>(Handle.MostRecentNonInjectedDecl)); _templateInstantiationPattern = new Lazy <CXXRecordDecl>(() => TranslationUnit.GetOrCreate <CXXRecordDecl>(Handle.TemplateInstantiationPattern)); _vbases = new Lazy <IReadOnlyList <CXXBaseSpecifier> >(() => Bases.Where((@base) => @base.IsVirtual).ToList()); }
public ulong GetBoringMineral(ResponseObservation observation) { foreach (var bs in Bases.Where(b => b.Taken).OrderByDescending(b => b.DistanceToMain)) { foreach (var min in bs.MineralUnits) { var mineral = observation.Observation.RawData.Units.Where(m => m.Tag == min.Tag).FirstOrDefault(); if (mineral == null) { continue; } var workersCount = 0; var drones = observation.Observation.RawData.Units.Where(d => d.UnitType == UnitTypes.DRONE && d.Alliance == Alliance.Self); foreach (var d in drones) { if (d.Orders.Count() == 0) { continue; } if (d.Orders.Where(o => o.TargetUnitTag == min.Tag).Any()) { workersCount++; } } if (workersCount < 1) { return(min.Tag); } } } return(0); }