Skip to content

Hold a stored tile under the global seed and its coordinate #59

Description

@KurbyDoo

Background

The store holds a tile under a single number worked out from the global seed and the tile coordinate together. That has to change for two reasons.

The store needs to hold tiles from more than one world at a time, so the seed has to stay part of how a tile is named rather than being folded away.

And squashing three numbers into one is rebuilding, badly, what the language already does. A pair or triple can be used directly as a key, and two different triples stay different keys even when they happen to land in the same place internally, because they get compared for equality after that. A number worked out by hand gets no such comparison. Two tiles that land on the same number become one tile, the store hands back terrain from the wrong world or the wrong place, and nothing signals it.

Keeping the coordinate also leaves the store able to say where the tiles it holds sit in the world, which anything that later decides what to keep by distance would need.

Description

Change the store so a tile is put in and taken back out under the global seed together with its tile coordinate, all three used directly, instead of under a single number worked out from them.

Nothing else about the store changes. It still holds a limited number of tiles and still drops the least recently used one to make room.

Two different global seeds are two different worlds and must never share a tile. Two different coordinates under one seed must never share one either.

Do not work the three numbers into one somewhere else instead. The point is that the three stay separate all the way to the lookup.

This supersedes the lines in #31, #39 and #44 that say a tile is identified by its seed.

Testing:

  • Assert a tile put in under a seed and coordinate comes back out under that same seed and coordinate
  • Assert the same coordinate under two different seeds holds two separate tiles
  • Assert two different coordinates under one seed hold two separate tiles
  • Assert tiles from two worlds can be held at the same time without either replacing the other
  • Assert asking for a coordinate that has not been generated returns nothing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions