Skip to content

Throw away the least recently used tile when the store is full #45

Description

@KurbyDoo

Background

The reason finished grids are held per tile rather than per region is that an endless world has to be explorable in a fixed amount of memory. That only works if old tiles get dropped.

Description

Give the store a limit on how many finished tiles it holds. When a new tile is added and the limit has been reached, drop the one that was used least recently.

Reading a tile counts as using it, not just writing one. A tile that gets read constantly must never be the one dropped.

Testing:

  • Assert the store never holds more tiles than its limit
  • Assert adding a tile past the limit drops the least recently used one and not simply the oldest one added
  • Assert reading a tile moves it to the back of the queue so it is not the next one dropped
  • Assert a tile that was dropped can be generated again and put back

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