menehune23

Member Since: April 22, 2012

Country: United States

  • These LED buttons would make an awesome DIY BCD clock kit! You could use the buttons as a nifty way to set the time in HH:MM:SS format. I submitted the project idea to your team via the Contact Us form last week ;)

  • Awesome to hear you had success with the randomSeed() call! You can also call randomSeed(millis()) at the start of a new game in cases where you have no unused pins (I use it on my Meggy Jr RGB). This would also work well since Binary Blaster has something analogous to a “startup screen”, where the time spent there is indeterminate, and the time between games is indeterminate too.

    If I were to implement a random sorter, I would probably do something like what’s below (to balance efficiency and readability):

    struct BinaryValue
    {
        byte value;
        byte sorter;
    
        BinaryValue(byte val)
        {
            value = val;
            sorter = random(99);
        }
    };
    
    BinaryValue valsToGuess[15];
    
    for (int i = 1; i < 16; i++)
    {
        valsToGuess[i] = BinaryValue(i);
    }
    
    QuickSort(valsToGuess, 15);
    

    where QuickSort is a standard in-place quick-sort algorithm, with the only modification being that the BinaryValue.sorter value is used in the comparisons instead of the binary value itself.

    In answer to your third question, I’m more thinking about getting reasonably far from less interesting cases like sorter = random(2), where two numbers have a higher chance of staying next to each other. I haven’t validated the math but if you use random(x + 1), then the chance of two sorter numbers colliding (resulting in the binary values staying next to each other) would be (1 / x)2, which is asymptotic in its plot. So eventually, for a large value of x, increasing x wouldn’t have as much of an effect on randomness.

  • Thanks for the response :) I haven’t looked at the code yet, but it seems at first glance to be a random seed issue. As far as a random sorting algorithm, I wonder if you could try assigning a random number (seeded, of course) from some large range (say 0 to 99; larger than [0, 15] to reduce probability of duplicates) to each of the decimal values 0-15, then sort on their random sorter value (we’ll see how this formatting comes out):

    // Sample unsorted data { <binaryValue>, <sorterValue> }
    { 0, 45 }
    { 1, 12 }
    { 2, 88 }
    { 3, 27 }
    { 4, 97 }
    { 5, 32 }
    { 6, 90 }
    { 7, 18 }
    { 8, 41 }
    { 9, 65 }
    { 10, 17 }
    { 11, 23 }
    { 12, 76 }
    { 13, 53 }
    { 14, 10 }
    { 15, 67 }
    
  • Anyone else notice that the numbers always come in the same order on a power cycle?

No public wish lists :(