average value of dice rolls. Game mechanics

dataguy101

New member
Joined
Feb 13, 2017
Messages
1
For "fun" I'm performing some data analytics on a PC game to try and optimize my characters. I'm enjoying figuring out the math myself so I'll only share part of a problem I just can't get started on. I can use what you all share to apply to other calculations I'll need to write code for later. Here it is:

"A bag contains tiles, each with one number from 10 to 22 printed on them. (10, 11, 12, 13 etc.)
Larry reaches into the bag and randomly pull out one tile to read the number
Next, he divides the value on the tile in half and then subtracts 5.
If the new value is great than 1/5 of the value of the tile, Larry writes down the new value, otherwise Larry writes down whatever 1/5 of the tile value is.
Larry repeats the above process as many times as he likes recording the numbers in sequence.
After Larry is done, what will be the average value of the numbers he has written down?"

Now If I ignore the IF statement, I have no problem recognizing that the floor becomes 0 and the max value is 6 after these calculation are performed.. I can average those and get an answer of 3. [((10/2 -5)+(10/2-5)/2)=3] or after factoring [(10+22)/2/2-5 = 3]

However the Conditional statement throws me off. I have no idea where to begin writing an expression where this floor value is not a constant. Or maybe it is and i just can't see it? I cheated and ran a quick 1000 simulations in excel to get a rough final answer of 3.6 but I'd prefer to develop a useful equation as it will simplify the code I'm writing for the rest of my calculations. (not to mention the excel random number generator is not that great. If we're gonna do this lets do it right!)

Is it possible to write an equation for this?
 
Top