Giter Club home page Giter Club logo

Comments (8)

MichaelMackus avatar MichaelMackus commented on May 17, 2024 1

from libtcod.

HexDecimal avatar HexDecimal commented on May 17, 2024 1

Thanks for sharing your own examples.

A malloc on each queue push isn't good for performance. It harms threading and memory locality.

It's tricky to figure out what I'd even want to do. I really want something that's flexible.

Maybe if I redid the C pathfinder I could make one that takes a C callback to define the graph. I don't think I'll do this until I've implemented something similar in C++, or maybe I can try to backport the complicated Python-tcod pathfinder.

from libtcod.

HexDecimal avatar HexDecimal commented on May 17, 2024

I've been in the middle of a rewrite of the pathfinder for a long time now. I haven't been happy with what I've done so far, and my plans have been ambitious.

I want to remove the 2D limit, allow a custom heuristic function, and a custom graph function.

The C++ templates in the src/libtcod/pathfinding directory do what I want, but I need to somehow port these to C99.

from libtcod.

HexDecimal avatar HexDecimal commented on May 17, 2024

Thinking back on this I should have just made the C++ templates more accessible and not worried about what was available in C.

It was really easy to set up a new pathfinder in C++. The hard part was that I need to figure out how to handle the inputs and outputs of the pathfinding computation data, since there's no standard multi dimensional array type in C++.

from libtcod.

MichaelMackus avatar MichaelMackus commented on May 17, 2024

from libtcod.

MichaelMackus avatar MichaelMackus commented on May 17, 2024

from libtcod.

HexDecimal avatar HexDecimal commented on May 17, 2024

The main dependency I used was a priority queue I believe.

This is the main part. It's trivial to implement a pathfinder after you have access to a good priority queue. I have one in libtcod but the interface is too weird and I don't want to lock it in by making it public.

I know in my haskell roguelike I pass in a function to the A* algorithm which returns all neighboring points for a given point.

I'll need to do this for C sometime. I've previously done it with C++ templates but it might be easy enough to make a simple C callback work in a similar way. I'm still missing a good C container for the array of distances/path-costs.

from libtcod.

HexDecimal avatar HexDecimal commented on May 17, 2024

Simple things like "what is the size of an index" are not so easy to resolve in C. This is one of the things which made the internal heap queue turn out weird.

from libtcod.

Related Issues (20)

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.