The vector doesn’t actually need to be sorted. If body part 1 takes up 10 “units”, and body part 2 takes up 5, body part 1 is going to have twice as many opportunities to get hit as body part 2, just because it’s twice as big
It’s the relative size that counts.
Hmm, I’m still not getting why this wouldn’t happen:
[1 1 1 1 1 1 1 2 2 3 3 3 3 3 3 3 3 3 4 4 4 5 5 5 5 5 5 5 5 5 ]
[= = = = = = = = = = = = = = = = = = = ^ ] ;; target
In the above, we get to a smaller body part, because of the way the vect was orderedYup, in the above list, you have 3 chances out of 30 to hit body part 4, 2 chances out of 30 to hit body part 2, and so on. So sometimes you'll hit the smaller body part. The target is random, so you'll randomly hit big body parts some times, and small body parts other times, but as you keep hitting different parts, you'll notice you hit the bigger parts more often, because they have more chances to be hit.
The parts don't need to be sorted in order of size, which means small values for target
don't necessarily imply hitting small body parts. That's not where the statistical odds come from. Where you get the "hit bigger parts more often" is from the fact that there are more values of target
that correspond to hitting a large body part, i.e. there's (...counting...) 7 different values that target
could be that would give you a hit on body part 1, but only 2 possible values for target
that would indicate a hit on body part 2. So on average, over time, you're going to hit bp1 about 7 times out of 30, and bp2 only 2 times out of 30.
Oh, it’s a combinatorics thing I missed not a clojure thing. Yeah that makes sense. Thank you!