# intermediate ii: weighted choices

## ✎  what are weighted choices for?

* by default, all choices listed in `{choose:}` have equal odds of being chosen.&#x20;

<p align="center"><code>{choose: jelly | ice cream | smoothie | cake | cookie}</code> </p>

<figure><img src="https://1355643618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LjUSz3NQrpyR-tHhUV-%2Fuploads%2FeRGTTICHSC6o3fWRXIxU%2Fimage.png?alt=media&#x26;token=65974b0d-b533-47f3-9548-d9140d9b5d6e" alt="" width="563"><figcaption></figcaption></figure>

* to make certain choices more common, users can hypothetically repeat certain choices...

<p align="center"><code>{choose: jelly | jelly | cake | cake | cake | cookie | cookie | cookie | cookie | cookie | smoothie | smoothie | ice cream}</code> </p>

<p align="center">because of the # of times each of the choice is repeated, it'll cause a change in rarity.</p>

<figure><img src="https://1355643618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LjUSz3NQrpyR-tHhUV-%2Fuploads%2FB9tTzMqkxMdiTJ4yr6i7%2Fimage.png?alt=media&#x26;token=8e9c51c8-74c0-48a3-a545-dff2387de3d7" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1355643618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LjUSz3NQrpyR-tHhUV-%2Fuploads%2FMFhGYiZSCAHNjMRJddSG%2Fimage.png?alt=media&#x26;token=a4ac0265-4b2d-4838-ac6c-cf4236540a0d" alt="" width="563"><figcaption></figcaption></figure>

* however, the above can get excessively verbose *extremely* fast for rarer options... so instead, it is better to use the weighted choose variable.
* the `{weightedchoose:}` variable allows you to assign a *weight* to a choice, allowing you to skew the odds for common, uncommon and rarer choices, **without repeating each choice over and over again**.

## ✎  how do i use a weighted choose?

* to assign a weighted choose, you would first need to decide how rare each option should be.&#x20;
* `{weightedchoose:}` allows you to select the weight of how much each item in the `{choose:}` will be. it will be assigned in order.

<figure><img src="https://1355643618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LjUSz3NQrpyR-tHhUV-%2Fuploads%2FZ0dvBdFT3ApiTPNIcxZv%2Fexplain_weight_choose.png?alt=media&#x26;token=5aeaff6b-8c12-4018-b346-fb7d2f8f5ace" alt=""><figcaption></figcaption></figure>

* so "the" = 1%, "choices" = 9%, "always correspond" = 10%, "in chronological" = 50%, and "order" = 30% chance.
* let's take an example, where you want the following items to have the below rarity:

<table><thead><tr><th width="260">prize</th><th>percentage chance</th></tr></thead><tbody><tr><td>common</td><td>60%</td></tr><tr><td>rare</td><td>30%</td></tr><tr><td>super rare</td><td>8%</td></tr><tr><td>ultra rare</td><td>2%</td></tr></tbody></table>

`/autoresponder add trigger: response:{choose: common | rare | super rare | ultra rare}{weightedchoose: 60% | 30% | 8% | 2%} you got a [choice] prize, congratulations!`

## ✎ more traditional weights + decimals also OK!

* if you don't want to use percentages, you can also use weights, such as the follows. let's go back to the jelly / cake / cookie / smoothie / ice cream example we had at the beginning (:

<p align="center"> <code>{choose:jelly|cake|cookie|smoothie|ice cream} {weightedchoose:2|3|5|2|1} [choice]</code> </p>

* or even use decimals!

<p align="center"><code>{choose:frog|cat|dog|fish|bear|bird|elephant}{weightedchoose:0.12|0.04|0.18|0.09|0.023|0.19|0.15} [choice]</code></p>
