Adjust universe generation to place together team members

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

Moderator: Oberlus

Post Reply
User avatar
Cosmic Dragon
Posts: 2933
Joined: Mon Apr 10, 2017 4:25 pm

Adjust universe generation to place together team members

#1 Post by Oberlus »

swaq wrote: Fri Oct 25, 2019 7:27 pm3. I wish there was a way to ensure teams are contiguous in the galaxy.
Vezzra wrote: Sun Oct 27, 2019 12:53 pm
o01eg wrote: Sat Oct 26, 2019 8:32 pmIt's passed with PlayerSetupData in create_universe function.
Ah ok, that must have been added after I last tinkered with that code then. Well, good. If the data is passed in, expanding the algorithm to take team assignments into account shouldn't be too much of a problem. Except for the problem that I really don't have any time for this right now (or in the near/foreseeable future). Of course, anyone who wants is welcome to take on the task... ;)
I'd like to, by I my Python knowledge is close to zero. I'm toying with the idea.

I see the good stuff is in create_universe(psd_map) (default/python/universe_generation/

Code: Select all

    print "Compile list of home systems..."
    home_systems = compile_home_system_list(total_players, systems, gsd)
    if not home_systems:
        err_msg = "Python create_universe: couldn't get any home systems, ABORTING!"
        raise Exception(err_msg)
    print "Home systems:", home_systems

    # set up empires for each player
    for empire, psd, home_system in zip(psd_map.keys(), psd_map.values(), home_systems):
        if not setup_empire(empire, psd.empire_name, home_system, psd.starting_species, psd.player_name):
            report_error("Python create_universe: couldn't set up empire for player %s" % psd.player_name)
home_systems is compiled without any information about teams, just trying to ensure the minimum distances between HWs and the minimum number of planets in the vecinity of each HW.
setup_empire(), the function that assigns HWs to each player/empire, is called for each pair of player/empire and HWs taken as they come out from the players setup and the the list of HWs. That is, it currently assigns HWs to players in the same order they are given. So nothing to change there.
Maybe a good-enough solution could be to order the players in PlayerSetupData so that the members of each team are consecutive (before universe generation), and change compile_home_system_list() so that it returns a list of HWs for which HWs close in the list are also close in the galaxy. Hmmm...

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

Re: Adjust universe generation to place together team members

#2 Post by Vezzra »

My approach would be to take the list of home systems returned by compile_home_system_list and add another step before calling setup_empire on each player/empire. That step would handle the assignment of homeworlds to empires based on whatever criteria we might come up with, which should be done in a dedicated function (e.g. "assign_home_systems") that gets the list of players/empires and homeworlds passed in (currently there is no need for such a step/function because the assignment of home systems to empires is trivial - just take the next best, no criterias involved).

That way you can keep the functionality and steps cleanly modularized and set apart from each other, without making one function too much dependent on how the other does things. If you rely on compile_home_system_list to return the home systems in a certain order for subsequent steps to work properly, you introduce a high potential for future bugs - if someone tweaks the compile_home_system function for whatever reason and the order of the list of returned systems changes, that would break anything that relies on a specific order.

The assign_home_systems function would take the input and do all the deciding on which empire gets assigned which home system (based on whatever criteria, in our case predetermined teams), and should return a empire/home system map, which then can be used to call setup_empire for each empire with the assigned home system.

Post Reply