Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModelRecord updates #5549

Merged
merged 50 commits into from
Jun 6, 2024
Merged

Conversation

SuperStucco
Copy link
Collaborator

ModelRecord provides a convenient summary of unit capabilities for a number of uses, similar to explicitly declared roles in the RATGen/force generator but more general and automatically generated. For example, when calling for random generation of units with the ANTI_AIRCRAFT role there may simply not be enough of the given unit type/weight class/etc. So the ModelRecord entries provide a property to indicate how well other units do even without the role.

This update adds more detail to the existing analysis process, and adds a few additional points which may be useful e.g. remote drone and robot drone flags to assist with potentially generating all-drone forces at some point, and some basic primitive/retrotech checking. Fills out a couple of legacy FIXME/TODOs. Analysis has been pulled out of the constructor to it's own method, so quickly checking code flow from outside can just step over it. Because this involves looping through all equipment on large numbers of units, extra work is done on loop optimization to avoid unnecessary checks and improve performance.

SuperStucco added 30 commits May 31, 2024 09:23
…infantry, fixed wing, and space craft. Pulled AP evaluation out into its own method. Changed evaluation to numerical instead of straight boolean.
…ce. Exclude conventional infantry weapons, including AP weapons on battle armor. Give Streak-based missile systems a discount.
…nd indirect fire capability. Pulled bulk of work out into separate method.
…infantry support weapon. Extract testing to method.
…role isn't provided use the MIXED_ARTILLERY role.
…for thresholding even well armored targets
Copy link
Member

@SJuliez SJuliez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice. I have a few comments / CRs

}

public int getSpeed() {
return speed;
}

public boolean getJump() {
return canJump;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this possibly refer to the MechSummary ms, like return ms.getJumpMp() > 0; ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didnt check if canJump is used elsewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This follows a similar style to the other getters, referring to a backing field rather than calling the MechSummary object, for consistency. Easy enough to change, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's alright as it is. Just something I thought while reading.

* Proportion of total weapons BV that is best at short range
* @return between zero (none) and 1.o (all weapons)
*/
public double getSRProportion() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be lovely if the comment on longRange/SR indicated what they mean. It does not seem self-evident.
Also, 1.o should be 1.0 ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darn copy-paste errors, one always slips through. Not sure what you're after on the descriptions though - do you want additional comments on the private variables, or a more detailed description on the methods?

Side note: getLongRange() is original and is used in a number of other files, and single-file updates are about all I'm aiming for as a version control noob. Later on I'll put in another PR to clean up the old method names to be more consistent and more evident like the newly added ones.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant was that, reading the old getLongRange and the new getSRProportion and their comments I could not imagine what they would return. What weapon is worse at its own short range than at its own long range? Is this a fixed comparison with, say, range 10? Meaning a medium laser would be bad at long range and a PPC would be good? But why would the PPC then be bad at short range? Minimum range? No clue. If I ever had to use these methods I would be forced to read the analysis code. The long range one is a legacy method, I saw that. It's ok if you don't want to do that atm.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. I'll put in something more descriptive for those, then that should be it.

* @param checkWeapon Weapon to check
* @return between zero (not a short ranged weapon) and 1
*/
private double getShortRangeModifier (EquipmentType checkWeapon) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our style guide suggests no double spaces and no space between method name and opening ( and opening { not on their own line (line 1071). A bit much :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also it seems that WeaponType suggests itself as the parameter here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same in l.1004: WeaponType and possibly others.


if (checkWeapon instanceof InfantryWeapon) {
return notEffective;
} else if (checkWeapon instanceof megamek.common.weapons.battlearmor.BAMGWeapon) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please import these.

@SJuliez SJuliez merged commit 946c9c4 into MegaMek:master Jun 6, 2024
4 checks passed
@SuperStucco SuperStucco deleted the RATGen-ModelRecord-updates branch July 11, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants