I am programming in python I was wondering how in games layer the chance of the object to fall out.

Closed due to the fact that the question is too general by the participants Jarvis_J , jfs , Kromster , 0xdb , andreymal Jun 27, '18 at 10:29 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • As the formula is written, and layered. Usually just by multiplying - x = base * (1 + chance1) * (1 + chance2) - Kromster
  • specify the question. Depending on the algorithm, there may not be any settings at all, for some algorithms it is sometimes useful to set the seed explicitly, sometimes to choose the algorithm itself (speed, statistical properties, predictability) - jfs
  • Well, let's say if I'm not a very experienced programmer and I need to write a text RPG and they need such a formula (preferably the simplest) - MioMelliot

1 answer 1

Damn while waiting for an answer, I almost died and even before someone could solve the problem

 def zon_itm(self): #определяет тип a=random.randrange(1,1000) if a <= 1000 and a >= 250: return ('обычный') elif a < 250 and a >= 100: return ('редкий') elif a < 100 and a >= 10: return ('эпический') elif a < 10 and a >= 1: return ('легендарный') 
  • Comparisons a <= 1000 and a >= 1 can be removed, there is no benefit from them. You can also remove the first comparison in each elif , they also do not bring anything new, but only complicate the reading of the code. - Enikeyshchik
  • self in def zon_itm(self): also not needed (self not used) - this method can be made a function or a static class method. The parentheses in return are also not needed. Range checks are complicated - just poke that a <= значение to determine value - gil9red
  • one
  • @ gil9red and what does author = 'ipetrash' do this line - MioMelliot
  • @ gil9red ?????? - MioMelliot pm