I'm trying to program a line of Ruby code that calculates the probable success rate of a simple skill test in a text adventure game. The test is "if x + random(12) => y then". How do I calculate the probable rate of success of this statement being true in Ruby?
In the game the player has certain skills and will occasionally have to test those skills plus a random number to get greater or equal to a given difficulty number. I want to calculate the success rate percentage of being able to win that skill test.
As an example in the adventure game your trying to track some animal through the jungle. To do this you must test your skill at tracking. If for example you have a tracking skill of 3 and you add a random number between 1-12 to that, you need to score at least a 9 or greater to succeed. Basically: Skill + random(12) => Difficulty_Number. I want to show a Success Rate percentage before they play to see what their chance of succeeding will be.
So in Ruby, what would be the algorithm to figure out the chance of success with my current Skill score? Thanks!