Logo Platform
logo amplifiers simplified

[RELEASED] alternativ Galaxy Generator

Copied to clipboard!
12 years ago
Aug 24, 2012, 8:14:05 PM
Alternativ Galaxy Generator


Version: 0.4.1

ES Version: 1.0.46

Fast Download here: alternativeGalaxyGenerator 0.4.1.zip

List Versions: es.racing4all.com



Now using the original Resource distribution system.

And has better modding support.

It is based on the source of the Generator from Version 1.0.9

Feel free to make suggestions.



Disclaimer:


using this mod with newer/older Versions can result in Game Crashes but should be save if Amplitude doesn´t change the Galaxy Generator.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.



Text changes might contain errors. It works with all 3 Languages.

And now it´s released under MPL2.





What it is:


A Galaxy Generator that is faster than the Original.

It supports multicore CPUs.

All galaxy shapes are Generated by Javascript. Javascript is provided through Jint which is Licensed under MIT.

You can change how many Arms a Galaxy should have.

Currently there is only support for 4 shapes, 3 are original. So you have over 28 possibilities.





Performance


A 2048 System Galaxy is generated in 12sec.

If you want more take the 4096 System Galaxy if you wish to wait 1min. unless you use double constellation amount or the 2 Ring Galaxy which takes 2mins.

8192 Systems needs 8min.

This has been testet on an i5 quad core underclocked to 2GHz.



You can reduce generation time by lowering the star connectivity



Featurenotes:


0.4.0

-update for wonders

-seed now generates the same map.

-~15% faster



0.3.0

-balancing of resources



0.2.0

-randomisation of starsystems in a constellation



0.1.0

-faster

-4 galaxy shapes



0.0.1

-multithreading

-2 galaxy shapes

-arm number of a galaxy can be changed





How the galaxy generation works

You need to know about JS and C#




Basicly you would do something like: var shape = new Shape();

the Problem is that the ECMAScript doesn't define any directive like using.

So you have to write var shape = new Dagobert.GalaxyGenerator....Shape();

to shorten that you can directly user var shape = Shape();



Objects you can generate:

Rect(X, Y);

Ring(minRadius, maxRadius);

Arc(minRadius, maxRadius, angle);

Constellation();



Predefined objects:

Configuration

Random



Functions:

Connect(Constellation, Constellation)

Connect(Constellation, Constellation, Constellation[])



What does what

for a detailed function list of Configuration and Random look at the source of these classes.



Shapes:

They descibe where planets can be generated. All shapes have the following methods:

PointF getPoint();

gives you a PointF Objekt with the variables X and Y

bool isValid(PointF);

return true if the point is in its Shape.



Following Shapes are Available:

Rect(X, Y);

where the center is 0,0 and in the middle of the shape.

Ring(minRadius, maxRadius);

Arc(minRadius, maxRadius, angle);

minRadius and maxRadius is in parsec. Angle is in degrees. an angle of 360 will not work as this will be an Ring.



Shapes alone don´t do anything usefull. Thats why we need a Constellation.

Constellation();

This is the main objekt you are working with. It hase the following functions:

AddStarSystems(Shape, count);

here is where the magic begins. This Method places count StarSystems where each StarSystem is in the given shape. Thats also the reason why you need to rotate or translage the constellation.

Translate(X, Y);

Translates the Constellation.

Rotate(angle);

rotates the Constellation with the given angle.

GenerateWarps();

Generates the warps between all starSystems in this constellation. This part basicly starts a thread. So from here on its MT.

GenerateLuxuryResources(amount);

GenerateStrategicResources(amount);

Places Luxury or Strategic Resources in a Constellation.



Now we have our Constellations ready. But they aren´t connected.

Connect(Constellation, Constellation)

Connect(Constellation, Constellation, Constellation[])

this connects the first constellation with the second one.

The third parameter is optional.

You can say what constellations to check for crossing warps.

This is needed if you find Wormholes that cross another constellation.



Now you are ready to go and make your own shapes or make suggestions for improvements.

I only explained the basics.

There might be some other methods not shown here.

You can look at the source to find them.



Installation


Download here: alternativeGalaxyGenerator 0.4.1.zip

Unzip into (my documents)\Endless Space\Modding. This will create a new directory (my documents)\Endless Space\Modding\alternativeGalaxyGenerator containing 3 files: index.xml,License.txt and Jint License.txt and 3 subdirectories: Localisation, Gui and Plugins.

Load the mod and enjoy



Modding


1. We start of with a basemod which you want to merge with this mod. make a backup of it.

2. go to the basemod folder and go to Plugins/GalaxyGenerator. if it doesn´t exist create it.

3. inside it create a folder named Mod and move every file which is in Plugins/GalaxyGenerator into Plugins/GalaxyGenerator/Mod.

4. copy the content of Plugins/GalaxyGenerator from my mod to the basemod.

5. have fun.

6. if you want to have the right localization you have to merge the files in Localization



Source


Download here: alternativeGalaxyGeneratorSource 0.4.0.zip



Report a Bug


[LIST=1]
  • make sure your game is in the right version
  • search in the file (game install dir)\EndlessSpace_data\output_log.txt for modding and copy the complete error message.
  • also a copy of (my documents)\Endless Space\Modding\alternativeGalaxyGenerator\Plugins\GalaxyGenerator\GalaxyConfiguration.xml is needed sometimes. As the file can be long please use attachments (zip it if needed).

  • [/LIST]
    0Send private message
    12 years ago
    Aug 24, 2012, 9:52:26 PM
    Merged it with community bug fix / balance mod and working like a charm. Huge Epic Galaxy that generates fast. If only there was mod that allows to create larger fleets that AI can handlle and create.



    Cheers mate
    0Send private message
    12 years ago
    Aug 24, 2012, 10:44:41 PM
    Great work! Are you planing a release of the source code for the alternativeGalaxy generator?

    Think that would be helpful for the modding community.



    But on the other hand it's also understandable if you want to protect your work. smiley: wink
    0Send private message
    12 years ago
    Aug 24, 2012, 11:35:10 PM
    +1 on request for source code unless you have privacy concerns.



    Can you help us to understand the approach you took? How is javascript involved? Did you modify the 1.0.9 generator to add a javascript interface, and then replace some of the existing code with javascript calls? Since your effect is to speed up the code, it is hard to imagine that you did this by replacing compiled C# code with interpreted javascript. I would love to know more about what you actually did.
    0Send private message
    12 years ago
    Aug 25, 2012, 12:04:45 AM
    davea wrote:
    (...)



    Can you help us to understand the approach you took? How is javascript involved? Did you modify the 1.0.9 generator to add a javascript interface, and then replace some of the existing code with javascript calls? Since your effect is to speed up the code, it is hard to imagine that you did this by replacing compiled C# code with interpreted javascript. I would love to know more about what you actually did.




    As far as i looked over the mod files, he used JavaScript instead of pure XML to describe, for example, the galaxy shapes (check out the GalaxyShapes.xml file in the mod directory).



    Isn't the official galaxy generator source code released under the MPL (Mozialla Public License)?

    So, correct me if i'm wrong, the edited source must be remain under the same license.



    Just for reference smiley: wink

    https://www.mozilla.org/MPL/2.0/

    https://en.wikipedia.org/wiki/Mozilla_Public_License
    0Send private message
    12 years ago
    Aug 25, 2012, 1:38:28 AM
    davea wrote:
    hard to imagine that you did this by replacing compiled C# code with interpreted javascript


    Didn't you say the original algorithm was exponential time? At that rate the language probably wouldn't matter as much.
    0Send private message
    12 years ago
    Aug 25, 2012, 2:08:09 AM
    Hi guys, I've been lurking for a while and been playing the game since beta. I merged the community bug fix/balance with this AND Larger galaxies (since PimpmyGalaxy isn't well, functional right now). All I can say is wow. I generated a 7224 star galaxy in about 2 minutes flat. Although, trying to generate a 15532 stars (dense eternal) was giving my system fits.
    0Send private message
    12 years ago
    Aug 25, 2012, 6:14:24 AM
    While analysing the performance there was 1 big function that took all the time.

    And you gues it right. Its the warp generator.



    I optimised at 3 points.

    1. i use Constellations as blocks. the warp generator will only work on stars in a constellation.

    2. this also allows for threading of individual constellations.

    3. and the warp generator has changed a little bit, checking every warp only once.



    The javascript part is only an interface.

    You have basic shapes. Ring Arc Rect. Which can give you a point in space.

    the method addPlanet should be named addStarSystems as it actually generates the stars with help of the shape.

    also Generating strategic and luxury resources and translating and rotating the constellation.

    now to the loong GenerateWarps. It uses threadpool. So in Javasript there is non multithreading. its all done in the generator.

    Connecting the star systems is fast but yould also be threaded.



    As for realeasing the source.

    The old Generator was not Licensed.

    But i will merge this release to the new generator.

    Before the release i will document my code and polish it.



    I´m also thinking of config changes.

    Since this System works on constellations the config should reflect that and also show starsystems per constellation rather than starsystems total.
    0Send private message
    12 years ago
    Aug 25, 2012, 7:48:56 AM
    That's great news !



    I did some profiling tuesday, just to see where i could rewrite to speed up a little and yes, WarpsOf() is a perf killer (the 2 millions calls for a "small" generation does not help). The call graph passes through FullyConnected() and Connected as far as i remember, and then call WarpsOf() multiple times. I'd be interested in your code if you dont mind, since i was planning to work on the performance part of the galaxy generator to speed up huge generations. Also, i'll provide a reference galaxy XML on Monday, if you want to keep the generation as it is, and compare your generated galaxies with the "reference" one.



    Great job Dagobert.
    0Send private message
    12 years ago
    Aug 28, 2012, 3:35:53 AM
    Awesome mod, wasn't able to get above 200ish with the original generator.



    Unfortunately Large and Huge is fairly laggy. Still 500 systems is working fine and that's still awesome.
    0Send private message
    12 years ago
    Aug 28, 2012, 7:53:32 PM
    maybe they will use some optimisations i made ingame.

    But don´t worry about the size of Galaxys. It will become bigger and bigger. Promise.



    First to the happy part. What will be new in the next release:

    -The Spiral Galaxy and a new Galaxy Type is comming.

    -in the config the starsystem amount is now per constellation.

    -and a big "what you can do in js" is comming explaining how to make new galaxy Types.





    Now to the source as requested: http://es.racing4all.com/GalaxyGeneratorSources.zip

    BEWARE: Many Bugs are inside. They could crawl all over your desk^^ You have been warned.

    Also. All Public functions in the class Constellation return true.

    This is necrassary because mono hase a bug. void functions which are called from Jint will return a NullReferenceExpection AFTER the function finished. That was also the bug why this generator came 1week later. Happened the same time as a patch which didn´t realy messed with the api as we were thinking.

    For the optimisations my bottleneck is checkAllCrossings.



    You wan´t to look at following classes:

    WarpBuilder: ReduceConnectivity: i reduced FullyConnected by a lot. Every connection is only checked once. not for every removed Warp.

    Warp: saves the id so it doesn´t have to call IndexOf() anymore. also a performance killer with alot of systems.



    Configuration: getRandomStarName: bugfix endless loops. 2 hashsets are not equal if they have the same obkects in a different order. use count instead.

    Configuration: getRandomConstellationName same as getRandomStarName

    and the one in Galaxy which is already mentioned servial times in the generator thread.





    and yes i am late. But i had to do nothing for a while.
    0Send private message
    12 years ago
    Aug 29, 2012, 2:18:57 AM
    Hmm your generator was working perfectly last night and now I get a NullReferenceExpection. I don't know much about this stuff but since there was an update today I am assuming it has something to do with that.
    0Send private message
    12 years ago
    Aug 29, 2012, 6:17:59 AM
    Thanks a lot for the code sharing and the insights. I'll check that ASAP. You won +1 internet mister. smiley: wink
    0Send private message
    12 years ago
    Aug 29, 2012, 8:15:25 AM
    Fixed the NullReferenceExpection. Download in forst post.



    Patchnotes (copy paste):

    Removed all references to System.Drawing.dll. Mac users no longer have to install Mono 2.11.3.



    whats not in the original patchnotes is that they changed the random number generator. So the same seed will generate the same Galaxys on PC and Mac.
    0Send private message
    12 years ago
    Aug 29, 2012, 11:05:02 AM
    Actually, the in game generation was the same on PC and Mac. The difference comes from the Test, which is an exe to test output. That exe uses mono on mac, and .Net on PC. The Random algorithm in Mono and .Net are different, so the Test.exe will yield different results. But since Unity uses the Mono Random, it yields the same results as a Mac. So i've added the Random.cs from Mono to the Galaxy Generator, so people can yield the same results with Test.exe on PC and on Mac
    0Send private message
    12 years ago
    Aug 30, 2012, 5:37:25 AM
    Ty for the info but i think it would be better to compile the the programms with mono.

    This way you also find problems that are caused by bugs in mono.
    0Send private message
    0Send private message
    12 years ago
    Aug 30, 2012, 7:46:08 AM
    I've checked the output generation against my reference file, and as it actually speeds up the generation, it does not generate the same galaxy (resources and start planets). But i dont think it's a big deal. If one would want to really speed up things, it would lead to a whole rewrite of the generation algorithm, but he would face the same "problem" as a rewrite of the whole algorithm will inevitably lead to change the calls to Random, and thus, wont hit the same Random value at the same time as the original one.
    0Send private message
    12 years ago
    Aug 30, 2012, 10:46:50 AM
    i basicly rewrite most parts.

    To make it possible for multithreading you need to have separate Random objects.

    Otherwise it´s not guaranteed that one seed will generate the same galaxy over and over again.

    In my case every constellation has it´s own Random.
    0Send private message
    12 years ago
    Aug 30, 2012, 11:10:51 AM
    Well, doing my own round..so to speak,



    quad core I7

    nvidia geforce GT555m 2GB(as well as intel graphics card)

    8GB memory



    medium: loaded fine

    large: loaded fine without too much heat

    huge: from the start my laptop went into: 'I'ma fly outta here bitches mode'

    first 5 mins: my cores maxed out at around 88Celsius, my GPU at 95Celcius(My intel card went to 99Celsius(Load for both between 70-80%)), CPU was at 100%, memory stable at 5.58GB

    after 5-6 mins: CPU down to 20% and 70Celsius, GPU's back to around 70Celsius(Intel at 75Celsius(Load for both between 0-15%)),memory still stable around 5½.

    after 9 and 40 secs mins: Crash to desktop due to too many heaps



    In case it matters, I'm using 1.14
    0Send private message
    ?

    Click here to login

    Reply
    Comment

    Characters : 0
    No results
    0Send private message