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!

#76 Post by Vezzra »

Cjkjvfnby wrote:IMHO you do duoble work on writting and supporting code. You write code in two langages (english and python).
True, but that's the way it is - writing comments takes time and effort (especially if you try to do it right). But it's an effort that is supposed to pay off, when you come back to code you haven't taken a look at for a long time, or when others have to work with your code and try to understand what strange things were going on in your mind when you wrote it ;)
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.
Also true, again but: Knowing me, if I don't add the comments immediately, I'll never do it. And even if, I'll probably get around to it so much later, that I'd need the comments already in place to understand what I'v been thinking when writing all that crap ;)

Everyone has his own style/preferences how to do that, I guess. See milesers reply. Also an interesting approach, but if I did it his way, I'd probably never get past producing a lot of comments...

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

Re: Scripted Universe Generation!

#77 Post by Vezzra »

Cjkjvfnby wrote: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
Incorporated and committed.

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

Re: Scripted Universe Generation!

#78 Post by Cjkjvfnby »

Sorry, too tired today to make usefull feedback, just some grooming.

Python code are full of multispaces. I make simple cleanup for pattern

Code: Select all

[\w,:]  +\w
Some PEP8 grooming

About new lines at the end of file.
http://stackoverflow.com/questions/7296 ... -a-newline
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

[The extension patch has been deactivated and can no longer be displayed.]

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!

#79 Post by Vezzra »

Cjkjvfnby wrote:Python code are full of multispaces.
The multiple white spaces in galaxy.py, planets.py and starsystems.py are intentional. They might not be in accordance with Python code guidelines, but IMO the formatting is easier on the eyes in this case, so I want to keep it the way it is. That's actually a style I adopted from FO's C++ source. The removal of multiple white spaces in starnames.py is ok and has been committed.
Some PEP8 grooming
That, and newlines at the end of the Python files commited.

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

Re: Scripted Universe Generation!

#80 Post by Geoff the Medio »

Code: Select all

4>..\..\universe\PythonUniverseGenerator.cpp(1359): error C2561: '`anonymous-namespace'::PythonErrorReport' : function must return a value
4>          ..\..\universe\PythonUniverseGenerator.cpp(1355) : see declaration of '`anonymous-namespace'::PythonErrorReport'
4>..\..\universe\PythonUniverseGenerator.cpp(1382): error C2561: '`anonymous-namespace'::PythonCreateUniverse' : function must return a value
4>          ..\..\universe\PythonUniverseGenerator.cpp(1377) : see declaration of '`anonymous-namespace'::PythonCreateUniverse'
4>

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

Re: Scripted Universe Generation!

#81 Post by Vezzra »

Geoff the Medio wrote:

Code: Select all

4>..\..\universe\PythonUniverseGenerator.cpp(1359): error C2561: '`anonymous-namespace'::PythonErrorReport' : function must return a value
4>          ..\..\universe\PythonUniverseGenerator.cpp(1355) : see declaration of '`anonymous-namespace'::PythonErrorReport'
4>..\..\universe\PythonUniverseGenerator.cpp(1382): error C2561: '`anonymous-namespace'::PythonCreateUniverse' : function must return a value
4>          ..\..\universe\PythonUniverseGenerator.cpp(1377) : see declaration of '`anonymous-namespace'::PythonCreateUniverse'
4>
Oh crap, stupid mistake :oops: Fixed, commit#7287

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

Re: Scripted Universe Generation!

#82 Post by Vezzra »

Two more changes to universe generation, one a minor adjustment, the other a not so minor improvement (hopefully):

1.) I renamed the "Irregular" and "Python Test" galaxy shapes (mainly because "Python Test" isn't something I want in the 0.4.4 release): the former "Irregular" is now "Irregular 1", and "Python Test" is now "Irregular 2". I know, not very creative, so if someone has a better idea... ;)

2.) I tried to improve the selection process for the starting home systems. There have been (justified) complaints that they don't get distributed evenly enough on the map, especially with a low number of empires on large maps. Too often several empires would end up cramped very closely together, while large areas of the map remain empty (which of course totally defeats setups where you want to have a large number of systems per empire, to prolong the time before they clash into each other). Home systems should now be far more evenly spread.

These changes will be in the test builds next week. Please test, especially point 2 of course.

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: Scripted Universe Generation!

#83 Post by adrian_broher »

Vezzra wrote:1.) I renamed the "Irregular" and "Python Test" galaxy shapes (mainly because "Python Test" isn't something I want in the 0.4.4 release): the former "Irregular" is now "Irregular 1", and "Python Test" is now "Irregular 2". I know, not very creative, so if someone has a better idea... ;)
From what I understood the python generator is a logical copy of the c++ generator. Why don't drop the C++ implementation for now?
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

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

Re: Scripted Universe Generation!

#84 Post by Vezzra »

adrian_broher wrote:From what I understood the python generator is a logical copy of the c++ generator. Why don't drop the C++ implementation for now?
No, the Python generator for "Irregular 2" is actually quite different from the C++ generator for "Irregular 1" (otherwise you're right, it would be pointless to keep both). Just look at the code or try it out, the difference should be obvious, at least on larger maps.

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

Re: Scripted Universe Generation!

#85 Post by MatGB »

The thing is, the "old" irregular wasn't, really, irregular, it was square. The new one, from the few games I've played, actually is irregular. But I dislike the name for both.

Quadrilateral for the old one? Peculiar for the new one?

Irregular is a better fit when it comes to astronomical terms for the new one, no term I'm aware of fits the old one well.
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
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Scripted Universe Generation!

#86 Post by Dilvish »

We might come up with better names, but in the meantime I think Irregular 1 and Irregular 2 is fine. I like them better than Quadrilateral and Peculiar. Although Irregular 1 does tend to have it's perimeter conform roughly to a square, it has irregular pattern of starlane connections within that perimeter.
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
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Scripted Universe Generation!

#87 Post by Dilvish »

Here's another thought -- let Python Test, currently Irregular 2, be simply Irregular, and call Irregular 1 "Boxy Irregular" or "Boxed Irregular"
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
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Scripted Universe Generation!

#88 Post by MatGB »

Works for me, only minor issue, if a player really likes the current irregular they'll be a bit confused, but I think that's a minor issue.
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!

#89 Post by Vezzra »

Dilvish wrote:"Boxy Irregular" or "Boxed Irregular"
"Square Irregular" / "Squared Irregular"?

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: Scripted Universe Generation!

#90 Post by adrian_broher »

Aside from the naming discussion: Do you plan to rip out the C++ implementation of the existing generators in favour of python equivalents?
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

Post Reply