You are viewing a single comment's thread from:
RE: Steem Monsters Tech Talk - Steem Blockchain Integration
If I buy a monster pack, is the transaction id used as a component in the random distribution of the pack I receive?
If I buy a monster pack, is the transaction id used as a component in the random distribution of the pack I receive?
This is an awesome question! This is something I have thought about and would REALLY like to do, but I'm not sure how to implement it in a way that provides an even distribution. What I need is a way to take the transaction ID and generate N integers from it between 0 and X such that each integer has a roughly equal probability of being generated.
If you (or anyone else reading this) are able to provide that algorithm I will definitely get it implemented right away!
You could use the transaction ID as the seed to your random number generator of choice and then generate those N numbers from that generator in a consistent fashion (like the first N calls to the random number generator).
Yes I think this is what I will do. I found a JS random number generator that can be seeded (since Math.random() cannot) here: https://www.npmjs.com/package/seedrandom
Thank you!
Yeah, Javascript's build in random number generator is pretty primitive. The package you found looks like it will do the trick just fine. You just reminded me I keep wanting to play around more with Node.js...just need to make some time.
The transaction hash is already strong random number. Let's take eg. first 3 digits to get an ID of draw card.
It would probably be less important if there is a set number of monsters like it is at the moment. But if you ever go in the direction of procedurally generated monsters, I would find it very compelling if the procedure was posted publically and the generation routine was cryptographically verifiable from the data in the blockchain.
I agree 100%! I will work on updating what we have so it is cryptographically verifiable and then publish the details. Probably a good topic for my next "tech talk" post. Thank you!
How are trxids generated? I feel like I should know this already, and I'm almost embarrassed to ask.
Anyway, care must be taken to ensure that good cards can't be mined. If you use blockchain data to seed your RNG, you probably still need to add randomness on your end before generating cards.
Love the project, by the way! My starter pack contained no legendaries, so no worries there. ;)