imitation game

imitation game

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
eronoobos
Posts: 73
Joined: 27 Mar 2015, 20:25

imitation game

Post by eronoobos »

I wanted to make a widget that counts enemy units. Not perfectly, but hopefully with less license than I do as a player. (I imagine everything is the tip of an iceberg.) Simple, I thought, I'll turn the ghost radar widget into a ghost count widget, and when widget:UnitDestroyed it will count backwards. :lol: :lol: :lol: :lol: :oops:

Took me lots of dumbo wiki research and lua coding to realize the engine developers were wise to not provide unsynced any way of knowing when an enemy unit died, even when it's in LOS. Imagine the game with units that only appear to die, units that appear to keep walking around after death, or units that remain invisible alive or dead.

I think there is an okay heuristic that a theoretical unsynced AI could use: listing all the features in sight every second and matching new wrecks with counted units. Similarly it could list all the visible units every second and determine if missing counted units were well enough within LOS that disappearing normally is unlikely. Still, some units would die out of sight or without a wreck, and at some point the counts need to have timeouts (another problem shared with human players). What else could it do? Search a video feed of its own viewport for explosions?

Okay, I guess a synced LuaAI could know when enemy units died and have safeguards to respect the boundaries of unsynced knowledge. Still, the problem of intelligence is fundamental to PvP, and most AIs don't have it.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: imitation game

Post by Anarchid »

Alternative approach

- estimating enemy income to be ~similar to yours OR estimating enemy income based on amount of territory they control
- estimating expected enemy total budget to this point based on that
- checking how many enemy units are known and how much they are worth
- if the total known enemies is much less than what should be expected, assume some evil plan and deploy strategic scouts
were wise to not provide unsynced any way of knowing when an enemy unit died
Not entirely correct: units that cease to exist before leaving LOS may be safely considered killed. The ZK widget gui_attrition_counter used to rely on that; however, since then this has been replaced with an API modification to provide UnitDestroyed for enemies in LOS without polling for unitID validity (and thus also allow to know the killer, allowing for more advanced kill rates).
User avatar
eronoobos
Posts: 73
Joined: 27 Mar 2015, 20:25

Re: imitation game

Post by eronoobos »

:shock: :mrgreen:

edit: oops, i should have put this in the AI section
Post Reply

Return to “Lua Scripts”