Coder Social home page Coder Social logo

Feature request: Caching about hex-grid HOT 3 OPEN

mgrider avatar mgrider commented on June 19, 2024
Feature request: Caching

from hex-grid.

Comments (3)

fananek avatar fananek commented on June 19, 2024

It is a good point. In AI opponent programming, some kind of caching is inevitable. Especially for recursive algorithms. Even though caching wasn't originally planned to be part of the library, it could be an interesting feature.

While caching brings performance benefits, it also raises some issues. We should think a bit about:

  • what shall be cached
  • cache invalidation
  • memory usage
  • thread safety
  • cache storage (memory, disk)

If we want to implement caching mechanism, I would use some more generic and reusable solution. For example, LRU/LFU algorithm sounds like a potential fit. It uses a priority queue which is already in place (used by an a-star algorithm)

Here is one more reading. Just for reference.

from hex-grid.

mgrider avatar mgrider commented on June 19, 2024

Hi František, Yes, I see the benefits of using LRU/LFU immediately. I'll update my implementation to use one of those, and reply here when I have something to look at and/or review. Thanks!

from hex-grid.

mgrider avatar mgrider commented on June 19, 2024

Looking a bit closer at this... it's not so simple as I'd at first imagined. The values that we'll be caching are different types of thing. I could imagine using a cache object for the neighbors example above, for instance, but then you'd need a different cache for allCellsCoordinates. I could imagine making it generic somehow, so both would be stored in the same cache, but then you've got wildly different "sized" objects stored. I'm not really sure what makes sense, at this point.

I did find an additional article with a more complete example (but pretty similar to the second reference you posted above).

from hex-grid.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.