Strange result calculating probability of hit
I'm getting a strange result when running this function
21 Replies
at finalValue = 12; there is a strangely large number of probabilities being created
this is how i'm printing the results
i'm not sure why, maybe it's because the float starts with 0.0 or something?
Why do a Yandev-like wall of if-elses rather than using math?
cause honestly i have no clue how to make a formula to calculate that
where does random.value come from? will it update with every call?
isnt the correct way to get a random number .Next() or so
comes from the unity game engine, yes it gives a random value every call
ah ok
hmm, could it be a flaw with the random function itself 🤔
It's Unity, so it's entirely possible ¯\_(ツ)_/¯
but technically there is nothing wrong with this code right? it should print out a proper bell curb of values?
I mean, the float values are pure magic
So hard to tell at a glance what it'll do
oh, nvm, got it
the difference bewteen 0.1358f and 0.0867f is too large
so naturally is assigns more values there, as it should
okay, fixed 👍
And here I wrote a nice test app lol
that's strange, why are the values in the random order, makes it hard to see discrepancies
Well, the values generated were random
So the
GroupBy()
took the first value of the kind, and grouped the rest to it
I can sort it, no problem
And let's crank up the numbers to 100k
yup, same result
there's a missing value
this 0.1095f
then it works properly
i missed it when i was copying from my excel lol
Where should it be?
after the next biggest one
after this > 0.1358f => 11,
and then reorder the numbers that are output
yup 👍
👍