Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

shuffling an array

07kmd07kmd Member Posts: 1
I'm trying to create a Boggle like game with letter cubes being populated with a letter from an array and I'm stuck. Stuck like don't even know where to start. Well almost don't know where to start. I have 16 rich text boxes and a string array for each box. I have a button that ideally would cause all 16 cubes to have a single letter in it. any suggestions would be very much appreciated! Thanks

Comments

  • zibadianzibadian Member Posts: 6,349
    : I'm trying to create a Boggle like game with letter cubes being
    : populated with a letter from an array and I'm stuck. Stuck like
    : don't even know where to start. Well almost don't know where to
    : start. I have 16 rich text boxes and a string array for each box.
    : I have a button that ideally would cause all 16 cubes to have a
    : single letter in it. any suggestions would be very much
    : appreciated! Thanks
    :
    To shuffle the letters around, I would use the bubble sort with a randomly 50% chance of swapping the array elements. This will "sort" the array into a random order, without any new letters appearing.
  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    : : I'm trying to create a Boggle like game with letter cubes being
    : : populated with a letter from an array and I'm stuck. Stuck like
    : : don't even know where to start. Well almost don't know where to
    : : start. I have 16 rich text boxes and a string array for each box.
    : : I have a button that ideally would cause all 16 cubes to have a
    : : single letter in it. any suggestions would be very much
    : : appreciated! Thanks
    : :
    : To shuffle the letters around, I would use the bubble sort with a
    : randomly 50% chance of swapping the array elements. This will "sort"
    : the array into a random order, without any new letters appearing.

    Well it would work, sort-off. However, using 50% chance bubble sort means it's a high probability that a number will stay very close to where it is.
    And even if that's not the case, im not sure if each character has an equal 'random chance'.

    I always use a system where I take all the numbers I want to shuffle, then divide them at random by picking the first, generating a random position and placing it there. Then the second, random position only this time with one less spot (since there is already one item occupying the spot). It takes a bit of code tweaking to get it right.
    Anyway, in my opinion it's easier to program than bubble sort (somehow that algo always remains a bit fuzzy to me).

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
Sign In or Register to comment.