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
Re: Stars! Nova 0.4.0 (developmental) Release Sun, 27 June 2010 14:58 Go to previous messageGo to next message
sirgwain is currently offline sirgwain

 
Chief Petty Officer

Messages: 82
Registered: March 2004
Location: Tucson
Daniel wrote on Fri, 25 June 2010 18:41

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



If you need any help understanding the code let me know. I find python to be easily readable, but I've been using it for some time. I'm working on converting this chunk of code to java to do some performance testing. When I have that done I'll post it here as well. Java is a lot closer to C# in syntax so you might be able to just cut and paste it, depending on how your Race class defines its properties.

-Craig

Report message to a moderator

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

 
Commander

Messages: 2760
Registered: October 2004
Location: Third star to the left
sirgwain wrote on Sun, 27 June 2010 20:55

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.


It's actually one of the pointers I wrote about:

ConstB wrote on Tue, 15 March 2005 16:04

race algo in c++ can be downloaded from http://constb.5u.com


Warning! raw C code in all its ugly glory! Rolling Eyes

Quote:

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

Silly me, that's what must have happened. My post is still intact, way up there... 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, 29 June 2010 22:02 Go to previous messageGo to next message
sirgwain is currently offline sirgwain

 
Chief Petty Officer

Messages: 82
Registered: March 2004
Location: Tucson
While converting the code from python to java, I checked it against the C code of constB and found some bugs.

The C code also has a different way of computing the advantage points from the habitability range. I think it's functionally the same, but it's the most complex part of the code so I'm not quite sure yet. As such, I would suggest using the C code or I can send you the required java files if you want something really easy to convert to C#.

-Craig

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Wed, 30 June 2010 08:06 Go to previous messageGo to next message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2760
Registered: October 2004
Location: Third star to the left
sirgwain wrote on Wed, 30 June 2010 04:02

I checked it against the C code of constB and found some bugs.

I guess those bugs were in the Python version? Sherlock


Quote:

The C code also has a different way of computing the advantage points from the habitability range. I think it's functionally the same, but it's the most complex part of the code so I'm not quite sure yet.

Any simpler, faster, or just easier to read version would be welcome! 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 Wed, 30 June 2010 13:09 Go to previous messageGo to next message
sirgwain is currently offline sirgwain

 
Chief Petty Officer

Messages: 82
Registered: March 2004
Location: Tucson
I've finished the Java version. It's taken from the C version. I think my decompiled flash version had some bugs, or my implementation of it did. I have unit tests for this code testing it against Humanoids, Humanoids with all Immune, Rabbitoids and Insectoids. I could do more but I got bored entering in all that data. Smile

Rather than posting the whole thing I put up a couple files on my website:

The RacePointsCalculator class. It has one static method that takes a Race class instance, and returns the advantage points for that race.
http://members.cox.net/ilovestars/racewizard/RacePointsCalcu lator.java

// the Race class, has the planet habitability calc
http://members.cox.net/ilovestars/racewizard/Race.java

// The Hab class, for storing planet and race habitability
http://members.cox.net/ilovestars/racewizard/Hab.java

// The ResearchCost class, used by the race
http://members.cox.net/ilovestars/racewizard/ResearchCost.ja va

// Finally the Consts class used to store constants, in this case just the starting points
http://members.cox.net/ilovestars/racewizard/Consts.java

I've peppered the code with comments, though it could probably use a "overview" type comment on the algorithm. I've also changed the code around a bit to make it more readable. The C version was full of int[3] arrays that I changed to Hab instances.

To convert it to C# you should just need a regex to convert get([A-Z]) to $1. Smile Damn java and it's stupid get/set methods.

It's insanely faster than the Python version. I'm not sure how much of that was Python and how much was the algorithm. I know Python is pretty slow compared to a compiled language, but holy moly. Now I'm not sure if I need a Javascript version for the client or not. The idea of supporting two versions sounds not fun.

Anyway, let me know if you have any questions.


Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Thu, 01 July 2010 16: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
Thanks, I have downloaded all those java files and will spend some time this weekend looking at them.


Have fun.

Report message to a moderator

Re: Stars! Nova 0.4.0 (developmental) Release Sat, 03 July 2010 10:39 Go to previous message
m.a@stars is currently offline m.a@stars

 
Commander

Messages: 2760
Registered: October 2004
Location: Third star to the left
It looks remarkably similar to my javascript version (itself a direct port of the original C code) Teleport

I too got tired of entering all the races for testing, but it paid off handsomely when every last bug and wrinkle were smoothed out. Sherlock



So many Stars, so few Missiles!

In space no one can hear you scheme! Deal

Report message to a moderator

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


Current Time: Wed Jul 28 06:12:11 EDT 2021