Menu

#498 Fix infantry trying to shoot and swarm at the same time

stable 0.42
closed
None
1
2015-08-16
2015-06-29
Noyal
No

Hi again,

I've got some other bigger things still in the works, but I put together a quick-ish fix for a bug/missing feature I ran into this week.

I noticed that, when using infantry/BA, Princess would try to both shoot and swarm(and leg attack) enemy units when at range 0, which ends up resolving as just shooting the target, meaning Princess almost never actually makes swarm/leg attacks, even though she knows how to consider them(basically as normal attacks with a damage multiplier).

I fixed this by adding an admittedly slightly clunky conditional for infantry in FireControl's FiringPlan building methods, which results in infantry/BA getting additional FiringPlans for swarming and leg attacking, if possible, and a best attack plan is selected via utility function from among them. In testing, Princess now seems to prefer swarm attacks, then leg attacks, then regular attacks, given decent to-hit numbers on each, which sounds about right to me. A side benefit is that she should also be a bit less likely to suicide-rush infantry into open terrain in order to get underneath enemy mechs, since she no longer thinks she can do shooting + swarming + leg attack damage by doing so. Overall, this should make bot-controlled infantry(and especially fast BA) a little more useful/dangerous.

As a side note, I tried your previous '-x "--ignore-eol-style"' suggestion for making the patch file behave better. Let me know if this solved the problem!

1 Attachments

Related

Bugs: #4598

Discussion

  • Noyal

    Noyal - 2015-07-03

    After posting this, I realized that field guns also suffered the same restrictions(can't fire field guns and standard weapons in the same turn), and thus applied a similar solution to them as well. At the same time, I also added in a slightly hackish solution to prevent Princess from constantly moving her field guns, thus preventing them from firing(a check in move path validation to avoid moving if the unit can't both move and shoot and is in range). This should also apply to 0-MP infantry as well.

    The net result is that in this version of the patch, Princess is reasonably capable of using infantry field guns(i.e. she will actually use their big guns), on top of the previous fixes to infantry swarming/leg attacks.

    On a related note, while figuring out a fix to make Princess not move field guns constantly, I discovered that, as far as I can tell, there is no actual path ranking done by Princess, at least in PathRanker. The core PathRanker.RankPath method simply returns null, and I can't find any other code that would do path ranking instead. It looks like potential move paths are simply validated, then one is chosen at random from the list of valid paths. Could someone more familiar with Princess' movement code please confirm if this is the case? While a full implementation is probably not in the cards for now, I might be able to devise some simple heuristics to at least help with some cases.

     
  • Klaus Mittag

    Klaus Mittag - 2015-07-03

    As near as I can tell (at a glance -- I'm probably less of an expert on Princess than you are), that exact method gets overridden in BasicPathRanker, so as long as all the path rankers MegaMek ever uses are instances of that class it should work out...I think. The "whoops, this method only ever returns null" case should only come up if PathRanker is ever instantiated directly, and I'm not sure off the top of my head if the fact that it can be isn't itself potentially problematic -- if it's just intended to be a general base class for concrete path ranker implementations to extend, wouldn't it be better off abstract?

     
  • Noyal

    Noyal - 2015-07-11

    Actually, I completely forgot that BasicPathRanker existed when I was looking at this. Whoops. You're probably right that path ranking should be refactored given the awkward functional split between BasicPathRanker and PathRanker. Perhaps someday. :)

    In that light, I went back and refactored this patch again to make my improvements to field guns/zero-move infantry less of a hack. Princess now recognizes the tradeoff between moving and shooting for these units as part of the path ranking process. That said, as of right now, unless you turn self-preservation way down, she still tends to move field guns a lot at close ranges, mostly in the hope of trying to keep them from dying by increasing TMM and/or avoiding LOS. This makes short ranged field gun fire(especially AC20's) still a bit iffy unless they're not taking much return fire, but until someone reworks Princess to respect the idea that some units are expendable(i.e. positive BV trade with the enemy), I think this is the best she can handle them. Just assume the gunners tend to break and run at the sight of battlemechs bearing down on their position or something.

    I also messed around with damage weighting of leg and swarm attacks a bit, since it seemed like they were less common than they should be. Still not fully happy with this, but they do get used on occasion, and finding the right balance is difficult in general.

    Hopefully this is the final revision to this patch. I've spent way too much time on this for what it is, at this point. Let me know if there are any corrections that need to be made for implementation, though!

     
  • Hammer

    Hammer - 2015-07-13

    Noyal, Are you on either of the official forums? CGL or the MegaMek.info one?

     
  • Noyal

    Noyal - 2015-07-14

    Not presently, though I do read the official forums occasionally and the MegaMek ones rarely. I'd be happy to make an account on one for coordination purposes, though I'm reluctant to get too involved in things as I'm not sure how long/much I'll be contributing in the medium/long term. I started a new position recently that's already eating at my spare time, and I don't want to overcommit(I've still got that zellbrigen option waiting for UI and debugging/polish already).

     
  • Hammer

    Hammer - 2015-07-14

    Understand completely. It was for coordination purposes that I was thinking. The devs are on both forums, so if you want pick a forum and let us now.

     
  • Nicholas Walczak

    Implemented in [r12006]. I had no problems applying the patch either.

     
  • Nicholas Walczak

    • status: open --> implemented
    • assigned_to: Nicholas Walczak
    • Group: undetermined --> stable 0.42
     
  • Nicholas Walczak

    • Status: implemented --> closed