It's just as the title says.
For the time being, we are working on the following items.
def hoge(n)
# Generate an array with a true pair false of n to 100-n and randomly select one
([true]*n + [false]*(100-n)) .sample
end
If not, I would appreciate it if you could advise me on the method.
ruby
I have the same question in the English version, so I will quote it.
def choice (weight=50)
land<=weight/100.0
end
How about
https://stackoverflow.com/questions/16965686/how-to-randomly-choose-true-false-w-weight-in-ruby
© 2024 OneMinuteCode. All rights reserved.