#BlazeBin - mzdbumjioxij
1 messages · Page 1 of 1 (latest)
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
which I can't wait to know of!!!!
OK, are you sitting comfortably?
just on the crappy kitchen chair, but that'll do!
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
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!
do you understand what the logic of this is?
not yet, I'd need to apply it first, this version of code doesn't speak for itself to me.
try it with 10 pieces of paper with numbers written on them
ok that was somehow way more confusing, just time...
if you have a problem give me a shout
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
no, not whitelist.Length. a separate length variable which you decrease with every choice
oh that was a minus minus!!
and length and rand should both be ints, only value needs to be byte
should should? or can?
should otherwise you are doing unnecessary casting
got this!
ok! (here)'s what I ended up doing => https://paste.mod.gg/qwuoqbxhqppr/0; @wind beacon
whatcha think?
A tool for sharing your source code with the world!
looks ok, you just need to stop it at 0 and reset length to whitelist.Length if you want to play/shuffle again
you really should try the logic with 10 pieces of paper irl, it will enlighten you
so... I prepare 10 pieces of paper with numbers written on them and, ... what?
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
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?
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
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
my guess is it would go back to ancient Greece, Roman or Islamic times
thanks for the help so far! I guess I'm gonna call it a happy ending.
Similar but not quite
Fisher-Yates is more like what you were trying to do with your original algorythm
so I can official say I made an algorithm all by myself??? 😳
well, yes, it's just that it didn't work, so I'm not too sure how much kudos you will get from it
🥹