MegaMek / megamek

MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight using giant robots, tanks, and/or infantry on a hex-based map.
http://www.megamek.org
GNU General Public License v2.0
286 stars 276 forks source link

49.20 Nightly - Princess Appears to do no pre-deployment pathfinding check. #5614

Open Thom293 opened 2 weeks ago

Thom293 commented 2 weeks ago

This is a long-standing issue and not unique to the nightly. I dont recall a bug report on it and didnt see one on a quick search.

This Locust deployed on this building on turn 1. It was competely unnecessary as there were plenty of empty roads in our deployment zone. He has been there the entire game shooting the building, trying to break free.

She exhibits similar behavior by deploying on islands, or in a landlocked hex in a group of tall buildings, or on swamp/water, etc. So, seems she may check the deployment zone and see any hex in it as valid, without checking the actual hex itself?

image

image

SuperStucco commented 2 weeks ago

From my observations, this might be two separate problems.

The first is pathfinding - stuck on TOP of a building, or an island, and unable to move. If there was a quick pathfinder check to see if the unit could get to the middle of the map, a random hex in the enemy's deployment zone, the edge of the map they are trying to exit, etc. that might help. Hard to get such a thing exactly right, as you want snipers and LRM boats deployed high in certain cases, and in other cases it doesn't matter so much if a couple of units ultimately get left behind later if they provide better cover early on.

This might be a different problem - as I don't see an elevation marker next to the Locust it is probably inside the building rather than on top. I've noticed that once inside a building, whether deployed there or skidded into, it tends to stay there. Maybe the utility evaluator of the movement path is discounting every possibility because the first step is going through a building wall and very likely taking damage.

repligator commented 2 weeks ago

(I think) the applicable code is under megamek/client/bot/BotClient.java and megamek/client/bot/princess/Princess.java. If I'm understanding everything correctly (and I may very well not be), Princess may have deployed that Locust under the impression that it had access to the rest of the board. She prefers to deploy with a clear path, but will also deploy with a path that can be made via destroying buildings. If that building is destroyed, the Locust has a clear path. The fact that destroying the building while the Locust is standing in/on it will almost certainly cause damage to the Locust itself isn't accounted for AFAIK.

[EDIT] Breakpoint on lines 917 of BotClient.java shows the ranking of deployment hexes. Screenshot_20240621_105207 Screenshot_20240621_111737

Thom293 commented 2 weeks ago

So she does some check. Its it just based on hezes or paths away from it?

Row 201, 202, 203 is interesting: she has the ranked all nearly the same even though 2 hexes are lava. Maybe it's just a simple as she doesn't have all hexes on her hazard list (I have a RFE on this that I can link in a bit.

Thom293 commented 2 weeks ago

Ok - might be related to #5361. Also might be related to a change I made recently to her piloting caution.

I'm no coder. Can't read it or write it but sometimes I can change it and get something sort of working. But it's brute-force blunt instrument type stuff. Ham-fisted.

I changed some stuff related to Ice and Piloting Caution (she fell constantly on pavement) and Berserker which all kind of works to some varying degree. Passable, but inelegant and 100% can be improved by someone that knows what they are doing.

But now that real coders are looking at this stuff... be my guest ripping out or improving anything I did before. Here, it looks like her hazard list does need to be updated. But it also might be related to the fact that I brute-forced her piloting caution to an obscenely high number to keep her from falling as much. Which is much better than it was, but may have this unintended consequence of causing her to think deploying on pavement is more dangerous than deploying in lava or inside a building.