Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Non-blocking mode for BWEnv #211

Merged
merged 1 commit into from
Oct 31, 2017
Merged

Non-blocking mode for BWEnv #211

merged 1 commit into from
Oct 31, 2017

Conversation

jgehring
Copy link
Member

In non-blocking mode, BWEnv will block the game for a specified maximum amount
of time only before continuing. This enables abiding time limits for a given
match-up without adding complicated timing logic to the TorchCraft client
program.

If the client does not send commands for the current frame back in time (e.g.
receive in BWEnv times out), the game continues and a new attempt to receive
them will take place in the very next frame and so on until we finally get a
reply. If BWEnv absolutely has to send the frame (e.g. the game or battle is
over), it will perform a blocking receive call before sending it to abide the
REQ/REP pattern.

Please note the interplay with the SET_COMBINE_FRAMES option: BWEnv can only
send frame data to the client after having a received a message with commands.
Hence, if it is unable to send new frame data it will keep combining frames and
eventually send the combined frame in the next execution of
Controller::onFrame() after the successful receive. Hence, SET_COMBINE_FRAMES
defines a minimum number of combined frames for non-blocking mode.

The default behavior is blocking mode (i.e. the same as before). It can be
enabled specifically via the new SET_BLOCKING command. The timeout can also be
set via a new command; by default it's 50ms.

@@ -145,13 +149,17 @@ class Controller {
static const int pixelsPerTile = 32;
static const int pixelsPerWalkTile = 8;
bool logCommands = true;
int combine_frames = 1;
int max_combine_frames = 1;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should actually be named min_combine_frames. Will update.

@jgehring jgehring changed the base branch from remove-czmq to master October 17, 2017 20:18
@jgehring jgehring changed the base branch from master to develop October 17, 2017 20:18
In non-blocking mode, BWEnv will block the game for a specified maximum amount
of time only before continuing. This enables abiding time limits for a given
match-up without adding complicated timing logic to the TorchCraft client
program.

If the client does not send commands for the current frame back in time (e.g.
receive in BWEnv times out), the game continues and a new attempt to receive
them will take place in the very next frame and so on until we finally get a
reply. If BWEnv absolutely has to send the frame (e.g. the game or battle is
over), it will perform a blocking receive call before sending it to abide the
REQ/REP pattern.

Please note the interplay with the SET_COMBINE_FRAMES option: BWEnv can only
send frame data to the client after having a received a message with commands.
Hence, if it is unable to send new frame data it will keep combining frames and
eventually send the combined frame in the next execution of
`Controller::onFrame()` after the successful receive. Hence, SET_COMBINE_FRAMES
defines a *minimum* number of combined frames for non-blocking mode.

The default behavior is blocking mode (i.e. the same as before). It can be
enabled specifically via the new SET_BLOCKING command. The timeout can also be
set via a new command; by default it's 50ms.
@jgehring jgehring merged commit ecfc816 into develop Oct 31, 2017
@jgehring jgehring deleted the bwenv-nonblocking branch October 31, 2017 13:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants