1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Pick Random Line

Discussion in 'General Software' started by FordGT90Concept, Apr 25, 2012.

  1. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    13,962 (6.25/day)
    Thanks Received:
    3,803
    Location:
    IA, USA
    Takes input either from a file (drag and drop on the executable supported) or from typing with one "item" per line. Click on "Pick One" and it will select a random line and place it in the result textbox where it can be copied/manipulated. This is great for having a computer make up your mind when you can't.

    Requires .NET Framework 4.0 (Client Profile).

    [​IMG]

    In 1.1, I added the "Weighted Delimiter" field which, if it contains something, will attempt to split the line with the first part being the weight and the second part being the value. For example, if I set "Weighted Delimiter" to a semicolon (;) and then input this line: 2.1;MyValue MyValue would be weighted to 2.1 (default is 1.0). If there was another line containing NormalValue, MyValue should get picked 2.1 times more frequently than NormalValue.

    Here's an example of what I used to test. I'm using /// for the delimiter.
    [​IMG]

    Note: Due to rounding errors, the last item will always be slightly more preferred than the rest. In my test, Mercenaries 2 had a percentage of 0.078740157480315 while Supreme Commander 2 had a percentage of 0.078740157480315. They matched in that case but in effect, it is adding 0.00000000000000011 to the last. This isn't likely going to matter unless you're doing something scientific but something you should be aware of.

    If you want to eliminate that rounding error, theoretically, you could add a 0///value at the very end. It should completely eliminate that 0.00000000000000011 from picking a line.

    Version history:
    -1.2.0: Fixed bug where last line wouldn't be picked if not using weights. Added drag and drop for files on the file name box and text on the main text box.
    -1.1.0: Added the ability to weight lines. See the above "spoiler" for details.
    -1.0.0: First release.
     

    Attached Files:

    Last edited: Aug 22, 2012
    Chevalr1c, qubit, Phusius and 2 others say thanks.
    Crunching for Team TPU
  2. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    13,962 (6.25/day)
    Thanks Received:
    3,803
    Location:
    IA, USA
    Uploaded 1.1.0. It nows supports weighting lines. Details of how to use that feature are in the "Weighted Lines" spoiler. If you don't use that feature, it is functionally identical to 1.0.0.
     
    Crunching for Team TPU
  3. TheMailMan78

    TheMailMan78 Big Member

    Joined:
    Jun 3, 2007
    Messages:
    21,186 (7.75/day)
    Thanks Received:
    7,709
    Just get married. You will never have to make up your mind again. She will do it for you and you don't even need to install .NET Framework 4.0
     
  4. manofthem

    manofthem

    Joined:
    Jan 9, 2011
    Messages:
    6,334 (4.47/day)
    Thanks Received:
    8,634
    So Ford this would be good for picking a winner for the next game giveaway? I'm all for it if so!
     
    Crunching for Team TPU
  5. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    13,962 (6.25/day)
    Thanks Received:
    3,803
    Location:
    IA, USA
    Yeah, that's what it was originally created for. The weighting was added to make it easier to decide what game to play (lower weights for games we've already beat/started).
     
    manofthem says thanks.
    Crunching for Team TPU
  6. manofthem

    manofthem

    Joined:
    Jan 9, 2011
    Messages:
    6,334 (4.47/day)
    Thanks Received:
    8,634
    Very cool, I'll try it out this weekend! Thanks
     
    Crunching for Team TPU
  7. manofthem

    manofthem

    Joined:
    Jan 9, 2011
    Messages:
    6,334 (4.47/day)
    Thanks Received:
    8,634
    Hey Ford, beer me a minute of your time (haha, Office reference). Can you look to see if you get the same thing that i'm getting... If i input say 10 numbers/names, it seems to never choose the last one. I tried with 4, 10, and 11 entries. These are just normal, nonweighted entries. Maybe it's user error, but i'd appreciate the insight.
     
    Jizzler and FordGT90Concept say thanks.
    Crunching for Team TPU
  8. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    13,962 (6.25/day)
    Thanks Received:
    3,803
    Location:
    IA, USA
    You're right. I'm sure I checked for that but must have some how broke it. I'll see about fixing it.

    Also, I wanted to add drag n drop support so I might as well do that too while I'm at it.
     
    manofthem says thanks.
    Crunching for Team TPU
  9. manofthem

    manofthem

    Joined:
    Jan 9, 2011
    Messages:
    6,334 (4.47/day)
    Thanks Received:
    8,634
    That would be terrific. I tried to drag and drop something earlier, just not thinking, but that would be pretty awesome.

    With the other issue, the temporary workaround is to just add another line, anything I suppose, and it'll suite me just fine. Thanks for looking into, and thanks for the great utility, really good for giveaways lol!
    :toast:
     
    Crunching for Team TPU
  10. Jizzler

    Jizzler

    Joined:
    Aug 10, 2007
    Messages:
    3,454 (1.30/day)
    Thanks Received:
    645
    Location:
    Geneva, FL, USA
    Bug confirmed.

    [​IMG]

    It just won't pick that last line ;)
     

    Attached Files:

    FordGT90Concept says thanks.
  11. qubit

    qubit Overclocked quantum bit

    Joined:
    Dec 6, 2007
    Messages:
    9,872 (3.88/day)
    Thanks Received:
    3,502
    Location:
    Quantum well (UK)
    Typical little utility to write for when you have too much time on your hands. I like it. :)

    @mailman: it sounds like you need to move on to Wife 2.0. ;)
     
  12. manofthem

    manofthem

    Joined:
    Jan 9, 2011
    Messages:
    6,334 (4.47/day)
    Thanks Received:
    8,634
    Crunching for Team TPU
  13. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    13,962 (6.25/day)
    Thanks Received:
    3,803
    Location:
    IA, USA
    Jizzler and manofthem say thanks.
    Crunching for Team TPU
  14. manofthem

    manofthem

    Joined:
    Jan 9, 2011
    Messages:
    6,334 (4.47/day)
    Thanks Received:
    8,634
    Thank you kind sir, that was quick!
     
    Crunching for Team TPU

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page