Home » Stars! Clones, Extensions, Modding » FreeStars » some questions about coding
Re: some questions about coding |
Sat, 12 March 2005 07:45 |
|
m.a@stars | | Commander | Messages: 2765
Registered: October 2004 Location: Third star to the left | |
|
Hi,
ConstB wrote on Fri, 11 March 2005 18:02 |
I used these to generate some kind of value tables to look at, just was too lazy to invent backward translation.
|
No problem, I spent a joyful 15 minutes reversing your functions to my needs. The power of integer math
And, at least for the 1500+ planets present in the reports I had on hand, your functions work as advertised.
Summarizing:
- Clicks to Grav calculation: exact
- Grav to Clicks calculation: exact for unambiguous values of Grav. (code available on request)
- Hab value calculation: exact for a wide variety of cases, including CA and 1WW (immunities not tested). No ambiguous values of grav present in sample.
And all of these without time-consuming "higher math"! I think I'll update the HabCalc tool soon.
So, kudos to the "Russian reverse engineer" for revealing another beautiful instance of the Jeff's craft.
C U @ the Board!
[Updated on: Sat, 12 March 2005 12:04]
So many Stars, so few Missiles!
In space no one can hear you scheme! Report message to a moderator
|
|
| |
Re: some questions about coding |
Sat, 12 March 2005 09:19 |
|
m.a@stars | | Commander | Messages: 2765
Registered: October 2004 Location: Third star to the left | |
|
Hi,
ConstB wrote on Sat, 12 March 2005 14:19 | I feel ruined. I corrected fourth bug in my reversed code, but it's still doesn't work as expected. If you are interested in playing with this wrong code, I can either post it here (528 lines) or send it by e-mail.
|
Don't feel bad. That monster has defeated many bright people. Most of us believe that "algorithm" to be One Big Kludge, countless times tweaked by the Jeffs, sworn enemies of simplicity
While I bet I'm not the only one interested in playing with your code, I'm not sure if this board can handle so many lines. As a first step, you can send me a zipped copy in a PM, or in an email message (address to be found in your PM box) Assembly code would be very welcome.
Cheers,
[Updated on: Sat, 12 March 2005 09:24]
So many Stars, so few Missiles!
In space no one can hear you scheme! Report message to a moderator
|
|
| | |
Re: some questions about coding |
Thu, 17 March 2005 18:30 |
|
Marduk | | Ensign | Messages: 345
Registered: January 2003 Location: Dayton, OH | |
|
ConstB wrote on Fri, 11 March 2005 05:18 | planetValuePoints = sqrt((double)planetValuePoints/3)+0.9;
|
I don't think it is sqrt(3) - with a sample of 11,244 green habs, I got my best results dividing by 1.724. I presume some sort of rounding issue was at work. Here are the number of systems where my hab calculation was off by 1%, substituting different values for sqrt(3):
1.720 - 4391
1.721 - 4060
1.722 - 3768
1.723 - 3380
1.724 - 3068
1.725 - 3170
1.726 - 3195
1.727 - 3208
1.728 - 3229
1.729 - 3286
1.730 - 3334
1.731 - 3448
1.732 - 3521
root3 - 3528
I don't have time for it tonight, but tomorrow I'll check my formula against yours and see if it is the same - at a glance it looks to be slightly different, but you still might want to try dividing by something other than root 3.
The 11244 samples I got by using a JoaT race with all three habs at maximum width, making all systems green. No TT, as I wanted to limit my starting terraforming. I'll try again with TT at some point, since there are several more levels of terraforming available that way.
I set the race loose in a Huge, Dense galaxy, allowing only enough tech to get the fuel mizer, and then scanning every system. Once that was done, I saved a .P file - that gave me the base hab values and the hab after Grav3 and Temp3 terraforming (what I got with the fuel mizer). After that I advanced one terraforming milestone at a time, saving a .P file at each step. Since each file's terraformed hab values gave me another set of samples to check my formulas against, it was more or less like scanning another Huge, Dense galaxy each time.
Report message to a moderator
|
|
| | |
Re: some questions about coding |
Fri, 18 March 2005 19:48 |
|
m.a@stars | | Commander | Messages: 2765
Registered: October 2004 Location: Third star to the left | |
|
PricklyPear wrote on Fri, 18 March 2005 00:56 | The actual implementation is a double precision multiplication by 0.33333etc. and then sqrt. Not sure if this gives rise to differences in what you've implemented.
|
Interesting. So not *everything* is integer math out there...
But after testing about 35000 green, red and yellow planets (from 25 different races/hab schemes, including terraforming, immunities, 1WW, widebands, and whatnot), ConstB's original formula (and my newest reinterpretation, to be found in The Academy) remains exact. So, I say sqrt(3) stays.
{added latest latest test figures}
{a note on accuracy: planets whose grav values are ambiguous can give inexact results. For those I've coded a rematch with their other possible grav value. So far, all rematches have resulted in the correct values as stated in the planet report. }
[Updated on: Tue, 22 March 2005 07:05]
So many Stars, so few Missiles!
In space no one can hear you scheme! Report message to a moderator
|
|
| |
Re: some questions about coding |
Sat, 19 March 2005 20:50 |
|
Marduk | | Ensign | Messages: 345
Registered: January 2003 Location: Dayton, OH | |
|
m.a@stars wrote on Fri, 18 March 2005 07:24 |
Marduk wrote on Fri, 18 March 2005 00:30 | Since each file's terraformed hab values gave me another set of samples to check my formulas against, it was more or less like scanning another Huge, Dense galaxy each time.
|
If I understand correctly, terraforming capability will matter only in settled planets... So, did you colonize/terraform the whole huge galaxy?
|
In the planet report, there is a second planet value for complete (according to current tech) terraforming. It's the parenthetical hab value you see when examining a system. Assuming that is correct, and it seems to be, it gives you another hab value for a different set of system environment values.
Report message to a moderator
|
|
| | |
Re: some questions about coding |
Sun, 20 March 2005 18:56 |
|
m.a@stars | | Commander | Messages: 2765
Registered: October 2004 Location: Third star to the left | |
|
Hi,
I finally managed to write a more readable/simpler version of the planet value algorithm. I posted it in The Academy for all to enjoy/demolish:
http://starsautohost.org/sahforum/index.php?t=msg&th=229 9&start=0&rid=625&S=fdfca492d0e72c55f919e79b9d3f df95
Of particular interest to Freestars can be that my version makes the basic assumption that habitability is symmetrical around the center, that is, the ideal center is located in the middle of the lower and upper boundaries, and both halves have the same value. The original algorithm seems able to cope with weirder definitions, i.e: bottom is 20, top is 80, center is 65, and hab value stretches proportionally to the different length of both "halves"...
C U @ the Board!
{added explanation about symmetry}
[Updated on: Sun, 27 March 2005 16:23]
So many Stars, so few Missiles!
In space no one can hear you scheme! Report message to a moderator
|
|
|
Re: some questions about coding |
Sun, 19 February 2006 22:12 |
|
LEit | | Lt. Commander | Messages: 879
Registered: April 2003 Location: CT | |
|
ConstB wrote on Thu, 17 March 2005 12:48 | and about design - I don't see any relation between Player and Race. In stars.exe race info is made a part of player structure. and I find it right!..
|
Again, almost a year later...
class Player : public Race {
A Player is a Race, so all the race info is in the player class.
The code in Battle.cpp is very preliminary (still is). Battles arn't done, and I just wanted to get something going. I do intend to use something better then that bit of code, ideally getting starting positions out of the rules file. I'm not sure how to specify starting positions in XML though (other then just listing them all).
Smart pointers and static globals: Both seem like good ideas. I've never worried too much about losing pointers, because I'm pretty good at keeping track of them, and pretty good at tracking them down if I do lose them. However, being smart up front is safer. I'll have to learn about smart pointers, I understand the basics, it's the details I need to understand.
- LEitReport message to a moderator
|
|
|
Re: some questions about coding |
Mon, 20 February 2006 04:48 |
|
m.a@stars | | Commander | Messages: 2765
Registered: October 2004 Location: Third star to the left | |
|
LEit wrote on Mon, 20 February 2006 04:12 | The code in Battle.cpp is very preliminary (still is). Battles arn't done, and I just wanted to get something going. I do intend to use something better then that bit of code, ideally getting starting positions out of the rules file. I'm not sure how to specify starting positions in XML though (other then just listing them all).
|
If only I had the time, I'd love to work on the Battlesystem. As it is, I have given some thought to it, but haven't actually coded a thing.
Having to pull Freestars files from CVS by hand doesn't help a whole lot, either.
About starting positions: seems to me there can be some math behind them, perhaps akin to splitting a pie, but interleaving the race positions. Although just listing them all sounds easier.
[Updated on: Mon, 20 February 2006 08:54]
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 01:29:28 EDT 2024
|