Better HN
topnewbestaskshowjobs
Log inSign up

nicolodavis

370 karma · joined Nov 29, 2017 (8y ago) · 50 submissions

Submissions

comment 1y ago · link · parent

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.

comment 1y ago · link · parent

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.

comment 1y ago · link · parent

boardgame.io was created as a personal open-source project while I was employed at Google. It is not an official Google product.

comment 1y ago · link · parent

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.

comment 2y ago · link · parent

For academic literature, I would recommend reading:

1. James Ross: https://www3.nd.edu/~afreddos/courses/43151/ross-immateriali...

2. Edward Feser: https://www.newdualism.org/papers/E.Feser/Feser-acpq_2013.pd...

3. John Searle: https://philosophy.as.uky.edu/sites/default/files/Is%20the%2...

comment 2y ago · link · parent

If we're talking about some sort of computational system achieving consciousness, I'm curious how you can escape the fact that computation is observer-relative, i.e. the underlying representation of a computation has no semantics, and requires an external entity to provide an interpretation.

comment 2y ago · link · parent

Great to hear about the revival of sacred music in your diocese.

Do you happen to have any links to the documents that your previous bishop wrote?

comment 4y ago · link · parent

You could consider using a library like boardgame.io for this.

comment 5y ago · link · parent

Wanted to add that Lisp maps quite well to visual programming languages: https://boardgamelab.app/blog/visual-scripting/

You get the benefits of writing code composed of neat delineated expressions that nest arbitrarily but without the verbosity that parentheses add to the source file.

10.

Autogenerated Screenshots in Markdown(nicolodavis.com ↗)

2 points · by nicolodavis · 6y ago · discuss

11.

Generating Screenshots from Markup(nicolodavis.com ↗)

1 points · by nicolodavis · 6y ago · discuss

comment 6y ago · link · parent

Do you have specific examples of what is difficult to understand in the standard books for a non-native speaker?

Just asking out of curiosity and maybe readers can learn a thing or two about making documentation more accessible.

comment 6y ago · link · parent

That's right. For my use-case I decided to just stick with JS for UI stuff (using Svelte). I call into Rust code like a black box to update some state.

comment 6y ago · link · parent

No reason except that I've written Go in the past and wanted to learn a new language :)

Comparing the two languages, I would say that Rust's enums and pattern matching make it easier to work with for my specific use case.

comment 6y ago · link · parent

The Rollup plugin linked to in the article produces JS functions that call into WASM code. JS objects are automatically converted to Rust structs via Serde and vice-versa.

I use TypeScript / Svelte for DOM interactions and only call into Rust code for the state updates (treating it like a black box).

comment 6y ago · link · parent

Something like this is valid TypeScript I think?

  interface MyType {
      a: number;
  }

  function process(value: MyType) {
      console.log(value);
  }

  const value = { a: 1, b: 2 };

  process(value);

comment 6y ago · link · parent

Note that Rust is only used for the state updates. All the UI stuff is TypeScript (using Svelte).

comment 6y ago · link · parent

Thanks for the link! I'll look into this for my other TypeScript codebases.

comment 6y ago · link · parent

Hey Amit, good to hear from you!

> Javascript is fast enough for your use case. No one will notice the difference in a board game website.

No, actually. Have you seen how long boardgame.io's MCTS bot takes to make a Tic-Tac-Toe move? Not the end of the world, but certainly in need of improvement.

comment 6y ago · link · parent

Yep, I don't think Rust is quite there yet for web dev. I didn't use Rust for any frontend interactions. The web app is an SPA written in Svelte. I only used it for the core state update logic, which benefits from the typing and performance boost.

comment 6y ago · link · parent

That's correct. You have to insert validation code at all the entry points, which was the case for me.

Moving to Rust doesn't eliminate validation altogether, but you don't have to do any type related validation which is nice.

comment 6y ago · link · parent

I'm just using an SPA written in Svelte on the frontend. I only use Rust for the game state updates.

About measurements, I just whipped up a quick benchmark comparing the JavaScript state updates with the WASM version. You do pay a cost crossing the JS / WASM boundary, but the WASM version is faster overall for my application. I'm not particularly concerned with performance at the moment (it was just a nice to have).

23.

Moving from TypeScript to Rust / WebAssembly(nicolodavis.com ↗)

500 points · by nicolodavis · 6y ago · 405 comments

24.

The Grim Reaper Paradox (2008)(alexanderpruss.blogspot.com ↗)

2 points · by nicolodavis · 6y ago · discuss

comment 6y ago · link · parent

@soylentgraham: You should check out the recent releases of https://boardgame.io/. The tutorials are now rewritten with a focus on the plain JS client (no React).

comment 6y ago · link · parent

I'm assuming that you're asking about Boardgame Lab (from the other comment).

The basic version just uses Monte Carlo Tree Search and the game's victory condition to play the game. This won't result in a very strong bot for most games, but is a reasonable opponent to play your game against (which is very useful when designing a game).

Options to make the bot stronger involve giving it hints and shorter term objectives.

comment 6y ago · link · parent

If I understand your architecture correctly, your client has to wait for the network roundtrip before being able to see the result of the die roll, correct?

comment 6y ago · link · parent

There is value in making the game progress client-side without waiting for a response from the server. Having the game logic run on both sides gives you the best of both worlds: 1. One authoritative version of the game state on the server. 2. Lag-free experience on the client.

comment 6y ago · link · parent

Nice!

I'm using a very similar architecture for https://boardgamelab.app/.

The WebAssembly performance boost will make a difference once I've implemented MCTS bots for the platform.

comment 6y ago · link · parent

This lecture at Stanford is a great breakdown of the philosophical understanding of what consciousness is and how that relates to artificial intelligence: https://soundcloud.com/thomisticinstitute/artificial-intelli...
12