Better Shuffling logic!!!
Before the refinement of the shuffling logic today I just simply randomized the numbers in the array, so that there are new numbers. That introduced one problem, actually two. Numbers could dupe!! I tried to fix it while using numbers with one decimal. The other problem was I could not add an animation anywhere. This is why I decided to make a brand new shuffling logic today. I first tried to fix the duping problem, by checking if this number already exists. This took a while, because I need to figure out how to only watch an array to a specific point, to ignore the upcoming numbers. This resulted in a growing or shrinking animation, which wasnt what I wanted. Then I thought, maybe I can shuffle in another way. Not by changing the value, rather by swapping numbers randomly. Just like in a deck of cards. So I loop through each digit and randomly choose a number in the whole array and then swapping those. This ensures every place got changed. Now there was another problem. It sometimes changed with it self causing it not to do anything. This was fixed by adding a while loop which generates new positions if the position is the own position. While writing this devlog I also thought of another problem. When the total count of numbers is very low, this shuffling method might not shuffle it enough, so I am looping it 2 times, if there are less then 10 numbers in it. Ya, thats about it. Now lets get to the slider which increases the blocks.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.