Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State via the API #48

Closed
benjaminpjones opened this issue Aug 29, 2022 · 10 comments
Closed

State via the API #48

benjaminpjones opened this issue Aug 29, 2022 · 10 comments
Labels
enhancement New feature or request high priority

Comments

@benjaminpjones
Copy link
Collaborator

benjaminpjones commented Aug 29, 2022

In hidden information games, the clients should not have access to the whole moves list. My thought is that the following endpoints can be created:

  • /games/%id%/state
  • /games/%id%/state/%seat% (partial state)

It would return the output of exportState().

@benjaminpjones benjaminpjones added the enhancement New feature or request label Aug 29, 2022
@benjaminpjones
Copy link
Collaborator Author

Can probably be done at the same time as #7

@merowin
Copy link
Collaborator

merowin commented Jan 26, 2024

My concern with this is the following. Currently the game view creates a whole game object, using all moves. That gives us a lot of flexibility; We can use the method nextToPlay, the gamePhase and result, the round method, etc.

One could argue that these things are (strictly speaking) part of what defines the game state. But currently we don't handle it that way. If we add all this to the exported game state, It might add a lot of complexity to the variants. And the api endpoint would be called a lot (e.g. when navigating through the moves).

@benjaminpjones
Copy link
Collaborator Author

I agree with the fact that it is nice to have the game object in the client. That said, I want to address this part specifically:

If we add all this to the exported game state, It might add a lot of complexity to the variants.

Passing nextToPlay, gamePhase etc. need not complicate variant implementations. We could also pass all these "common" attributes over the state API as well. The payload could look something like:

{
  "variant_state": { "board": [...], captures: {...} },  // output of exportState()
  "next_to_play": [0],
  "phase": "gameover",
  "result": "B+R",
  "round": 103,
}

That said, there are always multiple approaches to a problem. Is there a solution to "hidden information gets leaked via the API" that you see as preferable?

@merowin
Copy link
Collaborator

merowin commented Jan 26, 2024

I haven't worked out the details, but an alternative might be to allow variants to modify the move sequence before it is sent to clients.

Parallel move variants could remove the staged moves (except yours),
Hidden move variants could obfuscate moves

However, I'm not sure if its preferable. This approach might give us less flexibility that your proposal does.

@JonKo314
Copy link
Collaborator

One thing to consider: It might not always be possible to create the subjective game state by all moves that are shared with a user.

Example variant, like Baduk but:

  • Players only see their own moves
  • If they try to make an illegal move, they are prevented to make that move and may make a different move
  • Players are told, how many stones they have captured at any given moment

@merowin
Copy link
Collaborator

merowin commented Jan 28, 2024

Yeah, you two convinced me. I'm on board with this 🙂

@benjaminpjones
Copy link
Collaborator Author

benjaminpjones commented May 20, 2024

Marking this high priority as there are other related issues (#266, #174), and the cost of this tech debt grows quickly as other features are start to depend on the full game object existing client-side (#168, #214)

@merowin
Copy link
Collaborator

merowin commented May 24, 2024

I'm thinking on working on this next. I'm thinking of adding a server side endpoint like "get_game_state(gameId, round)"

With respect to the move navigation, that would mean that traversing through the move history, each round requires one network request. Just to make sure, are we (still) ok with that?

I believe there are alternatives that would optimize the data traffic etc. better, but 1.) would be a lot of work and 2.) probably add a lot of complexity to variants (especially hidden information variants).

@benjaminpjones
Copy link
Collaborator Author

I'm thinking on working on this next.

Wonderful! Many thanks in advance ☺️

With respect to the move navigation, that would mean that traversing through the move history, each round requires one network request. Just to make sure, are we (still) ok with that?

I'm okay with that. Fixing this is higher priority than network optimization IMO

I do have some ideas on the network optimization if/when we want to approach that though

@benjaminpjones
Copy link
Collaborator Author

We are now passing state thanks to #267

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request high priority
Projects
None yet
Development

No branches or pull requests

3 participants