Non player-bound unsync, for non cheating Lua AI

Non player-bound unsync, for non cheating Lua AI

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Non player-bound unsync, for non cheating Lua AI

Post by zwzsg »

Currently, LuaAI are just gadgets. But they are synced gadget, which means:
  • Their calculation are run on every computer, instead of only the AI owner. While our current LuaAI aren't too hungry, artificial intelligence is a difficult problem, and depending on your approach you might want alot of CPU. Seem wasteful to force every player to calculate what only one needs to be once.
  • Every player needs to have the code in order to run it. While being included within the mod archive is part of the strength of LuaAI, maybe one day we'll want to allow LuaAI to be distributable separatly from mod.
  • They can access the full controlling power of synced gadget. It's the coder that have to make sure he only manipulate the game through Spring.GiveOrderToUnit. But only honor bounds him to, he could very easily hide a Spring.CreateUnit or similar powerful commands, Spring wouldn't complain.
  • They can access the full reading power of synced gadget. This make them by default cheating AI. Mostly, it means that LuaAI know the position of every unit, including enemy way beyond the fog of war. Theorically I could wrap all the GetUnits with something to filter out what's out of view of a given teamID, but, that'd be extra work, plus I'm afraid of not doing it optimised enough. So far I just let KPAI knows a bit more than it ought, considering the advantage is small enough to not be that upsetting.

So why don't I run AI in an unsynced gadget? Because unsynced is always run from the point of view of the player. This makes sense for widget, which otherwise would be used to cheat by using data the player must not known. This makes sense for a gadget graphical effect, which are shown on player screen. However, you can't have AI in unsynced, because then they would not known about their own units, not be able to control them, and would instead only be aware of player units, not its.

So, this feature request is about having a new kind of unsynced, that isn't bound to a player, but can be set for any team. LuaAI is the only application I see for it at the moment, but maybe other people will think of other uses.

To tell the truth, it's not a feature request: I don't need that feature, I even doubt anybody really needs it anyway. It's just, couple months ago, some dev were talking about how multithreading required the schism between synced and unsynced Lua to be rethought and rewritten. I don't know if anyone is working on redoing that part of Spring Lua at the moment, I don't even want anyone to change it. But if devs are reworking that sync/unsync distinction, then might be the time to ponder about a non player bound unsync for non cheating AI. Not because I've real uses in mind, more for ... consistency or other moral imperative.

Just something to think about. Don't implement. I hate changes! :-)














Edit: Thinking back about it, I'm afraid I'm wrong when saying unsynced gadget only see the player units. I recall now that much of KP gadgetery about drawing effects are sprinkled with Spring.IsUnitVisible precisely because, unlike widgets, unsynced gadgets do see every units.

This mean that LuaAI can already run unsynced, where they can be (even must be) run on only one computer instead of all, and where commands that would be cheating are disabled. There's only left the issue of having full los instead of team los. Which as I said earlier could be solved in Lua.

So, uh, this make my idea even more worthless that I thought.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Non player-bound unsync, for non cheating Lua AI

Post by Tobi »

C.R.A.I.G. runs (mostly) in unsynced gadget area, sending commands to a small command-giving helper on the synced side.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Non player-bound unsync, for non cheating Lua AI

Post by Google_Frog »

CAI runs completely synced and doesn't cheat. Just a demonstration that it is possible to write a synced AI without giving in to the temptation to spawn fusions on the enemy base :lol:.

Synced AI has the advantage of no command giving lag. It would be nice to have non-synced external LuaAI but I think it is really low priority. All it does is reduce computation for some people in multiplayer where most AI will want to be usable by anyone for singleplayer.

All I can see it really being used for is rule enforcement for an AI competition. If people really want to do that they could write their AI as a widget, I wrote half of CAI as a widget before I looked up how to implement LuaAI.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Non player-bound unsync, for non cheating Lua AI

Post by zwzsg »

Google_Frog wrote:CAI runs completely synced and doesn't cheat.
From what I've seen, gadget:UnitDamaged +spotEnemyUnit, don't filter out enemy units out of los. Yes, it's quite minor, and won't change much, but a cheat nonetheless.
Google_Frog wrote:It would be nice to have non-synced external LuaAI but I think it is really low priority.
Low priority, sure, would be nice, I'm not convinced.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Non player-bound unsync, for non cheating Lua AI

Post by knorke »

Just wondering, why do Lua AIs have to be shipped with the mod instead of going into the AI folder like AIs made with other languages?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Non player-bound unsync, for non cheating Lua AI

Post by Argh »

Technically, they can just go into ../luarules, so they can ship with a Spring install just like any other AI.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Non player-bound unsync, for non cheating Lua AI

Post by Google_Frog »

From what I've seen, gadget:UnitDamaged +spotEnemyUnit, don't filter out enemy units out of los. Yes, it's quite minor, and won't change much, but a cheat nonetheless.
Ah now we get into the nitty gritty of "what is cheating?". I decided that if a unit is damaged any half decent player could watch the projectile and conclude which unit type damaged it and the general position of the unit.

Widget-powered AI removes game-specific choices such as these.
Post Reply

Return to “Feature Requests”