Logo Platform
logo amplifiers simplified
Endless Space
Universe banner wording

ENDLESS™ Space is a turn-based 4X strategy game, covering the space colonization age in the ENDLESS™ Universe. You control every aspect of your civilization as you strive for galactic dominion.

Custom AI programming

Reply
Copied to clipboard!
10 years ago
Jun 28, 2014, 8:31:07 AM
So this is kind of an unusual request, but I figured I'd at least brainstorm with the community about it.



I'm a software developer. I do quite a bit of algorithm design.



Endless Space has a lot of things that make it attractive for 3rd-party AI design. For one thing it's a pretty robust strategy game, with a variety of different playstyles. For another thing I've seen a lot of threads about how the default AI cheats, behaves unrealistically, etc. So potentially a 3rd-party AI might add a lot to the game. And, you know, it's an interesting challenge.



However, the hardest part is getting started. And by that I mean getting some kind of process running, that can know the sort of game state that the player would know and be able to issue commands. Here's my brain dump on that problem:



  • It can't be accomplished through any of the official mod mechanisms, which are limited to XML files only. Doing better AI requires running real code.
  • I don't think it can be accomplished through the plugin mechanism either. I poked around a bit at GalaxyGenerator.dll and it doesn't seem to use a very robust API to communicate with the main process--everything goes through more XML files
  • Something like Matt's D3D9 Interceptor might work. But reading textures to figure out game state is a lot of work. Also, I'm on OSX, and if I have to boot into Windows to work on this I probably won't
  • So I started a little journey of reverse engineering the game itself. Through a long series of adventures I don't have time to mention here, I stumbled into Assembly-Csharp.dll which looks very promising. It appears to be a C#-language DLL that implements the game's AI itself (as well as a great many other things). I'm not super familiar with .NET reverse engineering but it seems possible to me that either by selectively modifying this DLL, or some other way to replace classes inside it piecemeal at runtime, I could swap out the AI with a new implementation. That still won't get me a nice GUI menu of multiple AI implementations that someone could choose from, but it's a start.





These forums look pretty active... I dunno if any Amplitude devs hang out here or if there are people in the modding community who have suggestions on how to go about this, but opening up this game to new AI development seems within the realm of possibility if we can fill in a few missing pieces.
0Send private message
10 years ago
Jun 28, 2014, 7:26:58 PM
Yes do it!

Ive already done a little reversing for a database model Im making so I cant point a few things out. I dont know how to patch an assembly but Ive read dotnet code is easier than most. You might be able to patch the body of a method somewhere to extend the AI a bit but Im not sure what exactly you want to change. A whole lot of AI behavior IS already exposed in the XML so you might get lucky depending on what you want.



Assembly-Csharp.dll is where all script components go like all unity engine games. Heres some good reads if your browsing that. http://docs.unity3d.com/ScriptReference/

Also there is source code for GalaxyGenerator.dll https://www.assembla.com/code/amplitude-galaxygenerator/subversion/nodes



I would say your fist step is figuring out what you want to change if anything at all.
0Send private message
10 years ago
Jun 29, 2014, 6:59:19 AM
I love what's going on here, but my entire modding knowledge is self-taught xml from this game, so... damn. All I can add is that there are weights in the AI/Parameters folder, but I have a feeling you already know everything about that, heh.



What to change? Well, I would LOVE to have more competition when it comes to grabbing up good systems. Once I can go through wormholes, I scout the best locations and start grabbing them up (and the game is pretty much over from there). It seems like the AI takes it's time when it comes to expanding to good systems that aren't right next to itself.



Of course, that's just kind of my playstyle and also depends on my ability to defend those juicy systems.
0Send private message
10 years ago
Jun 29, 2014, 7:15:16 PM
Thats a neat thing to take a look at Tiaximus. Heres a little about that as far as I can tell.



Take a look at 'ExpansionMinister' which extends 'MinisterFleets'. This class seems to be responsible for dispatching AI colony ships.

In the ExpansionMinister constructor the type of colony ship to use is determined by searching all available ship designs for a design that contains a colonizer module. The minister will select and use the first colony ship design it finds.



The 'ExpansionMinister' seems to dispatch 'FleetAgents' which are AI routines for individual fleets. The ExpansionMinister updates its FleetAgents by issuing commands to them. Heres a section of the real code behind that. http://pastebin.com/EFNP5KYV



I think what happens is a colony fleet is created with a colony ship. The Fleet AI will evaluate the solar system its currently orbiting and compare its value to each neighboring solar system. If the Fleet AI finds a neighboring system with a higher value than the one its orbiting, it will travel too that higher value neighbor system. Once again it will evaluate each neighboring system to the one its currently orbiting and continue traveling until it finally finds a system with NO higher value neighboring systems. Then it with colonize the planet with the highest value in that system.



Not a bad strategy if you ask me. I roughly do the same thing.
0Send private message
10 years ago
Jul 2, 2014, 3:07:51 AM
Well, some developments!



tl;dr I've managed to write a (incredibly stupid) custom AI for Endless Space. It's not at all playable, but it proves the concept. The technique I use is sufficiently general that it could be used for much more powerful modding than previously thought possible.



The method is as follows: I'm patching the game binary itself. Through patching I convince ES to load some extra DLLs on startup, and to use those DLLs instead of its own internal code. This patching is destructive, so unlike a normal mod, you need to re-verify the local files with Steam to reset it back to a clean install.



You can see the proof-of-concept and some documentation on GitHub. It's currently OSX-only, but it should be just a few lines of code to port to Windows if somebody wants to take a crack at it. The repository includes a sample AI called DrunkenWalkAI, that, as the name would imply, sends fleets around in drunken (random) walk.



Standard disclaimers: this is very early and very buggy, it destructively edits the game on disk, use at your own risk, etc. That said it is pretty cool smiley: cool I can tell already that this game is going to be a lot easier to work with, than games like StarCraft that are currently used for AI contests.



It's my intention, if others are interested in writing AIs, to hold some kind of semi-regular contest for them to fight to the death. All details TBD.
0Send private message
0Send private message0Send private message
10 years ago
Jul 2, 2014, 10:23:02 PM
On OSX it's sufficient just to build and run out of Xamarin Studio in any directory. By default the program's working directory is going to be [source-root]/ESAITournament/ESStaticInjector/bin/Debug and so the paths to resources that are presently hardcoded in the injector are relative paths of the form [workingdirectory]/../../[etc] that should either already exist or be created during the build process.



The one exception is the path where all this stuff gets copied to at the end. That path is declared here. That will need to use a Windows equivalent of wherever ES gets installed on Windows.



I think that single path is all that needs to change... I don't really understand Windows file paths though, it's possible that the slashes need to be reversed.



Probably the right approach is to build on Windows out of the same ESStaticInjector (since it may evolve over time) but just move the path-related stuff into its own class that handles platform-specific behavior.
0Send private message
0Send private message0Send private message0Send private message0Send private message0Send private message0Send private message
4 years ago
Aug 24, 2020, 11:36:28 AM

What's the development of this story, lack professional programmers (designers) or have some other developing problems? If this is the case, visit this page and get 3rd-party AI improvements.

Updated 4 years ago.
0Send private message
?

Click here to login

Reply
Comment
0Send private message