Scripted Universe Generation!

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Message
Author
User avatar
Vezzra
Release Manager, Design
Posts: 6102
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Scripted Universe Generation!

#61 Post by Vezzra »

MatGB wrote:Still reading this thread, but the details of the discussion currently are way over my head
Well, it's the "Programming" subforum after all... ;)
One thing that I would like to see, at some point, "scenario" generation involving set planet names as well as system names, so if naming a planet is possible that'd be good, but it's a low priority compared to some of the other things I know are planned.
That's already possible, and actually done. Naming of star systems and planets during universe generation happens entirely in Python.

User avatar
Vezzra
Release Manager, Design
Posts: 6102
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Scripted Universe Generation!

#62 Post by Vezzra »

Vezzra wrote:I've finally had enough of the current silly implementation for the "Python Test" galaxy shape and replaced it with something more interesting (I hope). Similar to "irregular", but a bit different. The difference is probably more noticeable with a high number of star systems. Check it out! ;)
I wasn't entirely satisfied with the results so I decided to tweak the algorithm a bit. The difference to the "standard" irregular galaxy shape should now be a bit more pronounced, and there shouldn't be such extremely long starlanes at the edges. Already committed, will be in the test builds next week.

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Scripted Universe Generation!

#63 Post by MatGB »

galaxy.py from [r7255] breaks with the most recent test binaries so I reverted to [r7253], finished one game in it and it looked interesting, but I messed up my research progress a bit.

Definitely nice to not be in a square galaxy where I know roughly where the edges are.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Vezzra
Release Manager, Design
Posts: 6102
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Scripted Universe Generation!

#64 Post by Vezzra »

MatGB wrote:galaxy.py from [r7255] breaks with the most recent test binaries
Yeah, because it uses a function added to the Python interface in r7255. I've attached a slightly adapted version that should work with your binary to this post.
Definitely nice to not be in a square galaxy where I know roughly where the edges are.
Yep, that's the idea :D I too like the irregular galaxy shape, but it's a bit square for my taste ;)
Attachments
galaxy.py.zip
(1.61 KiB) Downloaded 121 times

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Scripted Universe Generation!

#65 Post by MatGB »

It's turn 114, and I still don't know if a couple flanks are secure, that sentinel I haven't got past could be a whole AI empire, it's really nice, like playing clusters was before I figured out how easy it was to keep yourself secure in it.

Thx for file, not sure I'll have time to start a game with it but might, busy week.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Vezzra
Release Manager, Design
Posts: 6102
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Scripted Universe Generation!

#66 Post by Vezzra »

Further progress has been made, after starlane functions and native generation starting specials generation has now been moved to the Python script. That leaves space monster generation as the last thing that has to be migrated, after that universe generation will be completely done in Python. Stay tuned :D

User avatar
Vezzra
Release Manager, Design
Posts: 6102
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Scripted Universe Generation!

#67 Post by Vezzra »

@Cjkjvfnby: I haven't forgotten you and your patches (this includes the ones on other threads), I just want to finish moving the last bits of the universe generation process to Python, then I'll get back to your patches, ok?

User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Re: Scripted Universe Generation!

#68 Post by Cjkjvfnby »

Vezzra wrote:@Cjkjvfnby: I haven't forgotten you and your patches (this includes the ones on other threads), I just want to finish moving the last bits of the universe generation process to Python, then I'll get back to your patches, ok?
Ok.

Some comment on last patch comment.

Code: Select all

# if the chance for specials is 0, return immediately
if basic_chance <= 0:
    return
Please don't forget your code should be frendly for programers with low skill. Not for dumb people. This comment is almost 100% same as written code (almost becasues it contain wrong information it say == 0 you code <= 0).
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Vezzra
Release Manager, Design
Posts: 6102
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Scripted Universe Generation!

#69 Post by Vezzra »

Cjkjvfnby wrote:Please don't forget your code should be frendly for programers with low skill. Not for dumb people. This comment is almost 100% same as written code (almost becasues it contain wrong information it say == 0 you code <= 0).
Ack. As you've probably already noticed I tend to be a little bit too elaborate and verbose. That also has its impact on my code comments... :roll:

I'll remove that comment.

User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Re: Scripted Universe Generation!

#70 Post by Cjkjvfnby »

Vezzra wrote:
Cjkjvfnby wrote:Please don't forget your code should be frendly for programers with low skill. Not for dumb people. This comment is almost 100% same as written code (almost becasues it contain wrong information it say == 0 you code <= 0).
Ack. As you've probably already noticed I tend to be a little bit too elaborate and verbose. That also has its impact on my code comments... :roll:

I'll remove that comment.

IMHO you do duoble work on writting and supporting code. You write code in two langages (english and python). And it is possible to have desync issues between code and comments. May be you can make verbose implementation later, after finish some stage. This has one big benifit: after some time you will review you code again, and may found some issues.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

mileser
Space Squid
Posts: 57
Joined: Thu May 15, 2014 2:32 pm

Re: Scripted Universe Generation!

#71 Post by mileser »

Cjkjvfnby wrote:
Vezzra wrote:
Cjkjvfnby wrote:Please don't forget your code should be frendly for programers with low skill. Not for dumb people. This comment is almost 100% same as written code (almost becasues it contain wrong information it say == 0 you code <= 0).
Ack. As you've probably already noticed I tend to be a little bit too elaborate and verbose. That also has its impact on my code comments... :roll:

I'll remove that comment.

IMHO you do duoble work on writting and supporting code. You write code in two langages (english and python). And it is possible to have desync issues between code and comments. May be you can make verbose implementation later, after finish some stage. This has one big benifit: after some time you will review you code again, and may found some issues.
:lol:

Sorry for any derailing here, as I'm not programming, but...

when I did VBA for an Access database back in the day, I would write everything in English in comments what I wanted to do. THEN I would write the code to accomplish what I wanted. It really helped me structure my work. Later, a friend needed to do something very similar to what I did and I sent the modules to him and he was able to follow exactly what I was doing by using my comments and it made it easier for him to implement for his project.
OS: OS X 10.10 Yosemite, XCode 6.01
Also: If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Vezzra
Release Manager, Design
Posts: 6102
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Scripted Universe Generation!

#72 Post by Vezzra »

Space Monster generation has been migrated to the Python scripts. With this step the migration of the universe generation process has been completed, meaning the entire process is handled by Python now.

So, what are the next steps? First of all, feedback from our play testers. I need to know if, besides obvious errors/crashes, you notice any differences (that should not be there), especially when it comes to the distribution of natives, specials and space monsters, as these have been the parts that have been migrated recently. The next test builds will already include these changes, so you just need to grab them as soon as they are available :D

Then of course the tweaking, polishing, fixing of issues that pop up, extension of the Python interface (which as of now only contains the necessary functions to reproduce current behaviour) etc. will start. And at some point I'll probably have to provide some kind of Scripted Universe Generation User Guide/Reference manual.

So yeah, there is still plenty of work to be done :D

Let the feedback come!

User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Re: Scripted Universe Generation!

#73 Post by Cjkjvfnby »

Vezzra wrote: Let the feedback come!
Run pycharm inspector (right click on folder > Inspect code...) to get first feedback. (unused import, unused variables, style issues)
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Re: Scripted Universe Generation!

#74 Post by Cjkjvfnby »

options.py: constants are usaully named IN_UPPERCASE (in pycharm you can call two action for fast renaming "rename"(will rename all usages too) and "toggle_case").

util.py: you can use math.hypot for distance
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Vezzra
Release Manager, Design
Posts: 6102
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Scripted Universe Generation!

#75 Post by Vezzra »

@Cjkjvfnby: So, I've finally come around to look more seriously at your patches/suggestions. I started with this one:
Cjkjvfnby wrote:remove function that can be onliner and used once
use zip to pair some values
https://github.com/Cjkjvfnby/freeorion/ ... 481419c38a
Incorporated and committed.
As I already said in my first response, the starnames module has been specifically dedicated to Dilvishs star group naming mechanic, therefore the name_planets function doesn't really belong there. As it's basically a function that applies to a star system as a whole, I think the proper place for it still is the starsystems module.

Of course that way it can't be integrated into the name_star_systems function, but I don't want to do that anyway. As I said in my earlier post, these two functions might not end up being called right after each other, so they are kept separate purposely.
4) Possible changes in generate_home_system_list
Again: As I said already in my previous post, this function needs to be rewritten anyway. Spending too much time simplifying code that will get thrown out isn't worth the effort.

Post Reply