[erlang-questions] How to implement the A Star find path algorithm using NIF?

skyman cloudzen@REDACTED
Mon Jul 10 19:03:33 CEST 2017

Hi Dmitry,

Thanks for your reply.
The map of our game is large(1000 * 1000 grids). If I use NIF to implement the A Star find path in C, can I allocate the map grid array(1000 * 1000) in C, and when map blocks changed, Erlang calls 'updateBlock' NIF to update the grid state in grid array in C?


At 2017-07-11 00:33:34, "Dmitry Kolesnikov" <dmkolesnikov@REDACTED> wrote:


On 10 Jul 2017, at 19.11, skyman <cloudzen@REDACTED> wrote:

Hi everybody,

Our game is using A Star algorithm to find path. For performance I want to write it in C language, and Erlang calls it by NIF. I don't know whether the map data is maintained in C or in Erlang. Can anyone tell me?

Map is native data structure. However, you need to use enif interface to interact with it. 

In addition, is there any better solution than NIF?

I’ve used to solve a “routing” issues on pure Erlang using ETS, lists, etc. However, this mainly depends on your traffic, latency and size of routing tables. It is hard to give a straight forward answer not knowing this figures.      

Thanks very much!

Best Regards, 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170711/fcce541f/attachment.htm>

More information about the erlang-questions mailing list