Announcement

Collapse
No announcement yet.

Please help me finalize rush buying formula

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Please help me finalize rush buying formula

    My Civmanager Program is almost ready except that I am not confident about rush buying formula. Here's the variables to be considered:

    Building Item Type (1=unit, 2=improve,3=wonder)
    Building Item Total Shield (multiplied by 10 or user input number at the beginning of rules.txt)
    Available intermediate building items and their Shield Costs.
    Money needed to buy incrementally.

    I have all the above variables figured out. However I'm not sure I have found the minimum cost in money to buy a unit. This is because that one can first buy an improvement then switch to unit, or vise versa. Can anybody help? (Well, it is one of the rare situations when a PhD in math needs help in a math question.

  • #2
    Depending upon what you were buying though, you'd only ever consider rushing a unit/building/wonder(!?) in the first increment before changing type as doing so further down the line would result in halving your accumulated production. Hence you'd only check for the first increment... Or am I misunderstanding the question?

    Comment


    • #3
      Thanks, ravagon. Let's narrow down my problem.

      a) We don't need to automate buying wonders since they are so rare.
      b) We have two situations when buying a city improvement: if there have been some shields accumulated, then buy it directly; if no shields have been accumulated then we first buy the cheapest improvement or the cheapest unit, then buy the full shield box. A comparison will be made between the two options to pick the cheapest price.
      c) Things are more complicated when buying a unit. We need to compare the cost of incremental buying for units with all 'one time shot' switching approach (i.e., switch to improvement, buy certain shields then switch back. The optimum number of shields buying on the improvement part can be obtained when we exhaust the list). We don't want to switch for more than once, for the reason you mentioned.

      Did we miss something? Yes. What if your city can produce certain amount of shields each turn and you don't want to buy the whole thing? This will greatly impact calculations in parts b) and c).

      Comment


      • #4
        Originally posted by Xin Yu

        Did we miss something? Yes. What if your city can produce certain amount of shields each turn and you don't want to buy the whole thing? This will greatly impact calculations in parts b) and c).
        I didn't realize you were implementing this as well. That would complicate things somewhat.
        Is this intended for use in scenario's with units (potentially) exceeding the 240 shield limit, beyond which rush buying becomes ... problematic?

        As far as I can see the basic solution will be to order the production possibilities available for both improvements and units separately and by increasing price. Hence the key indicator will be the price differential between sequential "products"relative to the overall cost. ie: If the price "jump" to the next higher element in the desired queue exceeds that of incrementally buying up in the adjacent queue (accounting for the loss in switching production) then that particular step should be rejected.
        Not quite this simple of course as the position of the adjacent elements in the overall shield requirement is the most crucial thing. Is there a detailed "price-map" of shield cost for the remaining shields relative to the proportion already accumulated? The only factual (?) info I have on it is the 240 shield cycle and the diminishing return effect the closer you are to starting from scratch.

        I can't quite see why the rush-buying of an improvement for the cheapest possible cost wouldn't have the same problems as that of rush-buying a unit though...

        Now I'm getting a headache

        Comment

        Working...
        X