[Oxyd] [1.1.48] game.map_settings.path_finder.fwd2bwd_ratio <= 1 never completes
Posted: Mon Nov 29, 2021 9:46 am
Hello,
I was messing around with some pathfinding stuff and i found that setting fwd2bwd_ratio to anything less than or equal to 1 creates a loop that seems to go on forever. This could just be an error in the documentation too and maybe i'm just using it wrong..
i made a recording of this behavior. in the video i first run the pathfinder with the defaults and then I set the value to -5 and the backwards pather seems to make it, but then gets confused and continues to search
i put the scenario and code in the zip file but to make it easier i will also post the code here
i also put the video as an attachment (.mkv) if you don't like that site
https://emalm.com/?v=__yax
the code i'm running looks like this:
I was messing around with some pathfinding stuff and i found that setting fwd2bwd_ratio to anything less than or equal to 1 creates a loop that seems to go on forever. This could just be an error in the documentation too and maybe i'm just using it wrong..
i made a recording of this behavior. in the video i first run the pathfinder with the defaults and then I set the value to -5 and the backwards pather seems to make it, but then gets confused and continues to search
i put the scenario and code in the zip file but to make it easier i will also post the code here
i also put the video as an attachment (.mkv) if you don't like that site
https://emalm.com/?v=__yax
the code i'm running looks like this:
Code: Select all
local handler = require("event_handler")
handler.add_lib(require("freeplay"))
handler.add_lib(require("silo-script"))
Public = {}
local threat_values = {
["small-spitter"] = 1.5,
["small-biter"] = 1.5,
["medium-spitter"] = 4.5,
["medium-biter"] = 4.5,
["big-spitter"] = 13,
["big-biter"] = 13,
["behemoth-spitter"] = 38.5,
["behemoth-biter"] = 38.5,
["small-worm-turret"] = 8,
["medium-worm-turret"] = 16,
["big-worm-turret"] = 24,
["behemoth-worm-turret"] = 32,
["biter-spawner"] = 32,
["spitter-spawner"] = 32
}
local enemy_types = {
"small-spitter",
"small-biter",
"medium-spitter",
"medium-biter",
"big-spitter",
"big-biter",
"behemoth-spitter",
"behemoth-biter"
}
local function send_attack(threat)
threat = tonumber(threat.parameter)
local surface = game.surfaces[1]
game.forces.player.chart(game.player.surface, {lefttop = {x = -2000, y = -500}, rightbottom = {x = 2000, y = 500}})
game.forces.enemy.share_chart = true
game.forces.player.share_chart = true
local silo = surface.find_entities_filtered({position={0,495}, raidus=100, name="rocket-silo"})[1]
local unit_group = surface.create_unit_group({position = {0, -470}, force = "enemy"})
for _=1, 200, 1 do
if threat < 0 then break end
local enemy_type = enemy_types[math.random(1, #enemy_types)]
threat = threat - 5*threat_values[enemy_type]
for _=1, 5, 1 do
local position = surface.find_non_colliding_position(enemy_type, {0, -470}, 128, 2)
if not position then break end
local enemy = surface.create_entity({name = enemy_type, force = "enemy", position = position})
unit_group.add_member(enemy)
end
end
local commands = {}
commands[#commands + 1] = {
type = defines.command.attack,
target = silo,
distraction = defines.distraction.by_enemy
}
unit_group.set_command({
type = defines.command.compound,
structure_type = defines.compound_command.logical_and,
commands = commands
})
end
Public.send_attack = send_attack
global.commands = {}
global.commands.send_attack = send_attack
commands.add_command('send', 'send attack..', send_attack)
return Public