Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple pathfinding in PHP

Tags:

algorithm

php

Does anyone know if there is a simple way to do pathfinding in PHP?

I basically have a list of numbers, e.g.

  • {origin:11485,outboundDirections:"11486,11487,11488"}
  • {origin:11487,outboundDirections:"11485,11676,94185"}

and getting from 11485 to 94185 would result in 11485>11487>94185 with ways to "exit", and I'm trying to figure out how to do this (it doesn't really have to be shortest path or anything AI-like, just a way to get from A to B)

I have no idea where to start at all, unfortunately

like image 937
pdx Avatar asked Dec 08 '25 09:12

pdx


1 Answers

I have recently started and opensourced a flexible pathfinding script in PHP, using the A* algorithm primarily. The idea being to give a node graph object with the most basic methods necessary that the algorithm needs to explore the node graph and get H and G costs.

It would work very easily with your list of numbers since it also uses integers to refer to nodes.

See: https://github.com/Nexii-Malthus/phpPathfinding

like image 89
Nexii Malthus Avatar answered Dec 09 '25 22:12

Nexii Malthus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!