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
The View Component does not need the entire state represented in the Go::Game object. It only needs enough information to display the state of the game that is relevant in the browser. This is the position of the stones, the current player, and the captured stones.
We can represent the position of the stones as an Array of length 81 for the 9x9 board. The initial game state will have an array of nil and as stones are added to the board, the symbols :black and :white will be used to mark where to display them. The Black player goes first, and we have zero captures at the start of the game, so the inital state could look something like this:
For now, this is all we need to draw the display of the game, and we can use this data structure (either a hash like this or a Struct) in our View Component hooked into Motion.
As of right now, the code does not implement this. Instead it passes an entire Go::Game object to the View Component. This is due to the way updating the game state and checking legal moves is implemented. Detangling these would be a great improvement. The view component can update its state and then ask the game logic if it is a legal state before updating the "central" server state that all of the view components will use to
The text was updated successfully, but these errors were encountered:
View State
The View Component does not need the entire state represented in the
Go::Game
object. It only needs enough information to display the state of the game that is relevant in the browser. This is the position of the stones, the current player, and the captured stones.We can represent the position of the stones as an
Array
of length 81 for the 9x9 board. The initial game state will have an array ofnil
and as stones are added to the board, the symbols:black
and:white
will be used to mark where to display them. The Black player goes first, and we have zero captures at the start of the game, so the inital state could look something like this:For now, this is all we need to draw the display of the game, and we can use this data structure (either a hash like this or a Struct) in our View Component hooked into Motion.
As of right now, the code does not implement this. Instead it passes an entire
Go::Game
object to the View Component. This is due to the way updating the game state and checking legal moves is implemented. Detangling these would be a great improvement. The view component can update its state and then ask the game logic if it is a legal state before updating the "central" server state that all of the view components will use toThe text was updated successfully, but these errors were encountered: