Skip to content

Deal and write the same in JavaScript as on .NET - #38

Closed
leonitousconforti wants to merge 8 commits into
mainfrom
fable-parity
Closed

leonitousconforti wants to merge 8 commits into
mainfrom
fable-parity

Conversation

@leonitousconforti

Copy link
Copy Markdown
Owner

Makes a seeded game compiled with Fable deal the cards it deals on .NET, and makes strategy and targeting strings read the same on both. Seeded games deal on .NET what they always have, only faster.

  • Deck.DrawWith makes the Random calls FSharp.Core's shuffle makes and walks the Map to the card, where Fable's shuffle dealt other cards
  • A second chance goes to the first of the players tied furthest behind under Fable too, where List.minBy keeps the last
  • Under Fable, floats are written as .NET's ToString("R") writes them, keeping -0 and writing exponents like 1E-07 and 1E+21
  • The obsolete helpers draw from System.Random() instead of Random.Shared on both platforms, so their five #if !FABLE_COMPILER blocks go
  • The other maxBy, max and List.randomChoiceWith uses already agree, except where NaN is involved

Checked locally: fantomas, build, tests, pack, the Fable compile, and a seeded-game transcript that is identical on .NET, under jsc and on main. 525k draws take 149-162 ms, against 525-565 ms on main.

@leonitousconforti

Copy link
Copy Markdown
Owner Author

Closing in favour of fixing these in Fable, so flip7 doesn't have to re-implement FSharp.Core:

The tests from this PR move to #39, which lists the ones that fail in JavaScript until those fixes ship.

@leonitousconforti
leonitousconforti deleted the fable-parity branch November 6, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant