Live data from Hacker News

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

github.com

31–40 of 69 posts

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

#31

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…

Yep, that's the exact issue I wanted to address with my own twist on the idea of an online boardgame engine - I was trying to actually persist the callstack of an async wasm vm function (game loop) execution into a database in rust. It is working in a sense that you can implement battle ships or tick tack toe, but I did not quite finish it. Happy to still make repo public if helpful.

To be more specific, async wasm function was implemented as a poll loop sync function exported to the caller, there was (at the time) no way to move wasm mv memory, so it was persisted while the game was live and replayed from a message log stored in a db after/if preemption.

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

#32

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…

The way I wanted to implement this in my turn-based game engine:

If you implement the deterministic update pattern to handle state synchronisation you can add "event" inside the logic that handles updates that pause the processing allowing your animations to be played. In JS, for example:

    async function handleUpdate(update) {
        if (update.type == "sell-items") {
            this.player.inventory[update.itemId] -= 1;

            await emitEvent("itemSold");

            this.player.money += 10;

            await emitEvent("moneyGain");
        }
    }
Server-side, "emitEvents" would be a no-op. Everything would resolve synchronously.

Client-side, the UI can listen to those events to pause the updating of the game state to see the intermediary state of the game and play animations. When the animation is done, it can resolve the promise, resuming the game updating logic.

If an update arrives while an update is being handled, it can be queued so it can be played after the current update finishes.

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

#33
post #25

Earlier quoted context omitted.

Can you explain more what type of game would need a call stack snapshot? I've never developed a game, but it seems like as long as you store like the initial state and prng you could always get the current state by replaying the full history. All the other logic would be stored outside the state, and only added when "committed". As long as prng is stable and you start from the clean state every time, you'd get the sa…

I think I have a good example from Magic: the Gathering. There’s a card called “Fact or Fiction”. You reveal the top five cards of your deck. Then your opponent splits the cards into two piles. Then you pick one of the two piles to take into your hand. You’ll need to store structures representing the choices that are intermediary steps (split cards, pick stack) in your state, which is basically function calls and the…

I had the same issue in AGoT:BG and I solved it by representing the state of the game as a tree. At any point of the game, the current game state is a leaf of the tree.

You'd represent this kind of choice as a child node. When the user has made their choice, the code can return to the parent node with the choice being made so it can continue with the next "step" of the game.

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

#34
I tried to use this before, but many parts didn't really work right, lots of conflict between dependencies, especially the server parts. I had to abandon what I wanted to do with it. Shame because many ideas were interesting, but felt it was a bit untested.

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

#35

Original creator of boardgame.io here. A pleasant surprise to see this here after many years. More recently, I've been working on https://boardgamelab.app/ , which uses a visual programming language to model game rules while also taking care of the UI layer.

I feel like saying that is supports AI players, but not having a simple, already hosted example is a disservice. Even tic tac toe, or go fish would be a nice hook to help people understand what it actually delivers.

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

#37

Is there a simple demo that one can test? I see a tutorial about tic tac toe, but the result doesn't seem to be hosted anywhere.

The tutorial page[1] has a link to open an interactive sandbox with a TicTacToe example. The link is titled "Edit in CodeSandbox".

1. https://boardgame.io/documentation/#/tutorial

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

#38

Original creator of boardgame.io here. A pleasant surprise to see this here after many years. More recently, I've been working on https://boardgamelab.app/ , which uses a visual programming language to model game rules while also taking care of the UI layer.

There was this iOS game which died which I wanted to recreate:

https://web.archive.org/web/20161020010853/http://www.82apps...

But I have 0 knowledge of game development. Maybe this could make my job easier? Or maybe somebody else who know how to write game can do it? Please?

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

#39
post #10

Earlier quoted context omitted.

Put the screen on the kitchen table and sit around it, call it CounterTop Surface, have a little imagination man.

You say this like a joke, but that would bring a lot of usability and convenience improvements compared to a physical board game. Just moving stuff out of and back into the box can take a lot of work. It's easy to overlook rules that a computerized game automatically handles for you, though. For example, I'm part of a group that plays Heat ( https://boardgamearena.com/gamepanel?game=heat ) every week. An important pa…

> and since the platform handles that, only one person in the group.

This should read "only one person in the group knows how it works".

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

#40

Original creator of boardgame.io here. A pleasant surprise to see this here after many years. More recently, I've been working on https://boardgamelab.app/ , which uses a visual programming language to model game rules while also taking care of the UI layer.

> More recently, I've been working on https://boardgamelab.app/ , which uses a visual programming language to model game rules while also taking care of the UI layer. Suppose there were a technology that could turn the canvas you authored into finished, consistent art; and a way to turn natural language rules into correct code. Would you use it? Why or why not?

It would be great to save time on the implementation of board game rules engines. Unfortunately the fine folks at FFG are really bad at figuring out what the rules actually are and telling people :(
Post reply on HN