• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Pick Random Line

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,263 (4.30/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
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).

pick_random_line_1_1_0.png


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.
WeightedExample.png


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.
 

Attachments

Last edited:
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.
 
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
 
So Ford this would be good for picking a winner for the next game giveaway? I'm all for it if so!
 
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).
 
Very cool, I'll try it out this weekend! Thanks
 
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.
 
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.
 
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.

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:
 
Bug confirmed.

random-line-bug.png


It just won't pick that last line ;)
 
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. ;)
 
Back
Top