Class MonsterMetrics
java.lang.Object
MonsterMetrics
Application to measure monster power levels.
- Since:
- 2016-02-10
-
Nested Class Summary
Modifier and TypeClassDescription(package private) class
Statistics for battles at a given search point. -
Field Summary
Modifier and TypeFieldDescription(package private) Armor.Type
Armor type for battling fighters.(package private) int
Monster number for single matchup.(package private) int
PC level for sample fight run.(package private) final Armor.Type
(package private) final int
(package private) final int
(package private) final int
(package private) final int
(package private) final int
(package private) boolean
Flag to display equated fighters per level.(package private) boolean
Flag to display equated fighters HD per level.(package private) boolean
Flag to display only revised EHD values.(package private) boolean
Flag to display unknown special abilities.(package private) boolean
Assess matchup at specified party level & monster number.(package private) boolean
Should we only print stat blocks for monsters?(package private) boolean
Show one sample fight at parity numbers.(package private) boolean
Flag to escape after parsing arguments.(package private) int
PC expected party size.(package private) final int
(package private) boolean
Flag to graph equated fighters HD.(package private) boolean
Flag to make a table of best-number-match values.(package private) final int
(package private) final int
(package private) final int
(package private) final int
(package private) int
Number of fights to run per search space point.(package private) int
Chance per level for magic sword.(package private) boolean
Did we print anything on this run?(package private) boolean
Flag to show suggested best level match.(package private) boolean
Flag to show suggested best number matches.(package private) boolean
Flag to show parity win ratios.(package private) boolean
Flag to show quick battle stats exclusively.(package private) Monster
Single monster option for measurement.(package private) long
Process start time.(package private) long
Process stop time.(package private) boolean
Should we wait for a keypress to start (for profiler)?(package private) int
Fraction of party who are wizards. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
Any special printing done per monster?private void
Assess a single specified matchup.private void
Display unknown special abilities if desired.private Armor.Type
Get armor type from command parameter.private int
getBalancedMonsterNumbers
(Monster monster, int ftrLevel, int partySize) Compute fair monster numbers by EHD.private MonsterMetrics.BattleStats
getBattleStats
(Monster monster, int ftrLevel) Compute stats for monster vs.private int
getBestLevelMatch
(Monster monster) Get the best level match for a given monster.private int[]
getBestNumberArray
(Monster monster) Construct an array of best number matches per level.private int
getBestNumberMatch
(Monster monster, int ftrLevel) Get the best number-appearing match for a given monster.private double
getDblArrayHarmonicMean
(double[] array) Get the harmonic mean of a double array.private double
getDblArrayMax
(double[] array) Get the maximum of a double array.private double
getDblArrayMean
(double[] array) Get the mean of a double array.private double
getDblArrayMin
(double[] array) Get the minimum of a double array.private double[]
getEquatedFighters
(Monster monster) Get equated fighters per level for a monster.private double[]
getEquatedFightersHD
(double[] equatedFighters) Get equated fighter hit dice for a monster.private int
Get integer following equals sign in command parameter.private String
Get string following equals sign in command parameter.private double[]
getParityWinRatios
(Monster monster) Compute an array of win ratios for monster at linear-EHD-parity vs.private void
graphDblArray
(double[] array) Print a graph of a double array.private double
invertIfNeeded
(double ratio, boolean invert) Invert a win ratio if needed.private boolean
isCloserToHalf
(double val1, double val2) Is the first number closer to one half than the second number?private boolean
isEHDClose
(double oldEHD, double newEHD) Determine if EHDs are relatively close.static void
Main application method.private Party
makeFighterParty
(int level, int number) Create a specified party of fighters.private int
matchFight
(Function<Integer, Double> winRatioFunc) Search for a matched fight based on some parameter.private int
matchMonsterToFighters
(Monster monster, int fighterLevel) Match fighters of given level to monster of one type.private Character
newFighter
(int level) Create a new fighter of the indicated level.private Weapon
newSword
(int level) Create a sword for a new fighter.private Character
newWizard
(int level) Create a new wizard of the indicated level.private void
Parse arguments.private void
Parse option for a sample fight.private void
Parse option for a single matchup.private void
Print program banner.private void
printBNMRow
(Monster monster) Print one monster in a BNM table.private void
Print a table of BNM values.private void
Print simple report of parity battle stats.private void
printQuickBattleStats
(Monster monster) Print simple parity battle stats for one monster.private void
Print stat blocks.private void
Print usage.private void
processArgs
(String[] args) Process arguments, including pre- and post-processingprivate double
ratioMonstersBeatFighters
(Monster monster, int ftrLevel) Get monster win ratio for same-size parties.private double
ratioMonstersBeatFighters
(Monster monster, int monNumber, int ftrLevel) Get monster win ratio for variable number of monsters.private double
ratioMonstersBeatFighters
(Monster monsterType, int monsterNumber, int fighterLevel, int fighterNumber, boolean invert) Find the probability that these monsters beat these fighters.private void
Report number of fighters at each level to match all monsters.private void
Report monster metrics as commanded.private void
reportOneMonster
(Monster monster) Report equated fighters and estimated EHD for one monster.private double
roundDbl
(double val, int precision) Round a double to an indicated precision.private void
Run a sample fight.private void
Start the process timer.private void
Stop the process timer & report.private boolean
testLopsidedMatch
(int fight, int wins) Test to shortcut a lopsided matchup.private String
toString
(double[] array, int precision) Create string from a double array, to given precision.
-
Field Details
-
MAX_LEVEL
final int MAX_LEVEL- See Also:
-
MAX_ENEMIES
final int MAX_ENEMIES- See Also:
-
DEFAULT_FIGHTS_GENERAL
final int DEFAULT_FIGHTS_GENERAL- See Also:
-
DEFAULT_FIGHTS_SPOTLIGHT
final int DEFAULT_FIGHTS_SPOTLIGHT- See Also:
-
DEFAULT_MAGIC_PER_LEVEL_PCT
final int DEFAULT_MAGIC_PER_LEVEL_PCT- See Also:
-
DEFAULT_WIZARD_RATIO
final int DEFAULT_WIZARD_RATIO- See Also:
-
GRAPH_Y_INTERVAL
final int GRAPH_Y_INTERVAL- See Also:
-
DEFAULT_ARMOR
-
MAX_OPP_LEVEL
final int MAX_OPP_LEVEL- See Also:
-
MAX_MON_NUMBER
final int MAX_MON_NUMBER- See Also:
-
DEFAULT_PARTY_SIZE
final int DEFAULT_PARTY_SIZE- See Also:
-
spotlightMonster
Monster spotlightMonsterSingle monster option for measurement. -
numberOfFights
int numberOfFightsNumber of fights to run per search space point. -
armorType
Armor.Type armorTypeArmor type for battling fighters. -
pctMagicPerLevel
int pctMagicPerLevelChance per level for magic sword. -
wizardFrequency
int wizardFrequencyFraction of party who are wizards. -
commandPartyLevel
int commandPartyLevelPC level for sample fight run. -
expectedPartySize
int expectedPartySizePC expected party size. -
commandMonsterNumber
int commandMonsterNumberMonster number for single matchup. -
displayUnknownSpecials
boolean displayUnknownSpecialsFlag to display unknown special abilities. -
displayOnlyRevisions
boolean displayOnlyRevisionsFlag to display only revised EHD values. -
displayEquatedFighters
boolean displayEquatedFightersFlag to display equated fighters per level. -
displayEquatedFightersHD
boolean displayEquatedFightersHDFlag to display equated fighters HD per level. -
graphEquatedFightersHD
boolean graphEquatedFightersHDFlag to graph equated fighters HD. -
showParityWinRatios
boolean showParityWinRatiosFlag to show parity win ratios. -
showQuickBattleStats
boolean showQuickBattleStatsFlag to show quick battle stats exclusively. -
showBestLevelMatch
boolean showBestLevelMatchFlag to show suggested best level match. -
showBestNumberMatch
boolean showBestNumberMatchFlag to show suggested best number matches. -
printedSomeMonster
boolean printedSomeMonsterDid we print anything on this run? -
doShowSampleFight
boolean doShowSampleFightShow one sample fight at parity numbers. -
doAssessSingleMatchup
boolean doAssessSingleMatchupAssess matchup at specified party level & monster number. -
makeBNMTable
boolean makeBNMTableFlag to make a table of best-number-match values. -
waitForKeypress
boolean waitForKeypressShould we wait for a keypress to start (for profiler)? -
doPrintStatBlocks
boolean doPrintStatBlocksShould we only print stat blocks for monsters? -
exitAfterArgs
boolean exitAfterArgsFlag to escape after parsing arguments. -
timeStart
long timeStartProcess start time. -
timeStop
long timeStopProcess stop time.
-
-
Constructor Details
-
MonsterMetrics
MonsterMetrics()Basic constructor.
-
-
Method Details
-
printBanner
private void printBanner()Print program banner. -
printUsage
private void printUsage()Print usage. -
processArgs
Process arguments, including pre- and post-processing -
parseArgs
Parse arguments. -
getParamInt
Get integer following equals sign in command parameter. -
getParamString
Get string following equals sign in command parameter. -
getArmorType
Get armor type from command parameter. -
parseSampleFightOption
Parse option for a sample fight. -
parseSingleMatchupOption
Parse option for a single matchup. -
reportMonsters
private void reportMonsters()Report monster metrics as commanded. -
reportAllMonsters
private void reportAllMonsters()Report number of fighters at each level to match all monsters. -
reportOneMonster
Report equated fighters and estimated EHD for one monster. -
anySpecialPrinting
private boolean anySpecialPrinting()Any special printing done per monster? -
isEHDClose
private boolean isEHDClose(double oldEHD, double newEHD) Determine if EHDs are relatively close. Note the -r switch is used for regression testing of the whole Arena suite. (Gives visibility if a code modification has unexpected side effects.) There's natural variation in estimated EHD due to random sampling, and more at higher levels, which we don't want to spuriously flag revised values. So we implement an exponential error bar before triggering a report. Also, there are some low-level monsters with EHDs right around the halfway point between two integers that would trigger a report half the time, if we compared integer values, and had an error bar below 1. Therefore, we compare decimal values, and only trigger a report if there's at least a 2/3 unit difference. For the monsters in question, we made the manual choice in the database of leaning toward the actual HD. In some cases this may mask the fact that the true EHD is under the halfway point by a tiny fraction. E.g.: Zombie, Caveman, Gnoll, Bugbear, Ogre, Hill Giant. -
getEquatedFighters
Get equated fighters per level for a monster. -
getEquatedFightersHD
private double[] getEquatedFightersHD(double[] equatedFighters) Get equated fighter hit dice for a monster. -
toString
Create string from a double array, to given precision. -
roundDbl
private double roundDbl(double val, int precision) Round a double to an indicated precision. -
getDblArrayMax
private double getDblArrayMax(double[] array) Get the maximum of a double array. -
getDblArrayMin
private double getDblArrayMin(double[] array) Get the minimum of a double array. -
getDblArrayMean
private double getDblArrayMean(double[] array) Get the mean of a double array. -
getDblArrayHarmonicMean
private double getDblArrayHarmonicMean(double[] array) Get the harmonic mean of a double array. -
graphDblArray
private void graphDblArray(double[] array) Print a graph of a double array. -
matchMonsterToFighters
Match fighters of given level to monster of one type.- Parameters:
monster
- Type of monster.fighterLevel
- Level of fighter.- Returns:
- If positive, one monster to many fighters; if negative, one fighter to many monsters.
-
matchFight
Search for a matched fight based on some parameter.- Parameters:
winRatioFunc
- Must be increasing in parameter.
-
isCloserToHalf
private boolean isCloserToHalf(double val1, double val2) Is the first number closer to one half than the second number?- Returns:
- true if val1 is at least as close to 0.5 as val2
-
ratioMonstersBeatFighters
private double ratioMonstersBeatFighters(Monster monsterType, int monsterNumber, int fighterLevel, int fighterNumber, boolean invert) Find the probability that these monsters beat these fighters.- Parameters:
invert
- If true, returns chance of fighters beating monsters.
-
invertIfNeeded
private double invertIfNeeded(double ratio, boolean invert) Invert a win ratio if needed. -
testLopsidedMatch
private boolean testLopsidedMatch(int fight, int wins) Test to shortcut a lopsided matchup. Tell if ratio over 0.5 at 2-sigma (97.7%) confidence See Weiss Introductory Statistics: Procedure 12.2, handicap enemy 10 fights. -
makeFighterParty
Create a specified party of fighters. -
newFighter
Create a new fighter of the indicated level. Equipment is kept to fixed baseline, with only magic swords to hit monsters as required. (So: Do not use standard Character equip or magic.) -
newSword
Create a sword for a new fighter. -
newWizard
Create a new wizard of the indicated level. Equipment is kept to fixed baseline. (So: Do not use standard Character equip or magic.) -
displayUnknownSpecials
private void displayUnknownSpecials()Display unknown special abilities if desired. -
getBattleStats
Compute stats for monster vs. standard-sized party at a given level. Here we assume a linear matching function based on database EHD (similar to rough idea on Vol-3, p. 11) -
getBalancedMonsterNumbers
Compute fair monster numbers by EHD. Assumes fixed party size and level.- Returns:
- fair number of monsters (possibly 0)
-
printQuickBattleStats
private void printQuickBattleStats()Print simple report of parity battle stats. -
printQuickBattleStats
Print simple parity battle stats for one monster. -
getParityWinRatios
Compute an array of win ratios for monster at linear-EHD-parity vs. standard party at various levels. -
ratioMonstersBeatFighters
Get monster win ratio for same-size parties. -
getBestLevelMatch
Get the best level match for a given monster. Assumes monster numbers fixed at standard party size. Searches for level where they're a match for same-size party of PCs (i.e., closest to 50% chance to win against each other)- Returns:
- level at which monsters & PCs are closest to 50% win ratio
-
ratioMonstersBeatFighters
Get monster win ratio for variable number of monsters. -
getBestNumberMatch
Get the best number-appearing match for a given monster. Assumes opposing PC party levels and size are fixed. Searches for number where they're a match for same-size party of PCs (i.e., closest to 50% chance to win against each other)- Returns:
- level at which monsters & PCs are closest to 50% win ratio
-
getBestNumberArray
Construct an array of best number matches per level. -
printBNMTable
private void printBNMTable()Print a table of BNM values. -
printBNMRow
Print one monster in a BNM table. -
showSampleFight
private void showSampleFight()Run a sample fight. Assumes standard party size, PC level 1 to MAX_LEVEL, and monster numbers at parity total EHD. -
assessSingleMatchup
private void assessSingleMatchup()Assess a single specified matchup. -
printStatBlocks
private void printStatBlocks()Print stat blocks. -
startClock
private void startClock()Start the process timer. -
stopClock
private void stopClock()Stop the process timer & report. -
main
Main application method.
-