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

skyman <>
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?


Thanks!





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

Hello,


On 10 Jul 2017, at 19.11, skyman <> 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. 
http://erlang.org/doc/man/erl_nif.html#enif_get_map_value


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, 
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170711/fcce541f/attachment.html>


More information about the erlang-questions mailing list