> For the complete documentation index, see [llms.txt](https://dropshop.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dropshop.gitbook.io/docs/platform-information/logic/selection-function.md).

# Selection Function

The Selection Function takes in an array containing the key:value pair {address:TWF} for all participant tickets submitted into the Lottery.  It then normalizes these weights across an interval between 0 and 1, with each ticket randomly assigned a share of this interval in proportion to its weight.

The Selection function uses a Mersenne Twister seeded with a Chainlink VRF call to pick a random number between 0 and 1.  Whichever ticket contains that number is declared a winner and the address sent back to the MSC.  That ticket is removed from the pool and the process repeats, with the total number of draws equal to the quantity of the good in the lottery.
