Add weighted picking#4
Conversation
| return sayInThread(say, mentionTs, [ | ||
| getSimpleTextBlock( | ||
| `Weights:\n \`\`\`${Object.entries(weights) | ||
| .map((userWeightPair) => `${userWeightPair[0]}: ${userWeightPair[1]}`) |
There was a problem hiding this comment.
user id here probably needs to be mapped to user name
| ) => { | ||
| console.log("editWeights"); | ||
| const { weights } = context.conversation; | ||
| const user = restOfCommand[0] ?? ""; |
There was a problem hiding this comment.
user name here probably needs to be mapped to user id
| const mapDbConversationStateToConversationState = ({ | ||
| excluded, | ||
| teams, | ||
| pickingAlgorithm, |
There was a problem hiding this comment.
Db will need some migrations to add pickingAlgorithm and weights tables / similar
| @@ -1,4 +1,4 @@ | |||
| export const getRandomInteger = async ( | |||
| export const getAtmosphericNoiseRandomInteger = async ( | |||
There was a problem hiding this comment.
renamed this based on how random.org says their algo works
|
|
||
| return sayInThread(say, mentionTs, [ | ||
| getSimpleTextBlock( | ||
| `Picking Algorithm: ${pickingAlgorithm}`, |
There was a problem hiding this comment.
mapping needed to a good display name but it was a bit annoying with enums so thought I'd deal with it later
|
I figured out an algorithm for auto balancing that will work even with adding new users and with excluding users and adding them back and have verified that it works through some testing and plotting, although not really bothered to add it rn algorithm is as follows:
Might also be interesting to add:
|
Adding automatic weighting to try to force uniformity might be a bad idea given that users can be excluded e.g. users is excluded for a long time they come back and are suddenly picked for everything so that the pick ratio balances out, so have instead gone with a manual weights approach which I think might be better?
Also haven't tested how the random distribution for random.org looks like since they have a 10 requests per sec limit, but instead added in another random function using math.random and checked that the distribution is indeed uniform