0

Intro: I'm creating some game and I'd like to create an automated test for it.

Game scenario: There are r rooms, p game players, gm game masters, t is total test duration. Each room have it's own game master, so for example if there are 5 rooms - there will be 5 masters. Player chooses random room to play, room size is infinite, so it's not important how many players there will be in the room at the same time. Players are taken from player pool. For example, we have pool of players = 100, and we want to see only 30 players playing at the same time.

Problem: The mechanism of taking players and putting them in to random room is done, but I'd like to set random playing time for each player. This is where my brain shuts down. As if I want to set test total time to 30 minutes, I want all players finish the game by that time. So whenever player is being taken from the pool and he starts to play, I'm setting playing time, like this: player1.play(10);

So I was thinking about some sort of algorithm, which could set random time for each player, but it should keep in mind total test time and shouldn't exceed it. I mean that players are coming one by one and test should finish within set time and player pool should be exhausted as well (they are taken from the pool and never returned).

My thoughts so far: set test total time as duration, and each time, when we call "play" method, we look at the test duration - how much time is left? So the player game time wouldn't exceed this value. But there is an issue, that other players should have time to play as well. Probably this means, that I should split players between tables before test starts and set their total time to test duration and split it between players for each table. But as they can play in parallel at the same table this is quite hard to implement.

Sorry for long post, just wanted to describe it as much as possible. Any thoughts?

0

1 Answer 1

1

The problem with simply allocating each player a random amount of time is that the total may be much larger or much smaller than the overall available time. Therefore it makes more sense to allocate the weighting of the total time that each player can have randomly.

So pseudo code* would be

double totalWeighting=0

for each player
    player.weighting=randomPositiveNumber()
    totalWeighting+=player.weighting
end

for each player
    player.allocatedTime=(player.weighting/totalWeighting)*availableTime
end

Its necessary to go through twice so we know the totalWeighting before we allocate time


*some would say my pseudo code is highly non standard and looks too much like java, I would say: I don't like pseudo code

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your answer. As I said, there is another issue: as my players are joining random rooms, there is possibility, I'll have situation: player1 and player2 have 10 minutes to play and the test is 15 min long. After they leave, player3 and player4 are joining with 6 and 8 min playing time. I think runtime weighting is quite complex and I'm creating huge overhead for not so complex task :(
@britva And its impossible to know in advance which players/how many players will join which rooms? Is it a requirement that all players have equal likelyhood of getting a particular play time? Or can late joining players be given substatially less time on average?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.