title: Game duration algorithm
body: <p><strong>Intro:</strong>
  I'm creating some game and I'd like to create an automated test for it. </p>
  
  <p><strong>Game scenario:</strong>
  There are <em>r</em> rooms, <em>p</em> game players, <em>gm</em> game masters, <em>t</em> 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. </p>
  
  <p><strong>Problem:</strong>
  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: <code>player1.play(10);</code></p>
  
  <p>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). </p>
  
  <p>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. </p>
  
  <p>Sorry for long post, just wanted to describe it as much as possible. Any thoughts? </p>