Home » Stars! 2.6/7 » The Academy » Planet value calculation made easy!
Re: Planet value calculation made easy! |
Wed, 03 October 2007 16:45 |
|
regiss | | Petty Officer 1st Class | Messages: 65
Registered: November 2002 | |
|
Shouldn't this be moved to "Free Stars" or smth..
"Academy's" starting to gather up all kinds of posts I guess.
Report message to a moderator
|
|
| |
Re: Planet value calculation made easy! |
Mon, 17 November 2008 14:52 |
|
Kelzar | | Master Chief Petty Officer | Messages: 112
Registered: January 2006 Location: Ohio, US | |
|
Alright maybe I'm doing something wrong but according to this calculation it still seems to miss by 1% (up and down) for several cases I've tried. Lets use a simple 2 Immune, smallest bandwidth possible. There should be 11 different green habs and according to this calculation they would be ....
100,97,94,92,89,87,77,67,58,49 and 41.
I run a test bed and get a 6click from perfect planet as 76.
I've run several other testbeds and am getting variances with them also.
the equation boils down to
sqrt(21600/3)*.9+.9
or 77.2675 so I don't see some minor flakey rounding problem accounting for the variance.
Am I doing something wrong?
Report message to a moderator
|
|
| | | | |
Re: Planet value calculation made easy! |
Tue, 18 November 2008 20:45 |
|
|
Kelzar wrote on Tue, 18 November 2008 19:31 | According to the algorithm what percentage for
GravImm TempImm Rad37-63 race would you get for a 45mR planet?
I keep getting 89%, and if I completely remove all the rounding the most I can get the value up to (using the algorithm's calcs) is 89.9449
Two 45mR planets in the same testbed are showing as 90% planets.
One .21grav,64deg,45mR the other 3.92,-56deg,45mR
So do I still have something wrong or is there another Jeff factor buried in the calculation yet?
|
I can assure you that 89% is the correct value for any planet with Rad=45 with those hab settings.
Report message to a moderator
|
|
| | |
Re: Planet value calculation made easy! |
Wed, 19 November 2008 04:59 |
|
m.a@stars | | Commander | Messages: 2765
Registered: October 2004 Location: Third star to the left | |
|
Kelzar wrote on Wed, 19 November 2008 01:31 | According to the algorithm what percentage for
GravImm TempImm Rad37-63 race would you get for a 45mR planet?
|
90.
Quote: | I keep getting 89%, and if I completely remove all the rounding the most I can get the value up to (using the algorithm's calcs) is 89.9449
Two 45mR planets in the same testbed are showing as 90% planets.
One .21grav,64deg,45mR the other 3.92,-56deg,45mR
So do I still have something wrong or is there another Jeff factor buried in the calculation yet?
|
I'd need to know exactly how are you applying the formulas. Bear in mind that the posted algorithm is C, which means an integer truncation happens every time integer math is performed (which is a lot of times)
It is very unlikely a "Jeff Factor" is still buried somewhere in this, since this algorithm was extracted from Stars! own binary code. It is also part of race validation, which we have reverse-engineered too and found to be exact. Race validation calls planetValueCalc hundreds of times. Plus, before publishing it I validated the math against 35000 actual planet values lifted from 20 different universes for a bunch of different races.
So many Stars, so few Missiles!
In space no one can hear you scheme! Report message to a moderator
|
|
|
Re: Planet value calculation made easy! |
Wed, 19 November 2008 05:05 |
|
m.a@stars | | Commander | Messages: 2765
Registered: October 2004 Location: Third star to the left | |
|
Kelzar wrote on Mon, 17 November 2008 20:52 | Lets use a simple 2 Immune, smallest bandwidth possible. There should be 11 different green habs and according to this calculation they would be ....
100,97,94,92,89,87,77,67,58,49 and 41.
I run a test bed and get a 6click from perfect planet as 76.
|
The algorithm gets that too, as well as your whole sequence of hab values, for a Grav/Temp Immune + Rad40-60 race.
So many Stars, so few Missiles!
In space no one can hear you scheme! Report message to a moderator
|
|
| | | | |
Re: Planet value calculation made easy! |
Wed, 19 November 2008 20:05 |
|
|
[email | m.a@stars[/email] wrote on Wed, 19 November 2008 04:49]AlexTheGreat wrote on Wed, 19 November 2008 02:45 | I can assure you that 89% is the correct value for any planet with Rad=45 with those hab settings.
|
Are you sure on that? I get 90.
|
I've been using posey's method of calculating planet values for quite a while & have used it in a spreadsheet I created to calculate values for an entire universe for given race habs & at any tech levels. The only time it's ever been wrong is with very low grav planets, the ones where grav is shown as eg. 0.14 where you can't tell if it's actually 0.14 or 0.145.
I get 89% for all planets with Rad=45 regardless of other planet habs if race settings are Imm,Imm,37-63 (I modified 512 planets to all be Rad=45).
You seem to have gone into this quite deeply m.a. so I'll back off on the "I can assure you" & make it "in my experience it's always 89%".
Off subject here m.a. but I like your fuelusage.html. I use it often.
Have you thought about providing an alternative so that you can just specify the distance (as an alternative) rather than needing to put in the co-ordinates? That might not be as easy as it sounds tho since it looks like your coding depend upon co-ords.
[Updated on: Wed, 19 November 2008 20:19] Report message to a moderator
|
|
| |
Re: Planet value calculation made easy! |
Wed, 10 April 2013 05:05 |
|
XAPBob | | Lt. Commander | Messages: 957
Registered: August 2012 | |
|
Hi all - been pulling together a perl module to start playing with data...
The numbers I'm getting are close, but in various cases are a few (up to 4) percent out in either direction.
I'm about to fire up a fat (huge, packed) testbed with 16 different racial hab settings and then force gen it to oblivion (and elephant galleons) in order to get a significant data set (which I can share)
Can anyone spot any obvious bugs I've managed to generate whilst porting the C code in the first post to perl?
#!/usr/bin/perl
# Stars! check racial habs
use StarsHabCalc;
use warnings;
use strict;
use Switch;
sub usage {
print "This script takes two csv files as parameters:\n";
print " - A race hab file - this consists of four lines of data from the RW and game:\n";
print " - Low, High, Terraforming ability for each of\n";
print " - Grav, Temp, Rad\n";
print " - Followed by a racename\n";
print " - A planet data file - consisting of a line per planet:\n";
print " - Name, Grav, Temp, Rad (Any other fields are ignored, but retained)\n";
print "\n";
}
# CODE START:
my ($racefile, $planetfile) = @ARGV;
&StarsHabCalc::LoadRacial ($racefile);
open PLANETS, $planetfile or die $!;
while (my $line = <PLANETS>) {
chomp $line;
my @line = split(',', $line);
my $planet = shift @line;
my $grav = shift @line;
my $temp = shift @line;
my $rad = shift @line;
my @clicks = (&StarsHabCalc::GravToClicks($grav),
&StarsHabCalc::TempToClicks($temp),
&StarsHabCalc::RadToClicks($rad) );
print join(',', $planet, &StarsHabCalc::HabFromClicks(@clicks), $grav, $temp, $rad, @line) . "\n";
}
close PLANETS;
"use"s StarsHabCalc.pm:
#!/usr/bin/perl
# Stars! Hab calculator...
# Version 0.1
# Credit particularly due to m.a@stars on the SAH forums:
# http://starsautohost.org/sahforum2/index.php?t=msg&th=2299
package StarsHabCalc;
require Exporter;
use warnings;
use strict;
use Switch;
# Functions to take the value of parameter and convert to clicks:
sub RadToClicks {
my $rad = shift;
return $rad;
}
sub TempToClicks {
my $temp = shift;
return ($temp+200)/4;
}
sub GravToClicks {
# Early grav clicks are ambiguous: .12,.12,.13,.13,.14,.14,.15,.15,.16,.17,(.17)
# (.17) - The last ambiguous point and the lowest possible hab centre (wacky choice).
# We always assume the worst (i.e. the lower clicks), appropriate for planet values.
# For hab the click width is ALWAYS even, so we should be able to deduce hab properly
# in the appropriate function (not here though)
my $grav = shift;
my $result;
$grav *= 100;
my $lowerHalf = 1;
if ($grav < 100) {
$grav = int(10000/$grav); #integer truncation
$lowerHalf = -1;
}
if ($grav < 200) {
$result = ($grav /4) - 25; # NO integer truncation
} else {
$result = ($grav +400) / 24;
}
$result = int(50.9 + $lowerHalf * $result);
#one less ambiguity since planets can never be zero clicks
$result = 1 if ($result < 1);
return $result;
}
# Define racial paramters. All arrays are in order "grav, temp, rad"
our $racename;
our @centre;
our @radius;
our @terra;
sub LoadRacial {
my $file = $_[0];
open (RACE, $file) or die $!;
my @lines = <RACE>;
close (RACE);
chomp @lines;
for (my $i=0; $i<3; $i++) { #i.e. grav/temp/rad
my ($lower, $higher, $terra) = split(/,/, $lines[$i]);
if ($lower ne 'immune') {
switch ($i) {
case 0 { $lower = &GravToClicks($lower);
$higher = &GravToClicks($higher);
$lower = 0 if ($lower == 1); # Correct for the planet assumption above
$lower++ if (($higher - $lower) % 2 == 1);} #Width must always be even
# This can he
...
Report message to a moderator
|
|
| | |
Re: Planet value calculation made easy! |
Fri, 12 April 2013 07:29 |
|
XAPBob | | Lt. Commander | Messages: 957
Registered: August 2012 | |
|
Updated to the below.
$radius[$i] = ($higher - $lower) / 2;
$centre[$i] = $higher - $radius[$i];
$terra[$i] = $terra;
I get about 10% of planets where I have a 1% error (overwhelmingly I underestimate hab by 1%)
and a handful up to 4%
That handful is from a Huge Packed* universe (900+ planets) across 10 races with a variety of immunities and hab settings.
Summary: 9390 planets, 843 errors, 1@-4%, 3@-3%, 5@-2%, 86@-1%, 748@+1%
* Note - I used Map2XY to create a solid block of planets and then sent a scout to the middle of the group from each of the 10 JoAT races to ensure that in 2401 I had complete universe scanning...
I could automate much of that process now (gen, export map, remap, open each turn in turn (then I have to move a ship on half of them) then gen and export all the planet reports and analyse...
I've also added a GetRacial subroutine to allow exporting of the racial statistics.
Those "large" errors by the way:
Diff Difference between calculated and Stars! value
Planet Name of planet
Perl What I calculated the value to be
Stars! What Stars! reported
Grav/TEmp/Rad Stars reported
G/T/Rclicks Perl calculated
Race Name of race
RGrav/Temp/Rad Perl calculated (from values in put from RW)
G/T/Rwidth As above
Diff Planet Perl Stars! Grav Temp Rad Gclicks Tclicks Rclicks Race RGrav RTemp RRad Gwidth Twidth Rwidth
-4 H&M 54 58% 0.15 136 33 6 84 33 M9 22 78 31 22 22 23
-3 Cepheus 97 100% 0.17 -160 10 9 10 10 M8 10 10 10 10 10 10
-3 Dwarte 43 46% 0.15 148 24 6 87 24 M9 22 78 31 22 22 23
-3 Tattoo 32 35% 0.15 64 42 6 66 42 M9 22 78 31 22 22 23
-2 98053 41 43% 0.17 172 26 9 93 26 M9 22 78 31 22 22 23
-2 Accord 16 18% 0.17 56 51 9 64 51 M9 22 78 31 22 22 23
-2 Accord 48 50% 0.17 56 51 9 64 51 M5 50 50 50 50 50 50
-2 New 29 31% 0.15 120 12 6 80 12 M9 22 78 31 22 22 23
-2 W..ight 54 56% 0.17 -8 48 9 48 48 M5 50 50 50 50 50 50
[Updated on: Fri, 12 April 2013 10:29] Report message to a moderator
|
|
| | |
Re: Planet value calculation made easy! |
Fri, 12 April 2013 17:42 |
|
m.a@stars | | Commander | Messages: 2765
Registered: October 2004 Location: Third star to the left | |
|
XAPBob wrote on Fri, 12 April 2013 18:40I absolutely use the 'worst possible' assumption, and am confident that the grav is indeed the source of my errors - I *think* my racial grav clicks are corrected by being even widths...
Here's what my "planet value report" tool does to get the correct Grav "clicks" from the ambiguous values where the calculations and Stars! own datadump don't match:
theHabValue = planetValueCalc(grav, parseInt(temp)/4+50, parseInt(rad));
if (theHabValue!=ReportHab) { // report mismatch?
if (grav<11) {
grav++; //kludge. Not all hab combos need it :-?
theHabValue = planetValueCalc(grav, parseInt(temp)/4+50, parseInt(rad));
}
Quote:I hope the module can come in handy - it certainly makes short work of the calculations. I might pass in the racial hab to the main function as well - would allow easy comparisons of different race habs...
That's more or less what my "planet value report" tool does to see what planets are better for what races, be they allied or enemy.
[Updated on: Fri, 12 April 2013 17:42]
So many Stars, so few Missiles!
In space no one can hear you scheme! Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon May 13 03:39:58 EDT 2024
|