FreeOrion

Forums for the FreeOrion project
It is currently Sun May 26, 2013 9:42 am

All times are UTC




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: building colony
PostPosted: Sat Sep 01, 2007 2:04 pm 
Offline
Space Krill

Joined: Sat Sep 01, 2007 1:44 pm
Posts: 4
Hi there

I just downloaded the Game (http://psitronic.de/div/FO), everything works fine, however, if I found a new colony on any kind of planet (even superb) the colony starves (population decreases) and I can't do anything. What am I doing wrong?

tx in advance


Top
 Profile  
 
 Post subject: Re: building colony
PostPosted: Sat Sep 01, 2007 2:34 pm 
Offline
Design & Graphics Lead
User avatar

Joined: Sat Sep 23, 2006 7:09 pm
Posts: 3693
Location: USA — midwest
A new colony usually can't produce enough food to feed itself.
You need your homeworld or another established colony to produce a lot of food (primary or secondary focus on food) to allow the new colony to grow.

_________________
—• Read this First before posting Game Design Ideas!
—• Design Philosophy

—•— My Ideas, Organized —•— Get an Avatar —•— Acronyms —•—


Top
 Profile  
 
 Post subject: Re: building colony
PostPosted: Sat Sep 01, 2007 5:06 pm 
Offline
Space Krill

Joined: Sat Sep 01, 2007 1:44 pm
Posts: 4
tx eleazar

- If I colonize a planet in the very first round (therefore in the starting system), my new colony decays by
0.1->10m -> 1.05m -> 109 micro -> 11.4 micro -> 1.21 micro -> RIP

- if I set the focus on food twice on both colonies:
0.19 -> 40.3m -> 8.22m -> 856 micro -> RIP

- if I research self rotating crops before, no difference

- if I choose terrible or superb planets, no difference

do I need to transfer the food actively somehow?
do I have to wait some time with colonizing?


Top
 Profile  
 
 Post subject: Re: building colony
PostPosted: Sat Sep 01, 2007 7:30 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7899
Location: Vancouver, BC
It looks like there's a bug in the food distribution code. I don't recall changing it recently though, so that's a bit odd...


Top
 Profile  
 
 Post subject: Re: building colony
PostPosted: Sat Sep 01, 2007 7:45 pm 
Offline
Space Floater
User avatar

Joined: Tue Aug 28, 2007 3:51 am
Posts: 41
Geoff the Medio wrote:
It looks like there's a bug in the food distribution code. I don't recall changing it recently though, so that's a bit odd...


I've been having the same problem. They die (seemingly) regardless of focus. Which, needless to say, is a bit of a downer. :mrgreen:


Top
 Profile  
 
 Post subject: Re: building colony
PostPosted: Sun Sep 02, 2007 3:31 am 
Offline
Design & Graphics Lead
User avatar

Joined: Sat Sep 23, 2006 7:09 pm
Posts: 3693
Location: USA — midwest
Your second colony is a "Terran" type planet, right? (or at least an ocean or desert type)
Otherwise, it looks like a bug

_________________
—• Read this First before posting Game Design Ideas!
—• Design Philosophy

—•— My Ideas, Organized —•— Get an Avatar —•— Acronyms —•—


Top
 Profile  
 
 Post subject: Re: building colony
PostPosted: Sun Sep 02, 2007 8:24 am 
Offline
Space Floater
User avatar

Joined: Tue Aug 28, 2007 3:51 am
Posts: 41
eleazar wrote:
Your second colony is a "Terran" type planet, right?


Yep, it happens with superb (or whatever they're called) Terran planets. I had a dig through the code, but it's a large codebase with which I am unfamilar.


Top
 Profile  
 
 Post subject: Re: building colony
PostPosted: Sun Sep 02, 2007 9:11 am 
Offline
Space Krill

Joined: Sat Sep 01, 2007 1:44 pm
Posts: 4
Yes, the second colony is superb. Furthermore, the "quality" of the planet doesn't influence the behavior of the decay, a strong indicator for a bug. The decay depends only from the focus of the mother colony, but it's a decay anyway. Although I'm C/C++ developer myself for years, I don't have the time to take a deeper look. Therefore I kindly ask the dev team to check this out, like this it's not too funny :)


Top
 Profile  
 
 Post subject: Re: building colony
PostPosted: Sun Sep 02, 2007 10:23 am 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7899
Location: Vancouver, BC
The fact that the second colony's quality doesn't affect the decay rate isn't actually a bug indicator. Colonies start off totally undeveloped, and unable to produce any food for themselves, so depend on imports from other, more developed colonies such as the homeworld. This import should happen automatically as long as the homeworld is producing at least 1 unit (or equal to the new colony's population) of food more than it needs, which is one unit per unit of population, which should be 30.

If anyone wants to check out the food distribution code, it's in Empire::UpdateFoodDistribution() in Empire.cpp. Potential causes include planet farming or population meters not being properly set before the food distribution is done. Notably it seems to be happening the same on the sever and the client, since the client appears to correctly predict the change (based on tooltips for the planet population) that the server actually produces.


Top
 Profile  
 
 Post subject: Re: building colony
PostPosted: Sun Sep 02, 2007 10:37 am 
Offline
Compilation Expert
User avatar

Joined: Thu Jul 06, 2006 10:30 pm
Posts: 219
Location: Russia/Moscow
It appears that food produced isn't redistributed to other planets.


Attachments:
File comment: No excess food is produced in the entire empire.
screenshot1.png
screenshot1.png [ 2.43 KiB | Viewed 1813 times ]
File comment: Yet capital produces enough food to contribute to the empire stockpile. Where rest of food goes? Maybe the government is corrupted?
screenshot2.png
screenshot2.png [ 33.22 KiB | Viewed 1819 times ]

_________________
In Soviet Russia, forum posts YOU!!
Top
 Profile  
 
 Post subject: Re: building colony
PostPosted: Sun Sep 02, 2007 10:41 am 
Offline
Space Floater
User avatar

Joined: Tue Aug 28, 2007 3:51 am
Posts: 41
Geoff the Medio wrote:
Empire::UpdateFoodDistribution() in Empire.cpp..


Tsk. I was looking under ResourceCenter and PopCenter...


Top
 Profile  
 
 Post subject: Re: building colony
PostPosted: Sun Sep 02, 2007 11:08 am 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7899
Location: Vancouver, BC
loonycyborg: The capital actually isn't producing enough food to contribute to the empire stockpile. A planet will only contribute to the empire stockpile if it's producing more than twice it's population in food, and that extra food isn't being used up by any other planets. Note that the empire pool and empire stockpile aren't the same... in that food is put into the pool, and then dolled out to the planet that produced it with first priority, and then other planets, and only then after every planet has as much as it needs / wants, to the stockpile. The idea is that there are several levels of feeding, where you need food equal to population to prevent starvation, and up to twice population to get maximum growth rate.

I'd like to rewrite the food distribution algorithm though, particularly as fully maxed out population planets have no use for any food more than their population at present, so it's pointless to give them any that could otherwise be stockpiled. It's also just confusing how food distribution and stockpiling works now... which may be unavoidable, but presumably there could be a better reason for it to be unavoidably confusing than the way it is now.

bhelyer: If you're poking around in UpdateFoodDistribution, you could change any lines in UpdateFoodDistrubution and the equivalents for other resources that look like:

Code:
        UniverseObject *obj = dynamic_cast<UniverseObject*>(center);    // can't use universe_object_cast<UniverseObject*> because ResourceCenter is not derived from UniverseObject
        assert(obj);

        double need = center->MeterPoints(METER_FARMING);
to just
Code:
        double need = center->MeterPoints(METER_FARMING);

Since the casting is (I think) no longer necessary.

Similarly, if you find any code casting from ResourceCenter* or PopCenter* to UniverseObject* before using ->GetMeter(...), then that function can be made public instead of private on the ...Center classes and then accessed directly instead of via the cast.


Top
 Profile  
 
 Post subject: Re: building colony
PostPosted: Sun Sep 02, 2007 11:24 am 
Offline
Compilation Expert
User avatar

Joined: Thu Jul 06, 2006 10:30 pm
Posts: 219
Location: Russia/Moscow
Geoff the Medio wrote:
The capital actually isn't producing enough food to contribute to the empire stockpile.

Now it does and still doesn't contribute.


Attachments:
screenshot3.jpg
screenshot3.jpg [ 189.24 KiB | Viewed 1786 times ]

_________________
In Soviet Russia, forum posts YOU!!
Top
 Profile  
 
 Post subject: Re: building colony
PostPosted: Sun Sep 02, 2007 2:28 pm 
Offline
Space Floater
User avatar

Joined: Tue Aug 28, 2007 3:51 am
Posts: 41
Geoff the Medio wrote:
bhelyer: If you're poking around in UpdateFoodDistribution, you could change any lines in UpdateFoodDistrubution and the equivalents for other resources that look like:

Code:
        UniverseObject *obj = dynamic_cast<UniverseObject*>(center);    // can't use universe_object_cast<UniverseObject*> because ResourceCenter is not derived from UniverseObject
        assert(obj);

        double need = center->MeterPoints(METER_FARMING);
to just
Code:
        double need = center->MeterPoints(METER_FARMING);

Since the casting is (I think) no longer necessary.

Similarly, if you find any code casting from ResourceCenter* or PopCenter* to UniverseObject* before using ->GetMeter(...), then that function can be made public instead of private on the ...Center classes and then accessed directly instead of via the cast.


Code:
===================================================================
--- Empire/Empire.cpp   (revision 2244)
+++ Empire/Empire.cpp   (working copy)
@@ -1528,18 +1528,19 @@
         ResourceCenter *center = *res_it;
         UniverseObject *obj = dynamic_cast<UniverseObject*>(center);    // can't use universe_object_cast<UniverseObject*> because ResourceCenter is not derived from UniverseObject
         assert(obj);
-        fp_map[obj->ID()] = obj->MeterPoints(METER_FARMING);
+        fp_map[obj->ID()] = center->MeterPoints(METER_FARMING);
     }

     // first pass: give food to PopCenters that produce food, limited by their food need and their food production
     for (pop_it = pop_centers.begin(); pop_it != pop_centers.end() && available_food > 0.0; ++pop_it)
     {
         PopCenter *center = *pop_it;
-        UniverseObject *obj = dynamic_cast<UniverseObject*>(center);    // can't use universe_object_cast<UniverseObject*> because ResourceCenter is not derived from UniverseObject
-        assert(obj);

-        double need = obj->MeterPoints(METER_FARMING);  // basic need is current population - prevents starvation
+
+        double need = center->MeterPoints(METER_FARMING);  // basic need is current population - prevents starvation

+               UniverseObject *obj = dynamic_cast<UniverseObject*>(center);    // can't use universe_object_cast<UniverseObject*> because ResourceCenter is not derived from UniverseObject
+        assert(obj);
         // determine if, and if so how much, food this center produces locally
         double food_prod = 0.0;
         std::map<int, double>::iterator fp_map_it = fp_map.find(obj->ID());
@@ -1560,10 +1561,8 @@
     for (pop_it = pop_centers.begin(); pop_it != pop_centers.end() && available_food > 0.0; ++pop_it)
     {
         PopCenter *center = *pop_it;
-        UniverseObject *obj = dynamic_cast<UniverseObject*>(center);    // can't use universe_object_cast<UniverseObject*> because ResourceCenter is not derived from UniverseObject
-        assert(obj);

-        double need = obj->MeterPoints(METER_FARMING);
+        double need = center->MeterPoints(METER_FARMING);
         double has = center->AvailableFood();
         double addition = std::min(need - has, available_food);

@@ -1578,12 +1577,14 @@
     for (pop_it = pop_centers.begin(); pop_it != pop_centers.end() && available_food > 0.0; ++pop_it)
     {
         PopCenter *center = *pop_it;
-        UniverseObject *obj = dynamic_cast<UniverseObject*>(center);    // can't use universe_object_cast<UniverseObject*> because ResourceCenter is not derived from UniverseObject
-        assert(obj);

-        double basic_need = obj->MeterPoints(METER_FARMING);
+
+        double basic_need = center->MeterPoints(METER_FARMING);
         double full_need = 2 * basic_need;
         double has = center->AvailableFood();
+
+               UniverseObject *obj = dynamic_cast<UniverseObject*>(center);    // can't use universe_object_cast<UniverseObject*> because ResourceCenter is not derived from UniverseObject
+        assert(obj);

         double food_prod = 0.0;
         std::map<int, double>::iterator fp_map_it = fp_map.find(obj->ID());
@@ -1603,10 +1604,8 @@
     for (pop_it = pop_centers.begin(); pop_it != pop_centers.end() && available_food > 0.0; ++pop_it)
     {
         PopCenter *center = *pop_it;
-        UniverseObject *obj = dynamic_cast<UniverseObject*>(center);    // can't use universe_object_cast<UniverseObject*> because ResourceCenter is not derived from UniverseObject
-        assert(obj);

-        double basic_need = obj->MeterPoints(METER_FARMING);
+        double basic_need = center->MeterPoints(METER_FARMING);
         double full_need = 2*basic_need;
         double has = center->AvailableFood();
         double addition = std::min(full_need - has, available_food);


Like that? I left in any cast that was needed for ID()...you'll have to forgive me if I seem a little slow on the uptake, the network of Classes in FO is a lot more complicated than I've encountered so far.


Top
 Profile  
 
 Post subject: Re: building colony
PostPosted: Sun Sep 02, 2007 2:57 pm 
Offline
Programming, Design, and De Facto Lead
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 7899
Location: Vancouver, BC
bhelyer wrote:
I left in any cast that was needed for ID()

I was actually just going to edit my post to note that I realized ID() would still require a UniverseObject*. There might still be a slight benefit to changing it to call GetPoints() from a ResourceCenter* though, as UniverseObject::MeterPoints is virtual and is overriden by Planet::MeterPoints, which calls either PopCenter::MeterPoints or ResourceCenter::MeterPoints (both of which are also base classes of Planet) depending on the requested MeterType. So, if the dynamic_cast is faster / better than a virtual function call and second function call, it might be a bit better overall, but it's probably not worth the time I've spent writing about it...

Quote:
...you'll have to forgive me if I seem a little slow on the uptake, the network of Classes in FO is a lot more complicated than I've encountered so far.

I have no expectations that anybody would fully grasp the FO class structure after only a few days.

Edit: The problem was these lines:
Code:
double basic_need = obj->MeterPoints(METER_FARMING);

The need should have been based on population (METER_POPULATION), not farming output.

This occurred as an accidental consequence of my recent changes to how meters are stored and accessed.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group