This content originally appeared on DEV Community and was authored by InHuOfficial
I found myself needing to create a basic system that takes a word or phrase as a seed and returns some "random numbers" that were repeatable if the same seed were entered.
Obviously they aren't actually random but I needed something that would spit out completely different numbers for "aaaa" compared to "aaab" for example.
Think of it like a very dumbed down version of how Minecraft generates worlds based on the seed you enter.
To test it out I decided to build a "design your own burger" system based on your name or a phrase!
As far as I can tell it works and it can actually be quite good fun trying different names and seeing if the resulting burger matches that persons personality!
Instructions
Super simple!
Step 1
Enter your name or a phrase in the first input (minimum 4 characters).
Your unique burger combination will show below once you have entered enough characters! Keep trying words, phrases, your name etc. until you find a beautiful burger. (it is case sensitive so try capitalised and not capitalised).
Step 2
Once you have found a burger combination you like (or hate and think would be funny) press the "Copy Markdown to clipboard" button below the ingredients list (or select and copy all the text in the <textarea>
below the button).
Step 3
Paste the Markdown into a comment under the article.
Be sure to change the rating (if your burger creation isn't a 10 that is ?) and if you want you can give your burger a silly description!
Oh and if you find a truly disgusting burger combination be sure to share that also!
Try it out!
Don't forget to share your creations / your username burger in the comments!
My favourites
Here are 3 burgers I created:
The InHuOfficial Burger
I couldn't possibly not share our very own burger namesake!
Apart from the blue cheese (not a fan) it seems like a beauty, double turkey bacon and bacon plus halloumi...delicious!
Username or phrase: InHuOfficial
Item | Ingredients |
---|---|
Bun | sesame seed |
Patties | elk burger patty, beef burger patty |
Sauces | chow chow, hot sauce, guacamole |
Toppings | turkey bacon, bacon, turkey bacon |
Cheeses | grilled halloumi, American cheese, blue cheese (stilton) |
Salads | coleslaw |
My rating out of 10: 9
My super serious description ?: Eating this burger will improve your accessibility skills 200%!
The Independence Day burger
Had to fiddle a little bit to get a burger fit for America!
Three patties, American Cheese and a double helping of sweet potato fries seems like a good fit!
Username or phrase: 04th July
Item | Ingredients |
---|---|
Bun | crusty |
Patties | chicken breast burger patty, beef burger patty, bean burger patty |
Sauces | ranch dressing, chimichurri, sweet chilli |
Toppings | sweet potato fries, serrano ham, sweet potato fries |
Cheeses | american cheese |
Salads | lettuce, gherkin / pickles |
My rating out of 10: 8
My super serious description ?: Nearly all American, if anything it perfectly reflects America in 2021 - American at the core with a nice sprinkling of flavours from other Countries and cultures to keep it interesting. A must try this July 4th!
The Ben Burger
How could we not include dev.to founder Ben?
The hilarious thing is it is an Elk burger (that is a Canadian thing right? Sorry I am an ignorant Brit)...and it has Maple Syrup on it....I couldn't stop laughing at the sterotype ???!
In all seriousness though I think this sounds like it could be delicious! Joe Rogan would obviously approve given his obsession with Elk!
Username or phrase: Ben Halpern
Item | Ingredients |
---|---|
Bun | sesame seed |
Patties | elk burger patty |
Sauces | maple syrup, bbq |
Toppings | serrano ham, onion rings, pulled pork |
Cheeses | american cheese, goats cheese |
Salads | coleslaw, roasted red peppers |
My rating out of 10: 10
My super serious description ?: This burger proves Ben is Canadian. I don't think I could have made it better if I tried! ??
A few little bits
No tutorial for this one, just some interesting bits of info.
There are over 29 BILLION different burgers that this generator can create.
If you ate one variation a day it would take you 79.6 million years to try them all.
It is probably flawed due to the way I built it so maybe there will be duplicates. It is just a silly project after all and my brain hurts already. If someone sees a flaw please point it out.
If you want to dig into my shoddy code here is a link to the fiddle: https://jsfiddle.net/aoc2L06p/
The key is
var seededRandom = function(seed, max, min) {
max = max || 1000000000;
min = min || 137;
seed = (seed * 9301 + 49297) % 233280;
var rnd = seed / 233280;
return Math.round(min + rnd * (max - min), 0);
}
Apparently the numbers used on lines 5 and 6 are carefully calculated to produce a very even appearance of random numbers.
Unfortunately I couldn't track down the article that explained it.
Conclusion
From my testing it appears to work fine. The actual seededRandom
function does what I need it to do and that was where this all started.
So what is YOUR Burger? Does your name create a better burger than "Ben Halpern", "InHuOfficial" or "04th July"? Give it a try!
This content originally appeared on DEV Community and was authored by InHuOfficial
InHuOfficial | Sciencx (2021-06-27T07:56:38+00:00) What ? burger ? are you? Enter your name to find out! [Demo Using Repeatable “Random” Numbers / Seeds]. Retrieved from https://www.scien.cx/2021/06/27/what-%f0%9f%8d%94-burger-%f0%9f%8d%94-are-you-enter-your-name-to-find-out-demo-using-repeatable-random-numbers-seeds/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.