8 ms·
A multiplayer board game in Rust and WebAssembly
- deleted 6y ago[deleted]
- otachack 6y agoThis is great stuff. Thanks for sharing it, I'll be checking it out to learn more!
- baby 6y agoI’ve been thinking about writing a boardgame with websockets a lot. The technology is here, the current climate for online boardgame is here, but weirdly it’s not happening.
- grammarnazzzi 6y agoThat's great. Really awesome. Thanks for sharing
- nurettin 6y agoThe best part of having the same language on both the server and the client is that you can have the same code running client side validations and do the same move on the server to avoid cheating. If validations are only done on the client, they will just send a winning board state.
- filleduchaos 6y agoThere's zero need to have any validations[0] on the client in a turn-based online multiplayer game. If your state and logic aren't pretty much entirely on the server for that, you're doing it wrong. [0] Of course, for smoothness/convenience one could do some basic checks on the client.
- nicolodavis 6y agoThere 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.
- filleduchaos 6y agoYou can make the game progress without running validations or duplicating game logic on the client. For example, in the online multiplayer version of Ludo I'm currently building, I trigger the die roll animation on the client but the actual dice are rolled on the server, which then calculates what moves are possible based on the game state and sends that + the value of the roll to the client. The client doesn't know anything about the rules of Ludo, it simply knows how to parse and render the move format as well as send the ID of the picked move to its source of truth (in this case, the server). https://en.wikipedia.org/wiki/Ludo_(board_game) https://en.wikipedia.org/wiki/Ludo_(board_game)
- nicolodavis 6y agoIf 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?
- filleduchaos 6y agoYes. This is over websockets though, and in all of my testing/profiling (pretty shitty ISP in West Africa, game server is currently hosted in the US) I haven't had an exchange take longer than one second. Also the mandatory wait is just for the die - for picking a move, for instance, the client can go straight into rendering the selected move while sending it to the server.
- soylentgraham 6y agoDitto; the client side code needs no game logic, only aiding UX; dont let the user click outside a minesweeper board, but if it does, the server still validates. I made a System inspired by boardgame.io (but it was too integrated with react for me), which means i can write the game on the server without writing any client code at all. the client gets a list of valid moves, and my debug view gets error messages and a bunch of buttons & drop downs for parameters. https://github.com/NewChromantics/PopNotPoker/blob/master/Server/Games/Minesweeper.js https://github.com/NewChromantics/PopNotPoker/blob/master/Se... here's multiplayer minesweeper:) Http://not.poker All the real work is in the lobby code anyway.
- tonetheman 6y agoThis is the same thing Javascript programmers used to say to justify node.
- kzrdude 6y agoThere is not really any novelty in this kind of approach, I guess? Just that with .js it hasn't always been possible, but with other server-client games, it always was.
- nurettin 6y agoit has been possible with transpilers. Typescript works out of the box. Opal for ruby, Transcrypt for python, etc.
- ludston 6y agoCute game. You can get into a state where there are no valid moves though: https://imgur.com/1WLufcx https://imgur.com/1WLufcx
- mkeeter 6y agoIt's true! I considered adding some kind of fix for that, but a fresh game is a mere refresh away, and I liked the opinion on Board Game Geek [1]: > It's probably also worth noting that if this happens then all players involved need to re-visit some ideas of basic strategy. [1] https://boardgamegeek.com/thread/861192/if-game-stuck-perfectly-6x6-grid-then-what https://boardgamegeek.com/thread/861192/if-game-stuck-perfec...
- nicolodavis 6y agoNice! I'm using a very similar architecture for https://boardgamelab.app/ https://boardgamelab.app/. The WebAssembly performance boost will make a difference once I've implemented MCTS bots for the platform.
- kriro 6y agoVery nice. How do you auto generate the bots from the game rules? I'm assuming you just have them play the game a lot against each other and use genetic algorithms/reinforcement learning (you'd need some rules about scoring)? Do you have the option to generate different bot difficulty levels?
- nicolodavis 6y agoI'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.
- HugoDaniel 6y ago> "Is there a Rust + wasm version of Svelte yet?" Here is a Svelte starter template for Rust (webasm) + Svelte: https://github.com/HugoDaniel/svelte-template https://github.com/HugoDaniel/svelte-template
- chrismorgan 6y agoOP is asking for a Rust port of Svelte, rather than using Svelte itself and adding WASM code alongside. I started such a thing a while back, but progressively decided the design wasn’t right for Rust, and so headed in a somewhat different direction, and then shelved the project after deciding to implement what I had had in mind differently.
- HugoDaniel 6y agohow much better can it be than doing `import module from './crate/Cargo.toml'` from Svelte directly, and get Hot Module Reloading for free ?
- mrunkel 6y agoVery nice.. I am probably going to containerize this, would you be interested in a pull request?
- cozuya 6y agoDo you have the license or permission from the original creators to duplicate their IP?
- pjfin123 6y agoAt least in the U.S. game rules aren't covered by copyright even though the art and any expressions of the rules are. https://www.copyright.gov/fls/fl108.pdf https://www.copyright.gov/fls/fl108.pdf
- mkeeter 6y agoOriginal author here, happy to answer any questions. I also appreciate the load testing! For the curious, we're at 30 open rooms, and I'm seeing: - 0.0 server load - 2.6 MB of RAM used by nginx + its worker process - 4 MB used by pont-server
- silasrude 6y agoWill the rooms stick around if people leave the page in the middle of a game? My wife loves the game btw. I enjoy it as well but I appreciate the stack behind it more. Ty for your efforts.
- mkeeter 6y agoI'm glad that your wife enjoys the game! At the end of the day, it's meant to be played and shared, rather than just existing as an interesting software artifact. The rooms persist as long as there's at least one connected player in them. Exiting + rejoining a room under the same name will let you continue to accumulate points under that name. (Rejoining isn't perfectly seamless: you won't necessarily be dealt the exact same hand, and if you exit + rejoin while it's your turn, your turn will be skipped)
- dpc_pw 6y agoSome persistence timeout even without any players would be nice.
- mroche 6y ago> The game server using async Rust, which was... exciting As someone interested in Rust but not currently using it, what is the state of async? An expansion on the bullet points following regarding runtime scope would be interest.
- k_bx 6y agoI’m using Tokio and Async_std (Actix Web, redis, reqwest ), everything’s great and feels pretty mature, except for the scary part of no warning when using sync code from it.