Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Random Reaction Query.  (Read 550 times)

AxisofLint

  • Bay Watcher
    • View Profile
Random Reaction Query.
« on: September 07, 2009, 01:25:27 am »

I'm trying to make a reaction that will randomly produce a certain material. However, the reaction has the chance to produce say.. 10 different things, at a 10% chance per thing. But I'd like it to only produce one of those things each time it succeeds. Is it possible to do that?

(Ps, thanks for being so patient with my repeated questions!)
Logged

Kidiri

  • Bay Watcher
    • View Profile
Re: Random Reaction Query.
« Reply #1 on: September 07, 2009, 06:53:27 am »

I don't believe it's possible to have one random item made, but if you replace the 100 to be 10 for every PRODUCT, there's a 10% chance for every item it will be made. What you've done then, is made everything be made every 10% of the time. If you want twenty possible things, change it to 5. If you want x items, change it to 100/x. Note that I have no idea if decimals work.

So you'll get something like this:
Code: [Select]
[PRODUCT:10:1:normal:stuff:to:make]
[PRODUCT:10:1:normal:stuff:to:make]
[PRODUCT:10:1:normal:stuff:to:make]
[PRODUCT:10:1:normal:stuff:to:make]
[PRODUCT:10:1:normal:stuff:to:make]
[PRODUCT:10:1:normal:stuff:to:make]
[PRODUCT:10:1:normal:stuff:to:make]
[PRODUCT:10:1:normal:stuff:to:make]
[PRODUCT:10:1:normal:stuff:to:make]
[PRODUCT:10:1:normal:stuff:to:make]
Adding this in a reaction will result in the first thing made 10% of the time, the second 10% of the time, the third 10% of the time and so forth and so on. A side effect is that it will yield in any two random things every 1% of the time, three things 0.1%, four things 0.01% etcetera. And it can also result in nothing (or everything, for that matter), this every 0,0000000001% of the times (if my maths is correct).
Logged
Veni, Vidi, Pompeii.
Soylent Green is kittens!
Sometimes, when my Dorfs are exceptionally stupid again, I wonder what exactly the [INTELLIGENT]-tag does.

blah28722

  • Bay Watcher
    • View Profile
Re: Random Reaction Query.
« Reply #2 on: September 07, 2009, 10:51:52 am »

It'll actually result in nothing at about 35% of the time (.9 ^ 10 = .349)

I'd boost each thing up to 20% instead of 10%. That way, the chance of getting two items is still low at 4%, but the chance of getting nothing is lowered to 10%
Logged

AxisofLint

  • Bay Watcher
    • View Profile
Re: Random Reaction Query.
« Reply #3 on: September 07, 2009, 04:51:42 pm »

Thanks. I'd planned on just using percentages if nothing else was possible, but wanted to check.

I'm just going to play about with a 'transmutation' option in the smelter. Put in two bars of iron and you have a chance of getting back... some more iron.. or wood.. or maybe adamantium.
Logged

Taritus

  • Bay Watcher
    • View Profile
Re: Random Reaction Query.
« Reply #4 on: September 07, 2009, 05:10:18 pm »

I'm thinking instead of nothing around 35% of the time you'd more likely get nothing 90% of the time.  If I'm correct in assuming Toady didn't put much effort into the reactions code, it just generates a random number and checks if it's lower than the chance field.  If it is, you get that.
Logged



AxisofLint

  • Bay Watcher
    • View Profile
Re: Random Reaction Query.
« Reply #5 on: September 07, 2009, 07:47:02 pm »

To do with this.. is there any way to create a new building type?
Logged

blah28722

  • Bay Watcher
    • View Profile
Re: Random Reaction Query.
« Reply #6 on: September 07, 2009, 07:48:10 pm »

Nope.

Unless you mean creating a jello forge. Then yes, yes you can.
Logged

Footkerchief

  • Bay Watcher
  • The Juffo-Wup is strong in this place.
    • View Profile
Re: Random Reaction Query.
« Reply #7 on: September 07, 2009, 08:10:50 pm »

Nope.

Unless you mean creating a jello forge. Then yes, yes you can.

You do just mean modding reactions so that the smelter makes jello stuff, right?
Logged

blah28722

  • Bay Watcher
    • View Profile
Re: Random Reaction Query.
« Reply #8 on: September 07, 2009, 08:15:03 pm »

yep.
Logged