eronoobos / BABAR-The-Shardifant

Balanced Annihilation & Balanced Annilhation Reloaded configuration for Shard
2 stars 1 forks source link

when more than one Lua AI are enemies they sometimes target their own units #10

Closed pandaro closed 8 years ago

pandaro commented 8 years ago

i noticed that some bombers bombard herself factory, i see it on sailaway map .

pandaro commented 8 years ago

and after few minute of suicide i get this error: `[f=0037620] Error: LuaRules::RunCallIn: error = 2, GameFrame, [Internal Lua error: Call failure] [string "luarules/gadgets/ai/BAR/bomberbehaviour.lua"]:57: attempt to index a nil value
stack traceback:

`

eronoobos commented 8 years ago

Was there an enemy team when this happened?

pandaro commented 8 years ago

in my experiment yes

pandaro commented 8 years ago

i noticed that ground units sometime make the same and try to attack for example herself mex

eronoobos commented 8 years ago

was the enemy team another ShardLua in either or both of these cases?

pandaro commented 8 years ago

is shard

eronoobos commented 8 years ago

You mean a non-lua Shard, or ShardLua? It makes a big difference which one.

pandaro commented 8 years ago

sorry is a shardLluaAI

pandaro commented 8 years ago

if can help: t1 submarine always try to attack floating radar and turrets.

eronoobos commented 8 years ago

https://github.com/eronoobos/BABAR-The-Shardifant/commit/0e9faa0f464a5e0ddb82b86f059109b80eb457c8 i'm not sure if this solved the issue, but using self.ai instead of ai. is a good precautionary measure for all modules. also updated debug drawing to the new system

pandaro commented 8 years ago

don't resolve at all but is a great improvement on map like barbary coves sometime this append again edit* submarine attack units

pandaro commented 8 years ago

i'm not sure if this solved the issue, but using self.ai instead of ai. is a good precautionary measure for all modules. also updated debug drawing to the new system

ok only an info about this need to replace with self.ai only vars or all the things? (function like ai.maphandler:mobilitynetworkhere() need to replace, can cause problem, is totally indifferent?)

eronoobos commented 8 years ago

It doesn't matter whether it's a variable or a function, the ai, game, and map objects ideally shouldn't be used as globals. I don't really understand what's going on, but the way they are set to the correct ones before every AI callin, is a bad hack. (For the non-Lua AI this is not a problem because each AI is an entirely separate Lua environment.)

https://github.com/eronoobos/ShardSpringLua/blob/3853dfc8b0f088ddd216451bce4a452a5623a488/luarules/gadgets/AILoader.lua#L54

https://github.com/eronoobos/ShardSpringLua/blob/3853dfc8b0f088ddd216451bce4a452a5623a488/luarules/gadgets/AILoader.lua#L179

The biggest problem using the ai objects attached to behaviours and modules is taskqueues. All of them ought to take the taskqueuebehaviour as an argument so that they can get the behaviour.ai. But I should figure out what's even happening before doing all that

pandaro commented 8 years ago

watch at my last commit, say if are ok, it fix a large amount of target problem

pandaro commented 8 years ago

anyway my attempt don't fix target errors, bombers bombard itself units again

eronoobos commented 8 years ago

https://github.com/eronoobos/BABAR-The-Shardifant/pull/37 (because it's relevant to the issue)

eronoobos commented 8 years ago

https://github.com/eronoobos/BABAR-The-Shardifant/commit/02731ff01d0dc2a47a0c2f4882c2a4f4c8081149 local variables in modules are a problem in the Lua AI, because the local variables are shared by all ShardSpringLua teams. Anything that isn't a constant should be within a module function, and part of the module's table.