Categories
Games

Battle Royale Model

In a battle royale game like Tetris 99 or Fortnite, a player’s rank does not absolutely reflect their skill level. Just by chance, a strong player may encounter a stronger player early on in the match. Since ranking is by elimination and time, a skilled player may be eliminated early and thus rank low.

I thought it would be interesting to model this phenomenon with Python.

In the following code, a list, “s”, of 10 members, stands for 10 players. The numbers 0 to 9 give the skill levels of players, with 0 being the strongest and 9, the weakest.

Two numbers are pulled from the list randomly, then compared.

The larger number is added to the rank list, “r”. The smaller number is added back to the pool of players.

At the end, zero is appended to the rank list because zero always wins. The rank list, “r”, is reversed to give the ranks their proper placements.

#Battle Royale Model

from random import choice

r = []
s = list(range(10))

while len(s) > 1:
    x = choice(s)
    s.remove(x)
    y = choice(s)
    s.remove(y)
    if x < y:
        r.append(y)
        s.append(x)
    else:
        r.append(x)
        s.append(y)

r.append(0)
r.reverse()

print(r)

Here is some output:

[0, 2, 8, 7, 1, 6, 5, 9, 3, 4]

Notice, Player 1 is ranked in the upper half, but barely; yet Player 1 is better than 80% of the players.

Also, although Player 9 is worst in skill, he made 8th place, rather than 10th or last place. One interpretation of this is that in battle royale games, hiding is a good strategy.

Leave a Reply

Your email address will not be published. Required fields are marked *