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

Determine role ratios from predetermined configurations #2

Open
sudojunior opened this issue Oct 30, 2021 · 1 comment
Open

Determine role ratios from predetermined configurations #2

sudojunior opened this issue Oct 30, 2021 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@sudojunior
Copy link
Member

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.

@sudojunior sudojunior added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 30, 2021
@sudojunior sudojunior self-assigned this Oct 30, 2021
@sudojunior
Copy link
Member Author

sudojunior commented Oct 30, 2021

Equivalent to the notation of sum(configs.*.roles[index].count) / len(roles) - with index referring to the current loop (also implying that each role is in the exact order that the first config is found in (even if one such role does not exist in a specific configuration).

But as for steering the boat back on course, this is merely for debugging purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant