Making browser games more secure with Elm, Part 2

@Erkal_Selman wrote the second part of our post explaining how the recording system works and why Elm’s limitations made it possible to fulfill requirements that other languages would not have been able to.

7 Likes

Thanks for the post!

A while back I made a similar system for a game, though I used it let the user save replays rather than as a cheat prevention measure. One concern I had was, as I understand it, floating point math can potentially be non-deterministic between CPU architectures (and maybe between browsers too?). I was never able to reproduce this non-determinism or find a source that exactly spelled out what floating point math can be non-deterministic (is it just trig functions or can +, -, *, / also be non-deterministic?), and is it a problem now or was it only an issue in the past.

This might not matter for your game since it looks like it doesn’t need to use floats anywhere but I’m curious if this is something you researched or if you ever had issues with it?

Edit: I got a score of 55788!

4 Likes

The blogpost made me daydream about compiling some constrained Elm main (the mentioned Computer with predetermined basic set of Msgs, extensible by the user of course) to a native SDL2 game (C / C++ / Rust / Zig I guess?).

For games like that (not thinking about WebGL for now), it seems like it could be a productive sweet spot: no need to figure out a general C FFI, some high-level Cmds to allow for “save/load your model” functionality would probably be enough initially.

Functionality-wise, probably somewhere around the old “pre-YoYo Games” versions of Game Maker that I grew up with :smiley:

Of course, it would most likely require me and whoever’s interested to get a move on with elm-in-elm (or somebody to write a quick compiler with elm-syntax) to provide such a C/… backend and runtime lib :sweat_smile:

2 Likes

we didn’t worry about floating point math and hoped that all browsers do it by the standard :crossed_fingers:

Fair enough, that’s what I do too. But note that the standard lets some details be decided by the implementer. Math.cos for example says

Returns an implementation-dependent approximation to the cosine of x.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.