Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

random selection of array elements

$
0
0
Hello, I have a bit of programming dilemma which I cannot seem to solve my self. What if I have an array of numbers and I want to randomly select entry from the array so that the higher the number in the array the more likely it gets picked? For example array like this: [1000,800,400,200] Should have highest change of selecting the highest number (1000) and lowest change for the lowest number. How to calculate this? thanks!

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>