Live data from Hacker News

Boardgame.io: an engine for creating turn-based games using JavaScript

github.com

61–69 of 69 posts

Re: Boardgame.io: an engine for creating turn-based games using JavaScript

#62

This engine uses a Redux-like architecture. You have a State type (containing data like "the position of the black kingside rook") and a stream of in-game actions (like "knight to F3"). Each action is handled by a pure function which converts the current State to a new State. You can either transmit State deltas from the server to the client, or just transmit the actions themselves ( https://longwelwind.net/blog/netw…

I agree that asynchronous flows are hard to represent using a state object.

I chose to go with a monadic approach in boardgamelab.app (I'm not limited by language features since I'm designing it from the ground up for this use case). The language is pure and functional with managed effects. You can express things like:

  set of cards -> filter by action cards -> choose -> [card]
  do stuff with [card]
written in a synchronous style, while under the hood it:

1. suspends the rule.

2. waits for the user to make a choice.

3. resumes the rule with the choice made by the user.

(note: listed above is a simplified text representation. The Boardgame Lab structure editor uses a block-based visual language.)

If written in Haskell, the underlying monad would look something like this:

  {-# LANGUAGE ExistentialQuantification #-}

  newtype Rule a = Rule {fn :: State -> (RuleResult a, State)}

  data RuleResult a
    = Done a
    | forall x. Show x => Choose [x] (x -> Rule a)

  instance Monad Rule where
    m >>= k = Rule $ \state ->
      case fn m state of
        (Done a, state') -> fn (k a) state'
        (Choose list m', state') -> (Choose list (m' >=> k), state')
i.e. each rule returns either a completed result or a choice along with a continuation of the remainder of the rule past that choice.

Re: Boardgame.io: an engine for creating turn-based games using JavaScript

#63
post #46

Earlier quoted context omitted.

My main pain point with any sort of Flux-like state management is transitions [1]. The state of UI is not fully described by the state of the game [2]. If I play a card, the game state can be instantly updated to the next decison-making point, but in reality I want to show steps of the game through animations, some of which are concurrent and some of which are consecutive. That usually ends up in a mess; and I've nev…

I toyed with an approach once that separated animations from game state updates. Every player action could cause a cascade of updates, which would all be resolved “instantly” to the point no more cascaded updates were left to be processed. While this is happening, any update that includes an animation pushes that to an “animation stack”, then the animations are played back one by one to show the player what happened.…

I've found in the past its good to have the model updates in the queue so that the animation controllers can be simpler. The animations simply need to observe the model and react to changes, and post events when they complete.

Re: Boardgame.io: an engine for creating turn-based games using JavaScript

#64

Earlier quoted context omitted.

How does secret state fit in this? If you want each player hand to be secret, then each player has its own state?

boardgame.io only runs game logic on the server, and it censors the State just before sending it to each client. This strategy makes the UI feel less responsive, but it keeps things simple. The Swords and Ravens blog post recommends resolving actions on the client when they don't require secret information, but resolving other actions on the server. You'd also need to resolve actions on the server when they involve R…

I don't recommend resolving actions on the server in any situation:

For actions that require secret information, you would filter the actions sent to the client of any secret information and make sure the code handling the action can handle both the action and the filtered actins.

For actions involving RNG, make all randomness rely on a seed. This seed would be stored server-side and passed along the action when sent to the client. This makes sure the clients can deterministically reproduce the update.

Re: Boardgame.io: an engine for creating turn-based games using JavaScript

#66
post #24

Earlier quoted context omitted.

What do you mean by stealth? I looked at the website and nothing about it makes it look like it would necessarily be free or open source.

Still needs clearer language IMO.

I just checked and it says MIT licensed. What am I missing?

Re: Boardgame.io: an engine for creating turn-based games using JavaScript

#67

This engine uses a Redux-like architecture. You have a State type (containing data like "the position of the black kingside rook") and a stream of in-game actions (like "knight to F3"). Each action is handled by a pure function which converts the current State to a new State. You can either transmit State deltas from the server to the client, or just transmit the actions themselves ( https://longwelwind.net/blog/netw…

My main pain point with any sort of Flux-like state management is transitions [1]. The state of UI is not fully described by the state of the game [2]. If I play a card, the game state can be instantly updated to the next decison-making point, but in reality I want to show steps of the game through animations, some of which are concurrent and some of which are consecutive. That usually ends up in a mess; and I've nev…

I agree fully with [1], having recently experienced the pain of implementing a custom drag-and-drop UI in React.

I ended up using ref's heavily to avoid stale closure and async re-render issues. Which basically amounts to circumventing React and interacting with the DOM directly.

Re: Boardgame.io: an engine for creating turn-based games using JavaScript

#68
post #66
post #24

Earlier quoted context omitted.

Still needs clearer language IMO.

I just checked and it says MIT licensed. What am I missing?

I think you might be conflating boardgame.io and boardgamelab.app.

boardgame.io - MIT licensed open-source JS library.

boardgamelab.app - Proprietary platform for designing and playtesting board games.

Re: Boardgame.io: an engine for creating turn-based games using JavaScript

#69
I’m quite ignorant of JS development with Node. This package really interests me so I followed the tutorial. On the second step, I used npm to install boardgame.io which triggered a barrage of error messages related to deprecated packages and 69 vulnerabilities. I ran npm audit and it displayed numerous high severity. I tried the npm audit —force which broke boardgame.io I don’t plan on trying to fix these problems so does it mean that I shouldn’t try boardgame.io?
Post reply on HN