Home World Forum
Stars! AutoHost web forums

Jump to Stars! AutoHost


 
 
Home » Stars! Clones, Extensions, Modding » Stars! Nova - Open Discussion and Help » Stars! Nova 0.4.0 (developmental) Release
Stars! Nova 0.4.0 (developmental) Release Sat, 29 May 2010 05:49 Go to next message
Daniel is currently offline Daniel

 
Chief Warrant Officer 3
Stars! Nova developer
Stars! Nova developer

Messages: 179
Registered: April 2006
Location: Nowra, Australia
Stars! Nova version 0.4.0 has been released.

Disclaimer: This is a developmental release and should not be expected to be a playable game.

For those interested in checking out the progress this project has made since our last release in 2009, you can download a windows installer from sourceforge. You can also download the source package - if you are so inclined. A package suitable for linux (under mono) will be added shortly.

A guide to get you started is available here.

For a summary of what has changed since our last release, read on:

General:

- Improved automatic locating of installed components to reduce
the required user setup.

- Update all licensing notices.

- Improved support for mono/linux installations (including
multiple cross platform issues).

- Fixed a variety of issues causing the game to crash
unexpectedly.

- Added various command line options for launching the game in
different ways:
Start Launcher
Nova --launch
Start New Game wizard
Nova --new
Start Race Designer
Nova --race
Start Component Editor
Nova --components
Start Console
Nova --console
Start GUI
Nova --gui -r <race> -t <turn> -i <intel file> -s <state file>
Run AI
Nova --ai -r <race> -t <turn> -i <intel file>
Display the help screen
Nova --help

- Changed registry root to from Ken Reed's name to Stars-Nova.

- Merged WinForms projects into one project (Nova) to generate
a single exe.

- Changed remaining .NET 2.0 projects to .NET 3.5.

- Various typographical fixes.

- Files created by Stars! Nova now have more meaningful
extension. Some of the files have been converted from binary
serialisations to gzipped xml to improve accessibility by 3rd
party applications.

- Added keyboard accelerators and shortcuts.



Installer:

- Added a new windows installer.



Launcher:

- Created a NovaLauncher application to act as the
entry/starting point for players



New Game wizard:

- Games can be given a name.

- Can now select number of players, player races and AI/Human
control.

- Added a new map generator with options to control map
generation parameters from the new game wizard.

- Added a .settings file to capture game information determined
from the New Game wizard.

- Added a Tutorial button to the New Game Wizard. (However
there is no tutorial yet.)



Race Designer:

- Set initial focus on password text box in Race Designer.

- Allowed the race files to be stored in a separate directory
to the Game Files.

- Fixes to the Race Designer such that the advantage point
total is correctly updated on loading a race, and all controls
in the race wizard are updated.

- Fixed problem with Race Designer advantage points not
updating when changing PRT and LRT.



GUI:
- Enabled the transfer cargo dialog by default as it was
sometimes disabled when it should not be.

- Improve map zoom, scroll and scaling the background image
for non-default maps.

- Radius of a minefield is now calculated properly.

- Fleets update which planet they are orbiting when they move.

- The production dialogue no longer lists the current star
base design as a production option.

- Corrected the planetary resource calculations.

- Planet Detail modified to display dock capacity.

- Added starting tech appropriate to PRT & LRTs.

- Modified resource calculation implementation for production
units and order.

- Implemented multi-phase battle movement and fractional battle
movement

- Fixed ISB discount bug.

- Fixed the cheap factory bug so that the 1 kT benefit is only
applied once.



Console:

- Improved automation of turn generation.

- Updated layout.

- Double clicking a race now launches the GUI.

- Intel split up per race (still contains 'everything': needs
to be filtered per race).



AI:

- Added an AI stub (AI submits turns but takes no actions).



Documentation:

- Added "Getting Started" guide to installation and a shortcut
to the start menu. Guide is also available on the project wiki
from: https://sourceforge.net/apps/mediawiki/stars-nova/index.php? title=Main_Page



Component Editor:

- Added a progress dialog for when loading the component
definition file.




Have fun.

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Sat, 29 May 2010 19:56 Go to previous messageGo to next message
Coyote is currently offline Coyote

 
Lt. Commander

Messages: 906
Registered: November 2002
Location: Pacific NW

Factory operation 14 and 15 /10k grants too many RW points.

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Sat, 29 May 2010 21:13 Go to previous messageGo to next message
evild00d is currently offline evild00d

 
Crewman 2nd Class
Stars! Nova developer
Stars! Nova developer

Messages: 14
Registered: July 2009
Location: Norway
Thanks for trying out the release. I've registered the bug on SF.net and (likely) fixed it in our source code. Hopefully you won't have to wait yet another year for the next release Smile

SF.net issue: http://sourceforge.net/support/tracker.php?aid=3009089

The original code for the factory operation points looked like this:
new ParameterEntry("OperableFactories", new int[26] {10,
               0,   0,   0,   0, -66,
             -53, -39, -26, -13,   0,
              14,  27,  39, -52, -65,
              78, 100, 123, 146, 169,
             192, 229, 257, 285, 313}),

The values at index 14 (-52) and 15 (-65) were accidentally negative instead of positive. I just removed the minus sign and hopefully the values are now correct.

Nicely spotted Coyote.

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Sun, 30 May 2010 19:43 Go to previous messageGo to next message
Coyote is currently offline Coyote

 
Lt. Commander

Messages: 906
Registered: November 2002
Location: Pacific NW

Also, the left and right arrow keys move the map up and down.

Terraforming, stargates and mass drivers can be added to general-purpose ship slots, this would be fixable in the component editor easily though.

Cheap Engines costs points instead of granting them.

So I take it that nothing actually builds yet?

Remind me sometime to make some proper player badges, ok? I'm surprised you're still using the ones I threw together in about 20 minutes one day while bored. :3


[Updated on: Mon, 31 May 2010 03:18]

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Mon, 31 May 2010 04:48 Go to previous messageGo to next message
Daniel is currently offline Daniel

 
Chief Warrant Officer 3
Stars! Nova developer
Stars! Nova developer

Messages: 179
Registered: April 2006
Location: Nowra, Australia
Thanks for the feedback. The more eyes we have to spot issues the easier it is to find and fix them:

Coyote wrote on Mon, 31 May 2010 09:43

Also, the left and right arrow keys move the map up and down.


Added to bugs, priority 3 (low). Should be easy to fix though.

Coyote wrote...


Terraforming, stargates and mass drivers can be added to general-purpose ship slots, this would be fixable in the component editor easily though.



This needs code changes to redefine 'General' slots. The same definition is currently used for both ships and star-bases. Gates will need to be fitted to ships for the MT gating ship, and all of these combinations may be allowable for expansion games. A narrower definition of general is required to implement the Stars! behavior. Priority 4 assigned. Will require a bit of work.

Coyote wrote...


Cheap Engines costs points instead of granting them.



Thanks for spotting that. Fixed in subversion, will be in next release. Now costs 80 points. Cool

Coyote wrote...


So I take it that nothing actually builds yet?



Things build. Make sure to build some factories first, then some mines...

Note that partial construction does not work so you will need a lot of resources to get a space station up. Try ISB so you can get a dock up before getting too bored. You should be able to colonize and explore. Invasion and bombing have some issues...

Coyote wrote...


Remind me sometime to make some proper player badges, ok? I'm surprised you're still using the ones I threw together in about 20 minutes one day while bored. :3


More pretty pics are very welcome Surprised



Have fun.

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Mon, 31 May 2010 09:28 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2765
Registered: October 2004
Location: Third star to the left
evild00d wrote on Sun, 30 May 2010 03:13

The original code for the factory operation points looked like this:
new ParameterEntry("OperableFactories", new int[26] {10,
               0,   0,   0,   0, -66,
             -53, -39, -26, -13,   0,
              14,  27,  39, -52, -65,
              78, 100, 123, 146, 169,
             192, 229, 257, 285, 313}),



The algorithm for the original Stars! Race Wizard Points is well known and tested as correct Deal, but doesn't look at all like that. I guess this is some evolution/improvement? Sherlock



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Mon, 31 May 2010 09:44 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2765
Registered: October 2004
Location: Third star to the left
Daniel wrote on Mon, 31 May 2010 10:48

This needs code changes to redefine 'General' slots. The same definition is currently used for both ships and star-bases.

"General Purpose" is just a handy abbreviation that the original Stars uses for certain slot combinations that actually mean "Mine, Elect, Mech, Missile, Beam, Armor, Shield, Scanner". That is, all but Engines, Mining Robots, Bombs, or Orbitals. Deal

That kind of slot combination is only found on ships, if memory serves. Sherlock


Quote:

Gates will need to be fitted to ships for the MT gating ship, and all of these combinations may be allowable for expansion games. A narrower definition of general is required to implement the Stars! behavior. Priority 4 assigned. Will require a bit of work.

The Jump Gate is a Mechanical item, and can be fitted to any slot that accepts these. Interestingly enough, no Starbase hull has that kind of slot. Teleport

Stars! original bitcodes for all these combinations are flexible enough for a lot of expansion, even if there's room for improvement.



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Mon, 31 May 2010 16:44 Go to previous messageGo to next message
Daniel is currently offline Daniel

 
Chief Warrant Officer 3
Stars! Nova developer
Stars! Nova developer

Messages: 179
Registered: April 2006
Location: Nowra, Australia
m.a@stars wrote on Mon, 31 May 2010 23:28


The algorithm for the original Stars! Race Wizard Points is well known and tested as correct Deal, but doesn't look at all like that. I guess this is some evolution/improvement? Sherlock


No. I have suspected, and you have now confirmed, that Ken came up with his own best guesses for the Race Designer. I have seen a web based race designer but I haven't seen the code/guts/algorithm, can you point me in the right direction?

We can probably live with the approximation for a while but the aim of Stars! Nova is to clone Stars! - additional options are ok, but version 1.0 should work as Stars! does in most respects (less some known bugs, plus some graphical enhancements). In general: if it doesn't work like Stars! it is a bug.

---

Thanks for the notes on what general purpose is, I have added them to the bug report so we can get that right.

The notes on the Jump Gate are helpful too. I copied a lot of stuff from this forum to a file but it was not spelled out what the base type of each of the items was, though most are obvious with some thought.

Did you manage to get as far as building a base and launching some ships? Is there something not obvious to us devs that makes this not seem possible? Or is it just the failure to do partial construction?



Have fun.

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Mon, 31 May 2010 21:59 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2765
Registered: October 2004
Location: Third star to the left
Daniel wrote on Mon, 31 May 2010 22:44

No. I have suspected, and you have now confirmed, that Ken came up with his own best guesses for the Race Designer.

That would explain it. I had guessed he used the info unearthed here and there. Sherlock


Quote:

I have seen a web based race designer but I haven't seen the code/guts/algorithm, can you point me in the right direction?

Ready, aim... go!
Also, this old FreeStars thread full of pointers. Deal


Quote:

Thanks for the notes on what general purpose is, I have added them to the bug report so we can get that right.

The notes on the Jump Gate are helpful too. I copied a lot of stuff from this forum to a file but it was not spelled out what the base type of each of the items was, though most are obvious with some thought.

I use an "unmodified Stars! items dump" from StarEd that I used to build this handy little table. I got the initial "allitems" table at StarsFaq.


Quote:

Did you manage to get as far as building a base and launching some ships? Is there something not obvious to us devs that makes this not seem possible? Or is it just the failure to do partial construction?

Nope. No time and a fragile winXP prevent me from actually perusing your fine work. Sad That's why I favor javascript lately. Rolling Eyes



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Tue, 01 June 2010 01:59 Go to previous messageGo to next message
gible

 
Commander

Messages: 1343
Registered: November 2002
Location: Wellington, New Zealand

m.a@stars wrote on Tue, 01 June 2010 01:44

Daniel wrote on Mon, 31 May 2010 10:48

This needs code changes to redefine 'General' slots. The same definition is currently used for both ships and star-bases.

"General Purpose" is just a handy abbreviation that the original Stars uses for certain slot combinations that actually mean "Mine, Elect, Mech, Missile, Beam, Armor, Shield, Scanner". That is, all but Engines, Mining Robots, Bombs, or Orbitals. Deal

That kind of slot combination is only found on ships, if memory serves. Sherlock


Quote:

Gates will need to be fitted to ships for the MT gating ship, and all of these combinations may be allowable for expansion games. A narrower definition of general is required to implement the Stars! behavior. Priority 4 assigned. Will require a bit of work.

The Jump Gate is a Mechanical item, and can be fitted to any slot that accepts these. Interestingly enough, no Starbase hull has that kind of slot. Teleport

Stars! original bitcodes for all these combinations are flexible enough for a lot of expansion, even if there's room for improvement.


A general purpose slot does NOT allow bombs or mining robots. They don't appear on starbases but I doubt they allow orbitals either.

The Geneticus Mod has pretty much ship every slot there is comverted to a "combo" slot that allows pretty much anything afaik. Certainly it allows the mining robots & bombs that the general purpose slot doesn't allow. Also, I'm don't know who named it, Stars! or the mod makers.

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Tue, 01 June 2010 05:27 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2765
Registered: October 2004
Location: Third star to the left
gible wrote on Tue, 01 June 2010 07:59

m.a@stars wrote on Tue, 01 June 2010 01:44

all but Engines, Mining Robots, Bombs, or Orbitals. Deal

That kind of slot combination is only found on ships, if memory serves. Sherlock


A general purpose slot does NOT allow bombs or mining robots. They don't appear on starbases but I doubt they allow orbitals either.

Exactly what I said. Rolling Eyes


Quote:

I'm don't know who named it, Stars! or the mod makers.

Who named what? Confused



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Tue, 01 June 2010 07:06 Go to previous messageGo to next message
gible

 
Commander

Messages: 1343
Registered: November 2002
Location: Wellington, New Zealand

m.a@stars wrote on Tue, 01 June 2010 21:27

Exactly what I said. Rolling Eyes
Indeed. Very Happy

m.a@stars wrote on Tue, 01 June 2010 21:27

Quote:

I'm don't know who named it, Stars! or the mod makers.

Who named what? Confused
Named the anything-fits-here-slot "combo"

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Tue, 01 June 2010 16:42 Go to previous messageGo to next message
Daniel is currently offline Daniel

 
Chief Warrant Officer 3
Stars! Nova developer
Stars! Nova developer

Messages: 179
Registered: April 2006
Location: Nowra, Australia
Thanks for all the pointers on the race wizard. They will take a bit of time to digest.


Have fun.

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Tue, 01 June 2010 23:25 Go to previous messageGo to next message
Coyote is currently offline Coyote

 
Lt. Commander

Messages: 906
Registered: November 2002
Location: Pacific NW

I've updated the components file - mostly fixing race permissions, but I added the mining properties to the robo-miners and fixed a couple incorrect graphics too.
I don't know the right numbers for the defense installations, but I guesstimated some that are nonzero.

Uploaded here since it's convenient



EDIT: Second update, fixed engines too!

The "fastest free speed" setting in the component editor sets the same value for ALL engines. However, it's not really necessary as that's set individually by the speed settings per engine anyway, so why not remove it altogether?


EDIT: Third update, all bombs now have the proper kill%. Orbital Construction Module now bombs, but the editor will only allow a maximum minimum kill of 1000, instead of the 2000 it's supposed to have.


[Updated on: Wed, 02 June 2010 20:02]

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Fri, 04 June 2010 21:29 Go to previous messageGo to next message
Daniel is currently offline Daniel

 
Chief Warrant Officer 3
Stars! Nova developer
Stars! Nova developer

Messages: 179
Registered: April 2006
Location: Nowra, Australia
Thanks Coyote,

Your third version of the components has been added to subversion. I then increased the limit on minimum kill to 10000 and increased the orbital construction module to a minimum kill of 2000.

The "fastest free speed" should be updated from the engine performance parameters and doesn't need to be a numeric up/down box. I have raised a bug report for that (issue #3009376, priority 3).

For the defense installations do you mean that the percent coverage for different numbers of installations is not being displayed? I have raised a bug report for that too (issue #3011692, priority 3).

Due to all the feedback so far we are considering doing a bug fix release so you can see the fruits of your labor.




Have fun.

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Wed, 09 June 2010 23:12 Go to previous messageGo to next message
Coyote is currently offline Coyote

 
Lt. Commander

Messages: 906
Registered: November 2002
Location: Pacific NW

Playing around more, I've found a serious issue. When cargo is unloaded onto a planet, it replaces whatever is on the planet instead of adding to it - I just turned my homeworld into an empty husk except for a 250kt pile of boranium (after filling then unloading a ship). No population or other minerals.
New Shocked
Also...
Colony ships don't seem to have a cargo bay. Adding fuel pods seems to not increase displayed fuel, adding cargo pods replaces the hull's cargo capacity with capacity added by pods instead of adding them all together.


I also missed the correct race permissions for speed trap 20 and orbital construction module Wall Bash


[Updated on: Wed, 09 June 2010 23:16]

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Thu, 10 June 2010 16:45 Go to previous messageGo to next message
evild00d is currently offline evild00d

 
Crewman 2nd Class
Stars! Nova developer
Stars! Nova developer

Messages: 14
Registered: July 2009
Location: Norway
I fixed the colony ship cargo and fuel capacity problems in the ship designer when I added support for replacing components. The fix will likely be included in the bugfix release.

Ship Designer Component Replacement/Removal issue: http://sourceforge.net/support/tracker.php?aid=3009384

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Fri, 11 June 2010 07:28 Go to previous messageGo to next message
Daniel is currently offline Daniel

 
Chief Warrant Officer 3
Stars! Nova developer
Stars! Nova developer

Messages: 179
Registered: April 2006
Location: Nowra, Australia
I have updated the components to add race restrictions for speed trap 20 (IS and SD only) and orbital construction module (AR only).

Bug #3013233 (priority 7) has been updated with additional information regarding problems with summing up ship/fleet cargo capacity. This requires a bit of work as there are problems with the current way cargo is tracked between fleets and ships.

Bug #3014797 (priority 7) raised for the contents of the planet being replaced with what is dropped.

Thanks Coyote for the excellent bug reports. Due to the quality feedback we are getting from the HWF community we are planning on doing a bug fix release to encourage continued testing.



Have fun.

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Fri, 11 June 2010 15:09 Go to previous messageGo to next message
Coyote is currently offline Coyote

 
Lt. Commander

Messages: 906
Registered: November 2002
Location: Pacific NW

No problem! Thanks for all your hard work, it's not going unappreciated. Cheers

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Thu, 24 June 2010 20:29 Go to previous messageGo to next message
Coyote is currently offline Coyote

 
Lt. Commander

Messages: 906
Registered: November 2002
Location: Pacific NW

Could you do us a huge favor and make the warp-speed slider larger so it's not such a pain to adjust? That's the largest UI gripe I have, and I'm sure things will be worked out eventually.

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Fri, 25 June 2010 14:21 Go to previous messageGo to next message
sirgwain is currently offline sirgwain

 
Senior Chief Petty Officer

Messages: 86
Registered: March 2004
Location: Tucson
Quote:

I have seen a web based race designer but I haven't seen the code/guts/algorithm, can you point me in the right direction?

Ready, aim... go!
Also, this old FreeStars thread full of pointers. Deal

I had to actually decompile the flash race wizard to get the algorithm for planet hab calculations. It's a pain in the neck.

For posterity, here is the python code in all its glory. This is the Race class which has the calculations for advantage points. I haven't been working on this in a while. It's almost a straight copy of the code I decompiled from the flash version and I tried to add comments where I could figure out what was going on. It still makes my head spin a bit. It's also TERRIBLY slow. I don't know if you'd see this in a compiled language, but in a scripting language like python it takes a long time to generate all those fake planets for the hab values. Given how fast and lightweight the original Stars! was, I wonder if this algorithm is entirely accurate.

class Race(object):
    """
    A race the user uses in the game.  Each user can have multiple
    races, and when joining a game a copy of the race is made and assigned to the game
    """
    
    def __init__(self, name, plural_name=None):
        self.name = name
        if plural_name is None:
            self.plural_name = str(name) + 's'
        else:
            self.plural_name = plural_name
            
        self.game = None
        self.user = None
        self.prt = None
        self.lrts = []
        self.hab_low = Hab()
        self.hab_high = Hab()
        self.growth_rate = None
        self.colonists_per_resource = None
        self.factory_output = None
        self.factory_cost = None
        self.num_factories = None
        self.factories_cost_less = None
        self.mine_output = None
        self.mine_cost = None
        self.num_mines = None
        self.techs_start_high = None
        self.spend_leftovers_on = None
        self.immune_grav = None
        self.immune_temp = None
        self.immune_rad = None
        self.research_cost = ResearchCost()
        
        # hab points used in race point calcs
        self.habpoints = None

    def __repr__(self):
        return "<Race: %s (%s) PRT: %s, LRTs: %s, Hab(%s -> %s immune: (%s %s %s)), rc: %s>" % (self.name, self.plural_name, self.prt, self.lrts, self.hab_low, self.hab_high, self.immune_grav, self.immune_temp, self.immune_rad, self.research_cost)

    @classmethod
    def humanoid(cls, user):
        """
        Create an instance of a Race with default Humanoid properties
        """
        race = Race('Humanoid', 'Humanoids')
        race.prt = PRT.JoaT
        race.lrts = []
        race.hab_low = Hab(15, 15, 15)
        race.hab_high = Hab(85, 85, 85)
        
        race.growth_rate = .15
        race.colonists_per_resource = 1000
        race.factory_output = 10
        race.factory_cost = 10
        race.num_factories = 10
        race.factories_cost_less = False
        race.mine_output = 10
        race.mine_cost = 5
        race.num_mines = 10
        race.techs_start_high = False
        race.immune_grav = False
        race.immune_temp = False
        race.immune_rad = False
        race.spend_leftovers_on = SpendLeftoversOn.SurfaceMinerals
        
        race.research_cost = ResearchCost(ResearchCostLevel.Standard, ResearchCostLevel.Standard, ResearchCostLevel.Standard, ResearchCostLevel.Standard, ResearchCostLevel.Standard, ResearchCostLevel.Standard)
        
        race.user = user
        race.init()
        return race
        
        
    def habcenter(self, index):
        """
        Return the center point of this hab, i.e. for
        hab 25 to 75 the center is 50
        hab 60 to 100 the center is 80
        """
        #return (self.hab_high[index] + self.hab_low[index]) / 2
        return self._habcenter[index]
        
    def habwidth(self, index):
        """
        The habwidth of a race (away from center)
        for 25 to 75 the width is 25 (25 away from 50)
        for 60 to 100 the width is 20        
        """
        #return (self.hab_high[index] - self.hab_low[index]) / 2
        return self._habwidth[index]
        
    def immune(self, index):
        """
        Return true if this race is immmune to the given index of hab
        type, i.e. 0 == immune_grav
        """
        if index == 0:
            return self.immune_grav
        elif index == 1:
            return self.immune_temp
        else:
            return self.immune_rad
    
    def research_cost_for_level(self, field, level):
        """
        Get the research cost for a tech field/level
        """
        cost = Consts.tech_research_cost[level]
        rcl = self.research_cost[field]
        if rcl == ResearchCostLevel.Extra:
            cost *= (1.75)
        elif rcl == ResearchCostLevel.Less:
            cost *= (.5)

        return int(cost)
    
    def haslrt(self, lrt):
        return self.lrts is not None and lrt in self.lrts
        
    def advantage_points(self):
        """
        Compute the advantage points for this race
        """
        points = Consts.race_starting_points
        
        if self.habpoints is None:
            self.habpoints = self._hab_points() / 2000;
        
        gr_factor = int(self.growth_rate * 100 + 0.5);   # use raw growth rate, otherwise HEs pay for GR at 2x
        gr_rate = gr_factor;

        # update the points based on growth rate
        if gr_factor <= 5:
            points += (6 - gr_factor) * 4200;
        elif gr_factor <= 13:
            if gr_factor == 6: points += 3600
            if gr_factor == 7: points += 2250
            if gr_factor == 8: points += 600
            if gr_factor == 9: points += 225
            gr_factor = gr_factor * 2 - 5;
        elif gr_factor < 20:
            gr_factor = (gr_factor - 6) * 3
        else:
            gr_factor = 45;

        points -= int(self.habpoints * gr_factor + .5) / 24
        
        # give points for off center habs
        immunities = 0
        for habtype in xrange(0, 3):
            if self.immune(habtype):
                immunities += 1
            else:
                points += abs(self.habcenter(habtype) - 50) * 4
            
        # multiple immunities are penalized extra            
        if immunities > 1:
            points -= 150
            
        # determine factory costs
        oper_points = self.num_factories;
        prod_points = self.factory_output;

        if oper_points > 10 or prod_points > 10:
            oper_points -= 9
            if oper_points < 1:
                oper_points = 1
            prod_points -= 9
            if prod_points < 1:
                prod_points = 1

            # HE penalty, 2 for all PRTs execpt 3 for HE
            if self.prt == PRT.HE:
                factory_production_cost = 3
            else:
                factory_production_cost = 2
            
            prod_points *= factory_production_cost

            # additional penalty for two- and three-immune
            if immunities >= 2:
                points -= ((prod_points * oper_points) * gr_rate) / 2
            else:
                points -= ((prod_points * oper_points) * gr_rate) / 9
    
        # pop efficiency
        popeff = self.colonists_per_resource / 100
        if popeff > 25: popeff = 25
        
        if popeff <=  7: points -= 2400
        elif popeff == 8: points -= 1260
        elif popeff == 9: points -= 600
        elif popeff > 10: points += (popeff - 10) * 120
        
        # factory points (AR races have very simple points)
        if self.prt == PRT.AR:
            points += 210
        else:
            prodpoints = 10 - self.factory_output
            costpoints = 10 - self.factory_cost
            operpoints = 10 - self.num_factories
            tmppoints = 0
            
            if prodpoints > 0:
                tmppoints = prodpoints * 100
            else:
                tmppoints = prodpoints * 121
            
            if costpoints > 0:
                tmppoints += costpoints * costpoints * -60
            else:
                tmppoints += costpoints * -55
            
            if operpoints > 0:
                tmppoints += operpoints * 40
            else:
                tmppoints += operpoints * 35
            
            # limit low factory points
            llfp = 700
            if tmppoints > llfp:
                tmppoints = (tmppoints - llfp) / 3 + llfp
            
            
            if operpoints <= -7:
                if operpoints < -11:
                    if operpoints < -14:
                        tmppoints -= 360
                    else:
                        tmppoints += (operpoints + 7) * 45
                else:
                    tmppoints += (operpoints + 6) * 30
            
            if operpoints <= -3:
                tmppoints += (prodpoints + 2) * 60
            """
            I have this commented out in my code.  I wish I could remember why.  I don't think it's needed but I can't remember where it came from.  Dang.
            if operpoints > 14:
                tmppoints -= 360
            elif operpoints > 11:
                tmppoints -= (operpoints - 7) * 45
            elif operpoints > =7:
                tmppoints -= (operpoints - 6) * 30
            
            if prodpoints >= 3:
                tmppoints -= (prodpoints -2) * 60
            """
            points += tmppoints
            
            if self.factories_cost_less:
                points -= 175
            
            # mines
            prodpoints = 10 - self.mine_output
            costpoints = 3 - self.mine_cost
            operpoints = 10 - self.num_mines
            tmppoints = 0
            
            if prodpoints > 0:                
                tmppoints = prodpoints * 100
            else:
                tmppoints = prodpoints * 169
            
            if costpoints > 0:
                tmppoints -= 360
            else:
                tmppoints += (costpoints * -65 + 80)
            
            if operpoints > 0:
                tmppoints += operpoints * 40
            else:
                tmppoints += operpoints * 35
            
            points += tmppoints
    
        # prt and lrt point costs
        points -= prt_point_cost[self.prt]
        if self.lrts is not None:
            for lrt in self.lrts:
                points -= lrt_point_cost[lrt]
    
        # too many lrts
        goodlrts = 0
        badlrts = 0
        
        # figure out how many bad vs good lrts we have.
        if self.lrts is not None:
            for lrt in self.lrts:
                if lrt_point_cost[lrt] > 0:
                    goodlrts += 1
                else:
                    badlrts += 1
        
        if badlrts + goodlrts > 4:
            points -= (badlrts + goodlrts) * (badlrts + goodlrts - 4) * 10
        if badlrts - goodlrts > 3:
            points -= (badlrts - goodlrts - 3) * 60
        if goodlrts - badlrts > 3:
            points -= (goodlrts - badlrts - 3) * 40
        
        # No Advanced scanners is penalized in some races
        if self.lrts is not None and LRT.NAS in self.lrts:
            if self.prt == PRT.PP:
                points -= 280
            elif self.prt == PRT.SS:
                points -= 200
            elif self.prt == PRT.JoaT:
                points -= 40
        
        # techs
        techcosts = 0
        for rc in self.research_cost:
            if rc == ResearchCostLevel.Extra:
                techcosts -= 1
            elif rc == ResearchCostLevel.Less:
                techcosts += 1
        if techcosts > 0:
            points -= (techcosts**2)*130
            if techcosts >= 6:
                points += 1430 # already paid 4680 so true cost is 3250
            elif techcosts == 5:
                points += 520 # already paid 3250 so true cost is 2730
        elif techcosts < 0:
            techcosts -= techcosts
            points += techcosts * (techcosts + 9) * 15
            if techcosts >= 6:
                points += 30
            if techcosts > 4 and self.colonists_per_resource < 1000:
                points -= 190
        
        if self.techs_start_high:
            points -= 180
        
        if self.prt == PRT.AR and self.research_cost.energy == ResearchCostLevel.Extra:
            points -= 100
        
        return points / 3
    
    def _hab_points(self):
        rp = RacePoints(self)
        return rp.points()
        
        
class RacePoints(object):
    
    def __init__(self, race):
        self.race = race        
        
    def points(self):
        # create a blank planet with no name at (0, 0)
        self.planet = Planet('', 0, 0)
        # create a blank Habitability setting
        self.planet.hab = Hab()
        
        self.test_hab_width = [50, 50, 50]
        self.test_hab_start = [20, 20, 20]
        self.iternum = [11, 11, 11]
        self.tfdone = [0, 0, 0]
        if self.race.lrts is not None and LRT.TT in self.race.lrts:
            self.ttfactor = [0, 8, 17]
        else:
            self.ttfactor = [0, 5, 15]
                    
        points = 0.0
        
        for h in xrange(0, 3):
            if h == 0:
                desire_factor = 7
                ttfactor = self.ttfactor[0]
            elif h == 1:
                desire_factor = 5
                ttfactor = self.ttfactor[1]
            else:
                desire_factor = 6
                ttfactor = self.ttfactor[2]
    
            for habtype in xrange(0, 3):
                if self.race.immune(habtype):
                    self.test_hab_start[habtype] = 50
                    self.test_hab_width[habtype] = 11
                    self.iternum[habtype] = 1
                else:
                    self.test_hab_start[habtype] = self.race.habcenter(habtype) - self.race.habwidth(habtype) - ttfactor
                    if self.test_hab_start[habtype] < 0:
                        self.test_hab_start[habtype] = 0
                    tmphab = self.race.habcenter(habtype) + self.race.habwidth(habtype) + ttfactor
                    if tmphab > 100:
                        tmphab = 100
                    self.test_hab_width[habtype] = tmphab - self.test_hab_start[habtype];
            points += self.points_recursion(0, desire_factor, ttfactor)
        
        return int(points / 10.0 + .5)   
        
    def points_recursion(self, habtype, desire_factor, ttfactor):
        sumoverhab = 0.0
        
        if habtype < 3:
            for i in xrange(0, self.iternum[habtype]):
                if i == 0 or self.iternum[habtype] <= 1:
                    tmphab = self.test_hab_start[habtype]
                else:
                    tmphab = self.test_hab_width[habtype] * i / (self.iternum[habtype] - 1) + self.test_hab_start[habtype]
                
                # account for terraforming
                if ttfactor != 0 and not self.race.immune(habtype):
                    tmphab2 = self.race.habcenter(habtype) - tmphab
                    if abs(tmphab2) <= ttfactor:
                        tmphab2 = 0
                    elif tmphab2 < 0:
                        tmphab2 += ttfactor
                    else:
                        tmphab2 -= ttfactor
                    
                    self.tfdone[habtype] = tmphab2
                    tmphab = self.race.habcenter(habtype) - tmphab2
                
                self.planet.hab[habtype] = tmphab
                sumoverhab += self.points_recursion(habtype + 1, desire_factor, ttfactor)
            
            if not self.race.immune(habtype):
                sumoverhab = sumoverhab * self.test_hab_width[habtype] / 100;
            else:
                # if immune to this trait, the value is always the same
                # so just sum it all 11 times
                sumoverhab *= 11;
        else:

            sumoverhab = self.planet.hab_value(self.race)#, pall, rall, iftall)
            maxterra = 0
            for i in xrange(0, 3):
                maxterra += self.tfdone[i]
            
            if maxterra > ttfactor:
                sumoverhab -= maxterra - ttfactor
                if sumoverhab < 0:
                    sumoverhab = 0
            sumoverhab *= sumoverhab
            sumoverhab *= desire_factor
        
        return sumoverhab



Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Fri, 25 June 2010 18:41 Go to previous messageGo to next message
Daniel is currently offline Daniel

 
Chief Warrant Officer 3
Stars! Nova developer
Stars! Nova developer

Messages: 179
Registered: April 2006
Location: Nowra, Australia
Thanks Coyote, bug issue #3021599 raised on the slider and I have given it an elevated priority as it is so frequently used.

Thanks sirgwain for the code. That is going to take some time to digest.

I'm hoping to do a bug fix release this weekend. We tried last weekend but encountered some issues.



Have fun.

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Sun, 27 June 2010 13:46 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2765
Registered: October 2004
Location: Third star to the left
sirgwain wrote on Fri, 25 June 2010 20:21

Given how fast and lightweight the original Stars! was, I wonder if this algorithm is entirely accurate.

That code is very similar to the original ASM/CPP code as published by constB. Fortunately, optimized compiled ASM/CPP is quite fast. Cool

Now I wonder how and when and why did your post overwrite mine. Evil or Very Mad



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Sun, 27 June 2010 13:48 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2765
Registered: October 2004
Location: Third star to the left
Daniel wrote on Sat, 26 June 2010 00:41

Thanks sirgwain for the code. That is going to take some time to digest.

His version at least has comments and meaningful variable names. Consider yourself lucky. Twisted Evil



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Sun, 27 June 2010 14:55 Go to previous messageGo to previous message
sirgwain is currently offline sirgwain

 
Senior Chief Petty Officer

Messages: 86
Registered: March 2004
Location: Tucson
m.a@stars wrote on Sun, 27 June 2010 13:46


That code is very similar to the original ASM/CPP code as published by constB. Fortunately, optimized compiled ASM/CPP is quite fast. Cool

Now I wonder how and when and why did your post overwrite mine. Evil or Very Mad


Do you have a link to the constB code? I remember looking around for code and the best I could find was the flash race wizard.

My post overwrote yours? I had some misquotes in there (I must have deleted a /quote accidentally).

Report message to a moderator

Previous Topic: Stars! Nova - May Update
Next Topic: Stars! Nova 0.4.1 Developmental Release
Goto Forum:
  


Current Time: Thu Mar 28 18:54:48 EDT 2024