From 4ec15f42a2db54f5942ee70ae0f5e11a426b9f60 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 4 Sep 2023 05:32:31 -0500 Subject: [PATCH] Change resource management AI behavior. --- olcCodeJam2023Entry/Scenario.cpp | 27 +++++++++++++++++---------- olcCodeJam2023Entry/pge.wasm | Bin 1147538 -> 1147562 bytes 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/olcCodeJam2023Entry/Scenario.cpp b/olcCodeJam2023Entry/Scenario.cpp index 8abc5dc..ed6c8c9 100644 --- a/olcCodeJam2023Entry/Scenario.cpp +++ b/olcCodeJam2023Entry/Scenario.cpp @@ -78,18 +78,25 @@ void Scenario::RunAI(Resources&enemy_resources,std::vectortoCP2={cp2->pos,baseOfOperations.lock()->GetPos()}; return toCP1.length()attachedUnit.expired()){ - if(cpCheckTimer.count(cp.get())==0||cpCheckTimer[cp.get()]<=0){ - for(auto&u:units){ - if(!u->IsFriendly()&&u->IsAllocator()&&u->attachTarget.expired()){ - //Tell this unit to move towards that collection point. - u->SetTargetCollectionPoint(cp,u); - break; + int maxOfResources=enemy_resources.health; + maxOfResources=std::max(maxOfResources,enemy_resources.atkSpd); + maxOfResources=std::max(maxOfResources,enemy_resources.moveSpd); + maxOfResources=std::max(maxOfResources,enemy_resources.procedure); + maxOfResources=std::max(maxOfResources,enemy_resources.range); + if(maxOfResources<10){ + for(auto&cp:collectionPoints){ + if(cp->attachedUnit.expired()){ + if(cpCheckTimer.count(cp.get())==0||cpCheckTimer[cp.get()]<=0){ + for(auto&u:units){ + if(!u->IsFriendly()&&u->IsAllocator()&&u->attachTarget.expired()){ + //Tell this unit to move towards that collection point. + u->SetTargetCollectionPoint(cp,u); + break; + } } + //Hasn't been checked recently. + cpCheckTimer[cp.get()]=60; } - //Hasn't been checked recently. - cpCheckTimer[cp.get()]=60; } } } diff --git a/olcCodeJam2023Entry/pge.wasm b/olcCodeJam2023Entry/pge.wasm index 1fe0a84297e867c7970bb5b7dbb8125d4a1615c7..40c0eab46762572563cd26b253430609c2345bac 100644 GIT binary patch delta 180 zcmbQ#>b9!YZNn{3#`&9Xdw%=GIBWYQ8%A#4=}$cw{TP|In|Lt>GU_lnFgYl&>M}6! zG5{IE8cZxoY_2R0ju#j}VvIb@+zM<0&ji4N+h=++W-~Fn@-nou`7r`9({?sL=9o~% z``eQjGq;toEATloS~2jnzm#MFVpbq#17da{<^W<&Am##MZXgD!;RRwoAm#^Rf$c9P I1y^PO06cg$MF0Q* delta 154 zcmZ40>Ncs>ZNn{3#`ev(J->Zo?A(6IhLM|>jmZH7r{DHu3}9s0uH(fR$S9&9tii;h z#OBJ&pui^ZOhAc^myvt>N^iz&CMFh#c5y#OAZFSw?#CPx%6MaY$ztZVvUWx(79eH? lVm2UV2VxE&<^*CcAm#>Q9w6ogVm=_|2V#Nkj8cLtGXOhfCT;)#