Menu

#72 Spread distribute mobility among items

open
nobody
None
3
2005-10-01
2004-06-10
Jeff Cotter
No

Sometimes mobility is the limiting factor when
calculating the number of items that are distributed
during the update.

The mob-limited amount should be calculated as a
double, then the actual amount should be
determined using roundave().

When calculating the new sector mobility, the
double amount should be used, such that, in the
case of mob limted distribution, the mob is reduced
to exactly zero.

Herein, I am trying a different distribution scheme,
but it gives you the idea:

// some code before calculates integer amount that
the sector wants to distribute
amtcost = (double)amt; // this is utility to calculate
exact mobility usage

if (bestdp->sct_mobil < bestpathcost * amt)
{
amt = roundavg(bestdp->sct_mobil /
bestpathcost); // mobility limited at dp

amtcost = bestdp->sct_mobil / bestpathcost; //
this is utility to calculate exact mobility usage
}

// all go to move
bestdp->sct_item[item] -= amt;
bestdp->sct_mobil -= (int)(bestpathcost *
amtcost);
cp->sct_item[item] += amt;
// all done moving

Discussion

  • Markus Armbruster

    • priority: 5 --> 3
    • summary: distribute mobility calculation --> Spread distribute mobility among items
     
  • Markus Armbruster

    Logged In: YES
    user_id=596270

    The random rounding bit is somewhat problematic, because
    lucky dice can let mobility go negative.

    I figure spreading mobility fairly among all exports of a
    sector would be fairly straightforward in the current code.
    Imports are another matter, because the source sector is
    charged. I doubt it could be done there with reasonable effort.

     

Log in to post a comment.