Shutdown windows process (AI client) if defeated

For what's not in 'Top Priority Game Design'. Post your ideas, visions, suggestions for the game, rules, modifications, etc.

Moderator: Oberlus

Post Reply
Message
Author
schpidi
Space Floater
Posts: 15
Joined: Sat Feb 09, 2013 5:11 pm

Shutdown windows process (AI client) if defeated

#1 Post by schpidi »

Hi all,

I searched for the topic, but I found nothing accurate...

Currently I am playing 500 stars 20 AI and I am running into performance issues, because I only have a medium sized system.

I found that each AI client has its own windows process.

So I had the idea not to attack them parallely.
I thought if I would kill them completely one after the other, I would get some free computer resources again.
But I saw that the AI client remains as windows process, even if AI empire is completely defeated.
For my big game this means around 100MB per AI client.

Is it possible / useful to implement something like this:
- if AI has no planets and no fleets any more -> shutdown process

This would release some resources, which could be reused for GUI or other AI processes.

What do you think about this?

Cheers,
schpidi

Zireael
Space Dragon
Posts: 429
Joined: Mon Aug 15, 2011 5:33 pm

Re: Shutdown windows process (AI client) if defeated

#2 Post by Zireael »

Oh yeah, great idea!

User avatar
Bigjoe5
Designer and Programmer
Posts: 2058
Joined: Tue Aug 14, 2007 6:33 pm
Location: Orion

Re: Shutdown windows process (AI client) if defeated

#3 Post by Bigjoe5 »

I'm surprised that the AI is slowing down the game after it's defeated. Is it actually using up CPU, or is it just holding on to memory?
Warning: Antarans in dimensional portal are closer than they appear.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Shutdown windows process (AI client) if defeated

#4 Post by Geoff the Medio »

Bigjoe5 wrote:Is it actually using up CPU, or is it just holding on to memory?
It probably still is deserializing its latest known galaxy state info each turn, but I'd expect it's more of a memory issue. The downside of having independent AI processes is the extra memory use.

schpidi
Space Floater
Posts: 15
Joined: Sat Feb 09, 2013 5:11 pm

Re: Shutdown windows process (AI client) if defeated

#5 Post by schpidi »

Bigjoe5 wrote:I'm surprised that the AI is slowing down the game after it's defeated. Is it actually using up CPU, or is it just holding on to memory?
I assume it is not wasting too much CPU, because no buildings, production, fleets calculation etc.
But for my big game it is still writing a 5-10MB AI log file for defeated ones, which is not necessary in my eyes.
And it still remains in the memory.
Geoff the Medio wrote:It probably still is deserializing its latest known galaxy state info each turn, but I'd expect it's more of a memory issue. The downside of having independent AI processes is the extra memory use.
But isn´t it possible to end the process completely?
I assume currently there is working some kind of garbage collector which free up the memory by some time?
Couldn´t we call the same shutdown routines like on closing the game?
If an empire is dead, it doesn´t need any info about the galaxy any more :-)

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Shutdown windows process (AI client) if defeated

#6 Post by Geoff the Medio »

schpidi wrote:But isn´t it possible to end the process completely?
Lots of things are possible, but require other stuff to be implemented first. In this case, there's nothing implemented to decide when an AI empire is defeated / can be excluded from future turns.

Edit: Also, doing this during a game would likely require some adjustment of various other code to keep track of the reduced number of empires, on the server (so that it doesn't wait forever for not-coming empire turn orders) and on the client (so it knows to update the UI appropriately). Also, would the gamestate remember that the previous empire existed, or just remove all traces of it? Presumably the in-game pedia should have some record, and old sitrep messages would still need to have access to the old empire's info...

schpidi
Space Floater
Posts: 15
Joined: Sat Feb 09, 2013 5:11 pm

Re: Shutdown windows process (AI client) if defeated

#7 Post by schpidi »

Geoff the Medio wrote:
schpidi wrote:But isn´t it possible to end the process completely?
Lots of things are possible, but require other stuff to be implemented first. In this case, there's nothing implemented to decide when an AI empire is defeated / can be excluded from future turns.

Edit: Also, doing this during a game would likely require some adjustment of various other code to keep track of the reduced number of empires, on the server (so that it doesn't wait forever for not-coming empire turn orders) and on the client (so it knows to update the UI appropriately). Also, would the gamestate remember that the previous empire existed, or just remove all traces of it? Presumably the in-game pedia should have some record, and old sitrep messages would still need to have access to the old empire's info...
Ok, then I misunderstood. When translating I found the message EMPIRE_DEFEATED and I assumed that this is an implemented event already.
Logically an empire is defeated for me if
- it is not transzendent (otherwise it would have won :))
- it has no planets
- it has no fleets

But I don´t know the internal class structure of the game and what info is available and what not.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Shutdown windows process (AI client) if defeated

#8 Post by Dilvish »

schpidi wrote:
Bigjoe5 wrote:I'm surprised that the AI is slowing down the game after it's defeated. Is it actually using up CPU, or is it just holding on to memory?
I assume it is not wasting too much CPU, because no buildings, production, fleets calculation etc.
But for my big game it is still writing a 5-10MB AI log file for defeated ones, which is not necessary in my eyes.
And it still remains in the memory.
You don't want to delete the logfile from disk in the middle of a game just because the respective AI was defeated. After defeat, an AI only adds about 100 lines per turn to the log file if you don't have verbose logging on, and takes about 0.2 seconds elapsed per turn (on my machine anyway) to review its situation and decide it has nothing to do.
But isn´t it possible to end the process completely?
I assume currently there is working some kind of garbage collector which free up the memory by some time?
Couldn´t we call the same shutdown routines like on closing the game?
If an empire is dead, it doesn´t need any info about the galaxy any more :-)
Even though we don't have it currently, there easily could be some kind of Effect that gives ships to a "dead" empire, or to a random one, and revive it from apparent defeat.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

unjashfan
Creative Contributor
Posts: 175
Joined: Fri Dec 30, 2011 8:08 am

Re: Shutdown windows process (AI client) if defeated

#9 Post by unjashfan »

there's nothing implemented to decide when an AI empire is defeated / can be excluded from future turns.
I think an empire can be considered defeated when said empire has no colonies, no colony class ships, and no troop ships remaining on the map. Basically all methods of colonization/invasion must be unavailable to that empire. Any remaining ships such as warships could remain on the map either as stationary objects in which they will get in the way of other players. Or, to make things more fun, the lost empire will receive a fleet of highly stealthed ghost warships for the sole purpose of seeking revenge and messing the other players up :mrgreen: .

User avatar
Bigjoe5
Designer and Programmer
Posts: 2058
Joined: Tue Aug 14, 2007 6:33 pm
Location: Orion

Re: Shutdown windows process (AI client) if defeated

#10 Post by Bigjoe5 »

There's also been some discussion of using diplomacy or other means to revive previously defeated empires, though I think if an empire is really defeated and has no assets whatsoever, it should probably be out of the game.

However, an empire could hypothetically survive without any planets or ships, and still be operating with spies in enemy empires, "stealing" or otherwise acquiring enough influence output to continue funding his espionage efforts.
Warning: Antarans in dimensional portal are closer than they appear.

User avatar
em3
Vacuum Dragon
Posts: 630
Joined: Sun Sep 25, 2011 2:51 pm

Re: Shutdown windows process (AI client) if defeated

#11 Post by em3 »

Bigjoe5 wrote:However, an empire could hypothetically survive without any planets or ships, and still be operating with spies in enemy empires, "stealing" or otherwise acquiring enough influence output to continue funding his espionage efforts.
I like that - at least in theory; I'm afraid that such burrowed empire would not have any means to stand on its own again, though, not to mention winning the game...

... well, unless the ultimate influence/espionage project would be "imperial takeover" :wink: .
https://github.com/mmoderau
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556

User avatar
Bigjoe5
Designer and Programmer
Posts: 2058
Joined: Tue Aug 14, 2007 6:33 pm
Location: Orion

Re: Shutdown windows process (AI client) if defeated

#12 Post by Bigjoe5 »

em3 wrote:
Bigjoe5 wrote:However, an empire could hypothetically survive without any planets or ships, and still be operating with spies in enemy empires, "stealing" or otherwise acquiring enough influence output to continue funding his espionage efforts.
I like that - at least in theory; I'm afraid that such burrowed empire would not have any means to stand on its own again, though, not to mention winning the game...

... well, unless the ultimate influence/espionage project would be "imperial takeover" :wink: .
While "Imperial Takeover" is unlikely, there's a realistic possibility of being able to take over ships and planets via espionage. Furthermore, empire A, which has thoroughly infiltrated empire B, is likely to be of great utility to empire C, who is at war with empire B, and who might offer empire A ships, planets or resources in return for its services.
Warning: Antarans in dimensional portal are closer than they appear.

User avatar
em3
Vacuum Dragon
Posts: 630
Joined: Sun Sep 25, 2011 2:51 pm

Re: Shutdown windows process (AI client) if defeated

#13 Post by em3 »

Bigjoe5 wrote:While "Imperial Takeover" is unlikely, there's a realistic possibility of being able to take over ships and planets via espionage. Furthermore, empire A, which has thoroughly infiltrated empire B, is likely to be of great utility to empire C, who is at war with empire B, and who might offer empire A ships, planets or resources in return for its services.
That does sound awesome. I'm not sure if we can expect such scenarios outside multiplayer games with role-playing humans. :D
https://github.com/mmoderau
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556

User avatar
Bigjoe5
Designer and Programmer
Posts: 2058
Joined: Tue Aug 14, 2007 6:33 pm
Location: Orion

Re: Shutdown windows process (AI client) if defeated

#14 Post by Bigjoe5 »

em3 wrote:
Bigjoe5 wrote:While "Imperial Takeover" is unlikely, there's a realistic possibility of being able to take over ships and planets via espionage. Furthermore, empire A, which has thoroughly infiltrated empire B, is likely to be of great utility to empire C, who is at war with empire B, and who might offer empire A ships, planets or resources in return for its services.
That does sound awesome. I'm not sure if we can expect such scenarios outside multiplayer games with role-playing humans. :D
I'm sure Dilvish is up to the challenge of making the AI diplomatically savvy enough to make this kind of arrangement with a player - assuming we have an adequately robust diplomacy system. The concept of a "contract" will probably be very difficult to pull of.
Warning: Antarans in dimensional portal are closer than they appear.

Post Reply