Skip to content

Determine role ratios from predetermined configurations #2

@sudojunior

Description

@sudojunior

Assuming roleConfigs is an array of role configurations that scale with the player quantity that is used to determine the average ratio of roles per game.

roleConfigs.map(({ roles, playerCount }) => {
  return roles.map(({ role, count }) => ({
    role, ratio: count / playerCount
  }))
}).reduce((prev, next) => {
  return next.map(({ role, ratio }, index) => {
    return { role, ratio: (prev[index]?.ratio || 0) + ratio }
  });
}, []).map(({ role, ratio }, index, array) => ({ role, ratio: ratio / array.length }));

The following assumes that the sum of count found in each role is equal to that of playerCount for that particular configuration - which is then used to determine the ratio of roles for that game, and then again with the output of that result to determine an average.

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions