BattletechModders / CleverGirl

Helps the AI be a bit more intelligent.
MIT License
4 stars 4 forks source link

AttackOrders may not prioritize ranged attacks due to rotation conflicts #26

Open IceRaptor opened 3 years ago

IceRaptor commented 3 years ago

Another sucide charge from the AI in round one Hellound charged at the King Crab with spawn protection still on Attachment file type: archive RogueLogs.zip 18.91 MB Harkonnen — 05/28/2021 @FrostRaptor CG decided that charge is the best move here, with ToHit:0.275. maybe there is some logic lapse? Interactive Rubber Dolphin — 05/28/2021 maybe evasion remove is weighted that much? FrostRaptor — Today at 9:46 AM I think it's a combination of things Looks like all the ranged weapons were marked as wilLFireAtTarget=false in the evaluation 1:30:16.961 Checking range 172.2269 and LOF from attacker: ((384.0, 199.2, -540.4)) to target: ((300.0, 161.3, -685.9)) 21:30:16.961 -- weapon => 'M. i. Heavy Laser (C)' 21:30:16.961 -- can be used in melee, adding to melee sets. 21:30:16.961 -- willFireAtTarget: False withinRange: True 21:30:16.961 -- weapon => 'Repeating TSEMP' 21:30:16.961 -- can be used in melee, adding to melee sets. 21:30:16.961 -- willFireAtTarget: False withinRange: True 21:30:16.961 -- weapon => 'SRM6 Streak MKII' 21:30:16.961 -- can be used in melee, adding to melee sets. 21:30:16.961 -- willFireAtTarget: False withinRange: True 21:30:16.961 -- weapon => 'AMS (C)' 21:30:16.961 -- can be used in melee, adding to melee sets. 21:30:16.961 -- willFireAtTarget: False withinRange: False 21:30:16.961 -- weapon => 'Grenade Launcher' 21:30:16.961 -- can be used in melee, adding to melee sets. 21:30:16.962 -- willFireAtTarget: False withinRange: True Which results in CG thinking the unit is a melee bot 21:30:16.974 == Creating melee weaponSets for attacker: Hellhound HND-RX_Lieutenant_A3C9A6F1 versus target: King Crab KGC-666_Poet_2B0CDE33 21:30:16.974 Unit isMeleeMech due to rawMelee: 153 >= rawRanged: 0 x 2 I evaluates its choices and figures out melee is the only thing that yields damage 21:30:16.980 AEHelper found 2 different attack solutions after evaluating attacks 21:30:16.980 evaluated attack of type Melee with 1 weapons, damage EV of 47.025, heat -81 21:30:16.980 evaluated attack of type Shooting with 0 weapons, damage EV of 0, heat -81 21:30:16.980 best shooting: 0 melee: 47.025 dfa: 0 So it goes for it Harkonnen — Today at 9:49 AM so its basically back to the question why " willFireAtTarget: False" FrostRaptor — Today at 9:50 AM Yup I can think of two things off the top of my head First is that being the first turn, sensors are offline - so pilot might be outside visual range Harkonnen — Today at 9:51 AM it was able to charge, caanot be FrostRaptor — Today at 9:51 AM Yup Plus LV logs have this: 21:28:01.349 MH:PCM Parsing current map. 21:28:01.360 Calculating vision range as Math.Ceil(baseVision:40 30.0 visionMulti:0.8) = visRange:961. 21:28:01.360 MapHelper: Vision range for map will be ==> 960m (normalized from 961m) So shouldn't be a signature/vision issue Harkonnen — Today at 9:52 AM lloking at your other explanation.... could it be that yore are checking this from the unit intial position and there is no LoS? FrostRaptor — Today at 9:52 AM Wrong element, there's two missions in this log Yup That's the second idea. That the current rotation may be what's throwing it off. Basically if HellHound had KGC in rear arc... most weapons would not figure from current rotation This is probably a bug in HBS code that I've carried over. Yeah, that's seeming more and more likely HBS code: bool flag = weapon.WillFireAtTargetFromPosition(target, unit.CurrentPosition, unit.CurrentRotation); bool flag2 = unit.Combat.LOFCache.UnitHasLOFToTarget(unit, target, weapon); bool flag3 = (target.CurrentPosition - unit.CurrentPosition).magnitude <= weapon.MaxRange; It's not setup to consider that you can freely rotate from a stationary attack. In most cases it works because the influenceMap will direct you to a different position before this logic kicks in KGC sprints in phase 11: 2021-05-27T23:13:07 CombatLog.ActorActivation [LOG] Actor King Crab KGC-666 (ec9d2280-ca9a-4d90-8a20-963d8a4c0a39.1) - Activated by Team Player 1 2021-05-27T23:13:07 CombatLog.ActorActivation [LOG] Actor King Crab KGC-666 (ec9d2280-ca9a-4d90-8a20-963d8a4c0a39.1) - sprinting

(related: HTF is a KGC going on phase 11?!? That's round 19, WTF!) That's wrong, that is previous mission Harkonnen — Today at 10:03 AM actualy, LoS from current explains all weirdness in Ai reported.... stupid melee attacks, mechs running from player.... FrostRaptor — Today at 10:03 AM @Interactive Rubber Dolphin to your question - the attack is weighted highly because of evasion break: 21:30:16.974 Evaluating damage for state: CHARGE 21:30:16.974 -- Checking ranged weapons 21:30:16.974 - Calculating utility based upon total projected instab of: 200 21:30:16.974 Adding 60 virtual damage to EV from evasivePips: 6 x bonusDamagePerPip: 10 21:30:16.974 Reducing virtual damage by 30 due to potential loss of 6 pips. 21:30:16.974 Reducing virtual damage by 50 due to attacker damage on attack. 21:30:16.974 Virtual damage calculated as -20 = evasionBreakUtility: 60 + knockdownUtility: 0 - selfDamage: 50 - selfEvasionDamage: 30 21:30:16.974 State CHARGE exceeds previous state damages, adding it as highest damage state Interactive Rubber Dolphin — Today at 10:04 AM wait

-20 wouldn't that be instead low? FrostRaptor — Today at 10:04 AM Yes, that's applied to the EV of the charge attack The point being without the +60 the charge would probably go negative in this case, and end up being a 0 damage attack - AI would have braced instead Interactive Rubber Dolphin — Today at 10:05 AM Ah I see FrostRaptor — Today at 10:07 AM Actually, at a different attack position it's even higher: 21:30:15.193 === Calculating expectedDamage for Hellhound HND-RX_Lieutenant_A3C9A6F1 melee attack from position: (384.0, 199.3, -540.4) against target: King Crab KGC-666_Poet_2B0CDE33 at position: (300.0, 161.3, -685.9) 21:30:15.193 useRevengeBonus: True ... 21:30:15.194 Virtual damage calculated as 180 = totalDamage: 200 + evasionBreakUtility: 60 + knockdownUtility: 0 - selfDamage: 50 - selfEvasionDamage: 30 21:30:15.194 Setting weapon: Melee to virtual damage: 180 for EV calculation Another factor that could be complicating this There are multiple enemies: 21:30:16.961 Evaluating all actors for hostility to Hellhound HND-RX_Lieutenant_A3C9A6F1 21:30:16.961 -- actor: King Crab KGC-666_Poet_2B0CDE33 is an enemy. 21:30:16.961 -- actor: Corsair COR-RA_Raven_F9FAE558 is an enemy. 21:30:16.961 -- actor: Mauler MAL-RX_Ronin_9D156E66 is an enemy. 21:30:16.961 -- actor: Munin LAM MN-1B_Tinker_E325BAAE is an enemy. The AI logic looks for 'opportunity fire' shots against targets, and so long as it finds one that beats the threshold it takes it. If the influenceMap logic results in a node position & rotation that is facing say the Munin, but the KGC evaluates first in the list and beats the threshold - you'd see behavior like this. It picks the KGC as the first opportunity fire candidate instead of evaluating all of them, as a performance boost. This one will be a bitch to fix

IceRaptor commented 3 years ago

Issue fundamentally is that ranged attacks are evaluated from current position + rotation, because AI logic assumes movement then eval of attacks. In the case that we have a stationary attack node, ranged attacks should allow rotations of the unit to turn to face their target. I think this already happens but need to include more logic to try to make this more intelligent.