Skip to content
This repository has been archived by the owner on Dec 22, 2020. It is now read-only.

Get game data from server [help needed] #45

Open
rocketinventor opened this issue Mar 22, 2017 · 4 comments
Open

Get game data from server [help needed] #45

rocketinventor opened this issue Mar 22, 2017 · 4 comments

Comments

@rocketinventor
Copy link
Contributor

rocketinventor commented Mar 22, 2017

I am trying to get various gameplay data from the server in order to use it for the client. The data that I am looking for includes the raw data (which pieces are currently on the board, move history, and the score, komi, etc if available. My priority right now is the raw data so that I can add a sync mechanism to address possible game-state mismatches (#27).

Any help would be greatly appreciated!

@rocketinventor rocketinventor changed the title Get game data from server Get game data from server [help needed] Mar 23, 2017
@macfergus
Copy link
Collaborator

This is a good question. Currently the GoBoard class in goboard.py tracks only the current state of the board. Nothing tracks history, komi, captures, etc, not even whose turn it is.

One solution is to wrap the GoBoard class in some kind of Game class that can contain a game tree and some other state. I think this would be straightforward and pretty clean but I haven't fully thought it through yet.

@rocketinventor
Copy link
Contributor Author

@macfergus Right now my main concern is extracting the current state of the board (likely from the context of model.py). How do I do that?

Capturing the game tree, as you described, might require some further conversation but, it is definitely something to look into for the future.

@macfergus
Copy link
Collaborator

macfergus commented Mar 28, 2017

I think the quickest way for now is to loop over self.bot.go_board somewhere in HTTPFrontend. It will look something like this:

json_board = []
for row in range(19):
  for col in range(19):
    piece = self.bot.go_board.board.get((row, col))
    # piece will be 'w' 'b' or None
    # put this into json_board somehow
return jsonify(json_board)

LMK if that gets you started!

@rocketinventor
Copy link
Contributor Author

@macfergus Thanks! That helped out a lot!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants