Closed pandaro closed 8 years ago
Yes, that's the correct way. We're passing the function validFunction
, not calling it. It's called within the function map:FindClosestBuildSite
.
As part of a process of elimination, try not passing validFunction at all
return self.map:FindClosestBuildSite(unitTypeToBuild, position, 400, minDistance)
to see if buildsitehandler's internals are the problem.
i try to debug in 1v1 bots, with only air factory, after some test:
if i call with validFunction(position): one AI can build a factory, the other AI cant. after the building of the first give me the error: Error: LuaRules::RunCallIn: error = 2, GameFrame, [Internal Lua error: Call failure] [string "luarules/gadgets/ai/preload/spring_lua/map...."]:44: attempt to call local 'validFunction' (a table value) stack traceback:
second attempt: validFunction() one AI can build all the factories without problem, the other ai cant place factories at all. No error reported.
3 without validFunction: one AI can build all the factories without problem, the other ai cant place factories at all. No error reported.
yes return self.map:FindClosestBuildSite(unitTypeToBuild, position, 400, minDistance, validFunction)
yes return self.map:FindClosestBuildSite(unitTypeToBuild, position, 400, minDistance)
no return self.map:FindClosestBuildSite(unitTypeToBuild, position, 400, minDistance, validFunction())
no return self.map:FindClosestBuildSite(unitTypeToBuild, position, 400, minDistance, validFunction(position))
the error you reported is because calling validFunction(position)
returned a position, and map:FindClosestBuildSite
then attempted to call that position as a function.
yes return self.map:FindClosestBuildSite(unitTypeToBuild, position, 400, minDistance, validFunction)
in this case the AI build only corap and not coraap and the same for arm *EDIT ! WARNING also in this case one AI build only a corap and the other not
yes return self.map:FindClosestBuildSite(unitTypeToBuild, position, 400, minDistance)
in this case one ai build both factories and the other dont build factories
Then the problem is somewhere in how BuildSiteHandler:CheckBuildPos
is checking build positions for armaap and coraap, not with how that line return self.map:FindClosestBuildSite(unitTypeToBuild, position, 400, minDistance, validFunction)
is written.
In the latter case, that suggests much larger problems with the way the Lua AI (I'm assuming this is being tested as a Lua AI) handles multiple AI teams.
you assuming correctly, but i will encourage you, the problem dont regard other factories but only aap. with multiple ais there are no problem, only a bug with the aap
wow, after a furious debug i reach a probabile conclusion unitCanGoHere() are broke cause spring.testMoveOrder() are broke for air path, so air simple cant go at the right position to build some things, for example advsol and aap. question: 1 please check you and give feedback? 2 in case of positive feedback, can we ask at spring developers if is a bug or a misunderstanding? 3maybe for air unit we can skip it? 4or other solution? % EDIT : i think this is caused by the unit def of air units that have a empty move class or somthing of special, because can go everywhere % EDIT EDIT wtf we test unitcangohere for air?
Weird, yeah, Spring.TestMoveOrder is always false for air units. That makes me wonder why air units ever do anything at all.
wtf we test unitcangohere for air?
The mobility networks should always match because of this line https://github.com/eronoobos/BABAR-The-Shardifant/blob/e01d102df75bd0d8b774c2a826426d42e81c9447/maphandler.lua#L1033 But since TestMoveOrder tells us nothing for air units, apparently, may as well just return true for air units.
sorry if i insisting on this but my bufix is simple add a line in head of unit can go here that say:
if mtype == 'air' then return true end
it work fine, cuse this function only say us if a unit can go in a place, and air unit simple can go here always
yup, that's just what i was going to suggest
https://github.com/eronoobos/BABAR-The-Shardifant/commit/ca4763dea9f59535bb45a770a5cce1e2c9dee4ae If you're using the latest ShardSpringLua you'll get mobility networks shown on the map, too. I hope it will help debug things in the future
It seems to be building advanced air factories just fine now. Same for you? If so, let's close the issue
it work, but im not able to see networks, how to enable? i press c and t and numbers but....
it's in channel 4. press c then press 4 if it doesn't work, join the official server to chat?
it work but we can open a private chat if we need to talk i'm online as bioparco
all work fine on air factories, i close issues
only for this 2 factories i noticed that the builder cant get the buildpos. i search in back for get the problem and seems is there: ai.buildsitehandler:ClosestBuildSpot() i dont know why but he get nil... inside this function i see this lines:
are you sure that this line :
return self.map:FindClosestBuildSite(unitTypeToBuild, position, 400, minDistance, validFunction)
is in the right way? maybe it will come likereturn self.map:FindClosestBuildSite(unitTypeToBuild, position, 400, minDistance, validFunction(position))
or something else... i try but give me back strange errors