Page 1 of 1

Alien pathfinder thru API ?

Posted: Sat Aug 20, 2016 2:32 pm
by binbinhfr
Hi,

I just ask in case, because I did not find anything, but is there an access to the pathfinder thru the API ?
For example : I want to know if there is a "free" path between point A and B ? (no walls, no water, etc...)

because my problem is that sometimes I want to launch alien attacks from A to B (using LUAsurface.set_multi_command for example), but there is no path, or B is on an island, or whatever.
Then aliens get stuck in place, not moving anymore...

Re: Alien pathfinder thru API ?

Posted: Sat Aug 20, 2016 10:14 pm
by aubergine18
I've seen some pathfinder stuff in the API but not checked to see what it does exactly, here's some links I'd noted down:

http://lua-api.factorio.com/latest/LuaF ... inder_busy

http://lua-api.factorio.com/latest/LuaC ... ach_entity <-- this might be what you need

Also, some mods which might have examples:

https://mods.factorio.com/mods/kyranzor/robotarmy -- from memory this one implements its own pathfinder

https://mods.factorio.com/mods/TheSAguy ... _Expansion or
https://mods.factorio.com/mods/TheSAguy ... on_Enemies -- vague memory that one of these does something with AI

https://mods.factorio.com/mods/Afforess/Misanthrope -- or it might be this one that has own pathfinder, can't remember

Re: Alien pathfinder thru API ?

Posted: Sat Aug 20, 2016 10:19 pm
by binbinhfr
> http://lua-api.factorio.com/latest/LuaF ... inder_busy

I saw this one.

> http://lua-api.factorio.com/latest/LuaC ... ach_entity <-- this might be what you need

This one seems to be more to know if a player can open a building.

But I will look at the other mods you are talking about : thx !

Re: Alien pathfinder thru API ?

Posted: Sun Aug 21, 2016 4:51 pm
by binbinhfr
results of investigations :

> https://mods.factorio.com/mods/kyranzor/robotarmy -- from memory this one implements its own pathfinder

no, it uses standard factorio "set_command".

> https://mods.factorio.com/mods/Afforess/Misanthrope -- or it might be this one that has own pathfinder, can't remember

yes misanthrope is using a pathfinder developped here :
https://github.com/lattejed/a-star-lua/ ... a-star.lua

Re: Alien pathfinder thru API ?

Posted: Mon Aug 22, 2016 2:15 am
by aubergine18
Here's another mod that does stuff with pathfinder https://mods.factorio.com/mods/Veden/Rampant

Re: Alien pathfinder thru API ?

Posted: Mon Aug 22, 2016 9:40 pm
by binbinhfr
Anyway I'd like to understand how Factorio original pathfinder works. Any dev around ?

If the way from point A to B is possible (a walking land path exists) but temporarly blocked (by walls for example). Will the set_command completely abort, or will it send the unit on the path, stopping on the wall, but trying to destroy them (if correct distraction value declared) ?

Re: Alien pathfinder thru API ?

Posted: Tue Aug 23, 2016 5:05 am
by Adil
(no dev, common knowledge)
There's the pathfinder info in the debug overlay on fn buttons.
I believe when they find obstacles they cannot get around, they attack those. (They keep doing that when you kite a horde into the forest and they don't seem to be distracted by anything otherwise).
However, on large scale pathfinding is not what defines where biters will go from the spawn to place of death, the destination is set by a simpler expansion mechanic which does not really invest in logistics evaluation, but looks at pollution and location of player structures. You can see places expansion mechanism deems a viable target in the overlay as well.

Walls seem to keep biters out of larger areas due to their interference with expansion, rather than pathfinder.

Re: Alien pathfinder thru API ?

Posted: Tue Aug 23, 2016 7:50 am
by binbinhfr
Adil wrote:There's the pathfinder info in the debug overlay on fn buttons.
.
I will look at these infos.

Anyway, I was not clear, but what I need to understand is the way API functions like http://lua-api.factorio.com/0.13.17/Lua ... ti_command work.
Because for the moment, it seems that if I asked an attack on a zone that is closed by walls, aliens do not move at all, and do not try to go at walls and destroy them to make their way... I wanted to have a confirmation on that and to know if it's normal, because it seems strange to me that they do not try to make their way.

Re: Alien pathfinder thru API ?

Posted: Tue Aug 23, 2016 8:42 am
by Adil
Did you check its returns?
Did you try to explicitly find a few biters and put order on them?
The AI interface is quite a mess inherited from the times that were, that function might search for biters in active chunks only or be ignored if the ai_controllable switch is off. I don't recall specifics, but such problems did come up before.

Re: Alien pathfinder thru API ?

Posted: Tue Aug 23, 2016 8:53 am
by binbinhfr
Did you check its returns?
Yes : it returns the number of aliens it finds. No problem.
Did you try to explicitly find a few biters and put order on them?
No. It's another command, but I will try.
The AI interface is quite a mess inherited from the times that were, that function might search for biters in active chunks only or be ignored if the ai_controllable switch is off. I don't recall specifics, but such problems did come up before.
The LUAsurface.set_multi_command works perfectly if there is no walls blocking the path. It gather some aliens in the area (I put a very large area), and they are sent to the desired location, attacking things on their way.

But if the destination area is enclosed by walls, Aliens just stay where they are, and they even do not move anymore (usually they make small movements). So there is a problem just in that special case.