You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that I need to manually keep game and board objects synchronized, which seems odd.
Why can't I pass a game object to the board constructor, and have the board always display the progress of the game, for example? If I want to "undo" a move, I can't just pop a position from the game and have the board update - I need to somehow track or recover what the most recent move is, and update both in sync.
Am I missing something?
The text was updated successfully, but these errors were encountered:
I'm trying just running something like this after each game update, but it seems wasteful:
board.removeAllObjects();
for ( var x = 0; x < game.size; x++) {
for ( var y = 0; y < game.size; y++) {
var obj = game.getStone(x,y);
if (obj){
board.addObject({x:x,y:y,c:obj});
}
}
}
(edited: i made a mistake, this is working, though it seems wasteful)
I have improved this to keeping a stack of state objects from board getState and using restoreState so at least this is done incrementally, but I still seem to be keeping extra copies of state and busywork just to keep the board displaying the state of the game.
It seems that I need to manually keep
game
andboard
objects synchronized, which seems odd.Why can't I pass a
game
object to theboard
constructor, and have the board always display the progress of the game, for example? If I want to "undo" a move, I can't just pop a position from the game and have the board update - I need to somehow track or recover what the most recent move is, and update both in sync.Am I missing something?
The text was updated successfully, but these errors were encountered: