[General Multiplayer] How is calculated the "player response time" in multiplayer mode?

Hi all of you !

I was wondering how to respect the allowed time for playing each move.

If we’re supposed to simply check our current time to play with Date.now(), I think that’s a little weird, as we don’t know the total available CPU power, and its current charge (potentially hundreds of AI bots playing at the same time).

Or do you provide us with a magical function returning how much CPU time we used ?

Thanks in advance !

No magical function provided. Just get current time in milliseconds after reading the first input to have your starting time.

1 Like

currentTime - startTime < (maxTurnTime - 10ms)

Usually works without timeouts.

1 Like

Thank you. Yes, actually that’s logic.
But so, for a given period, we’re not sure of the amount of computation our bot will be able to do,
which can impact our chance to win, depending of the current CPU usage.
Unless each bot is assigned a fixed CPU % amount, and additional bots are waiting their turn in a queue… Do you know about it ?

Every time a game is run it gets a locked to a single CPU core for the duration (and only one game can be locked to each core at any time) which is used to run the all the involved players code. Outside of your turn your execution gets frozen so you don’t affect the other players. Theres probably a bit of background usage by the OS etc, but generally you’ll pretty much have 100% of the CPU time for your turn.


Thank you, that’s exactly the answer I was waiting for !