#BlazeBin - mzdbumjioxij

1 messages · Page 1 of 1 (latest)

wind beacon
#

your problem is here

 (byte firstArg, byte LastArg) args = (whiteList.FirstOrDefault(), whiteList.LastOrDefault());

as long as 0 and 60 are not choisen (sic) this will always return the same values.
There is a better, more efficient way to do this

mint plinth
#

which I can't wait to know of!!!!

wind beacon
#

OK, are you sitting comfortably?

mint plinth
#

just on the crappy kitchen chair, but that'll do!

wind beacon
#

start with

byte[] whitelist and populate with numbers 0 thru 60
int len = 60;

then

int ix = random from 0 to len
byte val = whitelist[ix]
len --;
whitelist[ix] = whitelist[len]
whitelist[len] = val;

See if that makes sense to you

#

when len reaches 0 you can reset it to 60 to start again. The array will be constantly shuffled

mint plinth
#

ok! ok! just give me time to apply all of that and give feedback ASAP! but might not be able to stay online for as long!

wind beacon
#

do you understand what the logic of this is?

mint plinth
#

not yet, I'd need to apply it first, this version of code doesn't speak for itself to me.

wind beacon
#

try it with 10 pieces of paper with numbers written on them

mint plinth
#

ok that was somehow way more confusing, just time...

wind beacon
#

if you have a problem give me a shout

mint plinth
#

shoawr

#

ok, I got the first part... but then things just are obfuscated!

here it is so farcs byte length = (byte)whiteList.Length; byte rand = (byte)Random.Range(0, length); byte value = whiteList[rand];ORcs byte value = whiteList[(byte)Random.Range(0, whiteList.Length)];

#

and here's your shout @wind beacon

wind beacon
mint plinth
#

oh that was a minus minus!!

wind beacon
#

and length and rand should both be ints, only value needs to be byte

mint plinth
#

should should? or can?

wind beacon
#

should otherwise you are doing unnecessary casting

mint plinth
#

got this!

wind beacon
#

you really should try the logic with 10 pieces of paper irl, it will enlighten you

mint plinth
wind beacon
#

actually you need 11 pieces. the first 10 you number 1 thru 10 and on the 11th (we will call it Length) you write 10

#

then lay the first 10 out in front of you

mint plinth
#

I got curious after this and read a few about random shuffling on the wiki... out of curiosity, do you know the name of the algorithm?

wind beacon
#

no, sorry, I've been using it for so long it's origins are lost in the mists of time

#

I do remember teaching students with the 'paper' irl back in the '70's

mint plinth
#

oh that old it is! gonna try to make that ai bot figure its name out then!

#

oh it's the one I read about! Fisher-Yates Shuffle

wind beacon
#

my guess is it would go back to ancient Greece, Roman or Islamic times

mint plinth
#

thanks for the help so far! I guess I'm gonna call it a happy ending.

wind beacon
#

Fisher-Yates is more like what you were trying to do with your original algorythm

mint plinth
#

so I can official say I made an algorithm all by myself??? 😳

wind beacon
#

well, yes, it's just that it didn't work, so I'm not too sure how much kudos you will get from it

mint plinth
#

🥹