WeightedChoice
by @rehhouari
16
Chance Based Random Choice in Godot 4 (Weighted Probability)
About this project
Weighted Choice This Godot 4 plugin provides a static WeightedChoice.pick() method you can call to randomly choose an item from a dictionary based on weights. Usage: Includes in-editor documentation! pick(dict: Dictionary, weightkey: Variant) Takes a dictionary dict, and randomly picks one item based based on weights. If weightkey is set, the function will search for weights in a nested dictionary. Returns a key. Examples Non-nested weights: Nested weights Loot Box Demo You can check the loot box demo for an example on how to use this plugin Try it in the browser Installation Install from the Asset Library, or clone the repository and copy the weightedchoice folder into your addons folder. When installing, you can uncheck the "demo" folder Credits MIT License Copyright (c) 2023 Rafik El Hadi Houari Uses code from Mickeon https://github.com/godotengine/godot-proposals/issues/3948#issuecomment-1035074260 mentioend in: https://youtu.be/lckgjXM3CeE Demo assets: https://admurin.itch.io/free-chest-animations https://snowhex.itch.io/mini-tools-pack-harvestsummer
From the project README on GitHub
- Stars
- 16
- Forks
- 0
- License
- MIT
- Last push
- 3 Jan 2025
Add this badge to your README
Show that your project is listed on Made in Algeria.
[](https://www.madeinalgeria.dev/projects/weightedchoice)