Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix world DSL hash primitive to depend on seed #1989

Merged
merged 1 commit into from
Jun 25, 2024
Merged

Conversation

byorgey
Copy link
Member

@byorgey byorgey commented Jun 25, 2024

It turns out that the hash primitive was always computing the same deterministic hash of the coordinates regardless of the seed. This meant that e.g. any world features placed in a way that depended on the hash were always in the same locations, and if you created a world that only relied on hash and not on, say, Perlin noise, it would always look the same regardless of the seed. This does not seem desirable.

This PR fixes the DSL interpreter by passing the seed to the murmur3 hash function (we used to always pass the constant seed 0). In theory, this does mean that all the "classic" worlds are now slightly different than what they used to be (except for seed 0). However, there's no way to tell the difference between one random placement and another. The only scenario where we really depend on the particular locations of entities for a particular seed is the world101 tutorial, but that used seed 0 anyway, which did not change.

Depends on merging #1988 first.

Base automatically changed from push-munwpnkvlzkq to main June 25, 2024 21:37
@byorgey byorgey added the merge me Trigger the merge process of the Pull request. label Jun 25, 2024
@mergify mergify bot merged commit 939ecf3 into main Jun 25, 2024
12 checks passed
@byorgey byorgey deleted the push-rxokpkpuxtxn branch June 25, 2024 22:14
mergify bot pushed a commit that referenced this pull request Jun 26, 2024
Adds a new primitive `imap`, aka index map, primitive to the world DSL.  `imap` has type `World int -> World int -> World a -> World a`.  Think of it like `(Coords -> Coords) -> World a -> World a`, i.e. given a coordinate mapping, it creates a new world by looking up the cell at the transformed coordinates in the given base world.  However, since there are no lambdas we cannot directly give it that type; instead, the first `World int` represents a function `Coords -> int` which gives an x coordinate, and the second gives the y coordinate.  All told, `imap wx wy wa` is like `\c -> wa (wx c, wy c)`.  For example, `imap (-x) y w` is a reflection of `w` across the y-axis.

Adds a description of `imap` to the language reference, as well as adding a few examples.

Also removes the `rot` and `reflect` primitives, since they can now be simply implemented in terms of `imap`.

Depends on merging #1989 first.  Closes #1584.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants