I’m trying to create a small RPG simulator that will simulate a fight between a team of players and a boss of some sort.
- Each boss and player has a skill level.
- If a team is composed entirely of members who are of equal level of skill as the boss they are fighting, they should win half of the time. If they are 3 levels above the boss, they should win 3/4ths of the time. If they are 3 levels below the boss, they should win 1/4th of the time.
- To win a boss fight, at least half of the team has to survive 10 “ticks”. During each tick, each player is given a probability of death that is based half upon his own person skill level, and half upon the average of the rest of the players of the team.
The goal is to simulate the domino effect of team deaths. If one person dies, the rest of the team is less likely to be able to survive. If every player in the team is the exact same level as the boss, they’ll win 50%, but if it’s just the group average that is equal to the boss and some of the players are several levels below, this might make it more likely that the team will fail since those members will have a higher chance of death and their deaths will lesten the group average, which is counted half against the remaining players.
But, for the life of me I can’t figure out how to calculate the odds I should give each person for each tick.
I was thinking that if, for instance, I wanted half to live (in the case where all players are the same level and even with the boss) that it was simply a matter of figuring out what percentage of deaths would compound into 50% over ten runs.
0.5 = x^10
x = 0.5^0.1
x = ~0.933
But, since the players individual levels are shrunk as people die, when it goes back in to calculate for the levels of players on the second tick (for instance), they’re no longer even with the boss. Instead they’re (I think) half they’re own average, which is even with the boss, and half the average of their group which is 93.3% dead. So where as before the fight, each individual player had a == rating with the boss which translates to a 50% chance of death @ the end of 10 ticks, their lowered level gives them something more like 48.3% chance the second tick, which makes my code calculate:
0.483 = x^10
x = 0.483^0.1
x = ~0.930
So during the second tick, slightly more people will die than are intended, and during the third even more, and so on. In total, the team can only half survive for seven or eight ticks instead of the projected ten.
I’m not sure how to work back to figure out what odds to give for each tick when the result is based on the result of the previous.
I hope this makes sense…