Alpha Centauri 2

Sid Meier's Alpha Centauri & Alien Crossfire => The Theory of Everything => Topic started by: kyrub on February 04, 2013, 12:41:42 AM

Title: Unit cost BUG (vote for solution, please)
Post by: kyrub on February 04, 2013, 12:41:42 AM
I played with a workshop in a testgame and I must say that I am totally confused over the unit cost issue. It's totally crazy, haphazard.


Case 1)
A garrison infantry unit, 8-10-1*3. It costs 40 minerals. According to formula
http://alphacentauri2.info/mediawiki/index.php?title=Unit_Cost_%28Advanced%29 (http://alphacentauri2.info/mediawiki/index.php?title=Unit_Cost_%28Advanced%29),

the unit should cost
Quote
Cost = Weapon * (Armor + Speed) * 10 / (2(Reactor + 1))

8 *10 *10 / 16 = 50, which is then "halved for unit with speed 1" => 25. Minimum cost for a unit is
Quote
(Reactor*2 - Reactor/2)*10

which gives us probably  (6-2 rounded up?) * 10 = 40 cost. Great!

But the rules say that
Quote
Cost +10 minerals if both Weapon and Armor greater than 1.

So it's somehow different. Can anybody help me?


Case 2)
Let's give this unit an ability, High Morale. The cost jumps to 48. Why the heck? It should be up by 25%, which is 50.

Case 3) 
Let's try to add another, secondary ability, AAA tracking (cost factor 1). The unit price should now be up by 25% + 25%. Last time we added +8 for High Morale, this time ït will be double, 56, no? Wow, it's 72. I try removing both "factor 1" abilities and putting in Drop pods as "factor 2". This should give the same 72 result as both factor 1s togethe... You fool, it's 64 now!

Case 4)
Let's change AAA to Comm Jammer, while conserving the High morale. The cost is back to 48 --- which is right, as Comm Jammer cost factor is Attack/Defense = 8/10 rounded down = 0. Uff, finally something is right.

Case 5)
Now the real fun begins. - Let's change primary High Morale (cost factor 1) to AAA tracking (cost factor 1). The AAA, ECM unit cost should stay the same as Trained, ECM, no? Never. It jumps up to 64 !!! Changing to Cloaked, ECM gives me the same result. Only High morale + Comm Jammer gives me the right numbers, costs only 48! Well, seriously, what is this? A bug, surely?
Title: Re: Unit cost mysteries (and a bug?)
Post by: kyrub on February 04, 2013, 01:29:40 AM
OK, I have figured up the first part. In the game I have +2 INDUSTRY (which I forgot).

So, (case 1) the lowest reactor cost is actually:
Quote
(Reactor*2 - Reactor/2)*10
(3*2 - 3/2 rounded down) * 10 = 5 *10 = 50 minerals (with the industry bonus it's 40).

The same goes for (Case 2) : 50 minerals + 25% for special ability = 60  (with the industry bonus it's 48).


But in next cases, I am lost.
Title: Re: Unit cost mysteries (and a bug?)
Post by: BFG on February 04, 2013, 04:29:48 AM
All I can offer is that it's possible to create a unit with a cost of 9,120 minerals in the vanilla game  ;lol
Title: Re: Unit cost mysteries (and a bug?)
Post by: Yitzi on February 04, 2013, 04:50:21 PM
I believe you have found an undocumented feature of the cost formula, and a bug to go with it.  What happens is: If you have two special abilities on a unit, that is worth another +1 special-ability cost, unless the first one is free.  However, in this context "first one" doesn't refer to the one that you put first in the unit design, but rather the one that's first in a predetermined order set by the game (which may be related to stuff in alphax, I'm not sure.)

Now, this is presumably a bug, and one that I can fix in version 1.3 of my patch, but to do that I'd need to know what should happen.  Should that extra +1 simply be removed?  Should it be negated if either of the abilities is free?  Or should it always apply (IMO, most likely the original intent)?
Title: Re: Unit cost mysteries (and a bug?)
Post by: ete on February 04, 2013, 05:23:32 PM
I'd favor negating the +1 if either ability is free, though depending on the code it's possible that current behavior is intended. I feel like free abilities should always be free, and that was likely the intention.
Title: Re: Unit cost mysteries (and a bug?)
Post by: kyrub on February 04, 2013, 05:33:42 PM
Good find, Yitzi. I've looked there and you are right.
For the wiki: Having 2 special abilities => extra +25% cost. This is the original feature of the game.
The other part, e.g. the bug is dependent on the rank of abilities in alpha.txt. If the "free" ability precedes, it costs 0.

- Yitzi, I dislike the extra 25% for 2 abilities. However, while I find it a rather poor feature, it should be respected as it is clealy intended for the basic version of the game. Grr.
- I suggest that you make a flag in alpha.txt, where the extra 25% can be removed.
- I think that if one of two abilities is "free", the unit cost should never increase, not the other way round. This is just my opinion, let's see what others think.

----------
The other discrepancies I found are down to rounding. It's lazy programming as well, IMHO.

The cost may be 50, but it is 5 in internal code. Then 25% represents 1.25, rounded to 1. However, 50% is 2.5, which is rounded up to 3.

Therefore
simple unit cost = 5*10 = 50
unit +1 abi cost = (5 + 1.25) * 10 = 6*10 = 60
unit + 2 abi cost = (5 + 2.5) * 10 = 7*10 = 70
unit + 1 abi + 1 abi = (5 + 3.75) * 10 = 9*10 = 90
Title: Re: Unit cost mysteries (and a bug?)
Post by: Yitzi on February 04, 2013, 05:57:55 PM
- I suggest that you make a flag in alpha.txt, where the extra 25% can be removed.

I think that'll wait for version 2, where I'll take requests, as we'll probably want a whole bunch of flags related to the unit cost formula.

Quote
The cost may be 50, but it is 5 in internal code.

Not just internal code; it is treated as "5 rows", which is then multiplied by your minerals-per-row (by default 10-INDUSTRY, but that 10 can itself be modified in alphax.txt.)
Title: Re: Unit cost mysteries (and a bug?)
Post by: ete on February 04, 2013, 07:05:08 PM
Added to wiki: http://alphacentauri2.info/mediawiki/index.php?title=Unit_Cost_%28Advanced%29&action=historysubmit&diff=424&oldid=318 (http://alphacentauri2.info/mediawiki/index.php?title=Unit_Cost_%28Advanced%29&action=historysubmit&diff=424&oldid=318)
Title: Re: Unit cost mysteries (and a bug?)
Post by: BFG on February 04, 2013, 11:26:05 PM
For the wiki: Having 2 special abilities => extra +25% cost. This is the original feature of the game.

...

- Yitzi, I dislike the extra 25% for 2 abilities. However, while I find it a rather poor feature, it should be respected as it is clealy intended for the basic version of the game. Grr.
Are we sure that was an original feature of the game?  Keeping in mind I'm just an outside observer, how do we know that's not something that was originally documented as a feature of the game, but later removed (or never implemented) because Firaxis realized it was a poor choice?

If you do implement this in the game, then rather than (or perhaps in addition to) adding flags to disable in alphax.txt, I'd recommend also adding a bonus that automatically disables the additional cost later in the tech tree - perhaps at Biomachinery.
Title: Re: Unit cost mysteries (and a bug?)
Post by: kyrub on February 04, 2013, 11:52:07 PM
There is this line in a program loop checking all special abilities:
IF (extra_cost=/= 0) THEN increase (extra_cost)

This simply suggests that when an extra bonus has already been added (due to a primary special ability), then it should be further increased just for the fact, that another special ability is now detected.
Still, it IS possible that this was actually omitted, left over in the code from a previous alpha version of SMAC. The fact that this feature is not documented at all is quite strange, since it is pretty relevant to unit building. In fact, it is more relevant than all other extra rules, like "when armor and weapon > 1 add 10 minerals".


If there are more people who would like to see this "cost" feature excluded from the game, we may put up a poll and decide the issue.
Title: Re: Unit cost mysteries (and a bug?)
Post by: BFG on February 05, 2013, 02:04:49 AM
If there are more people who would like to see this "cost" feature excluded from the game, we may put up a poll and decide the issue.
Curiouser and curiouser.  From what you're saying, it would be impossible to determine definitively if Firaxis intended to include this in the final build.  Well, my vote would be to include it provided it could be disabled, or is automatically disabled at Biomachinery or a similar higher level tech.

EDIT: The total number of possible units (under stock SMAX rules) is no more than 4 million.  And it's likely closer to half that (but an exact number would require significantly more work).  85% of those are combat units.  You know, in case anyone's interested.
Title: Re: Unit cost mysteries (and a bug?)
Post by: Yitzi on February 05, 2013, 03:33:09 AM
Curiouser and curiouser.  From what you're saying, it would be impossible to determine definitively if Firaxis intended to include this in the final build.

There's no reason to think they didn't, as they did put it in.  They simply made a coding mistake that makes free abilities sometimes (but not always) count.  I could fairly easily make the free abilities always count toward the extra +1, and even more easily make them never count (and easiest of all would be removing the +25% for 2 abilities entirely.)

Quote
Well, my vote would be to include it provided it could be disabled, or is automatically disabled at Biomachinery or a similar higher level tech.

Making it possible to disable (immediately or at a later tech) would be a job for a later patch*; I'm not yet ready to take requests for new alphax-dependent features.  For now, it'll be a single formula.

*I make no guarantees regarding my ability to do such a thing; I probably could, but I'm not certain (as there is no precedent for tech affecting the cost of a unit, merely its availability.)  Even if I could, it would likely apply only to units designed after the tech was researched, so you'd have to go back and re-build all your designs.
Title: Re: Unit cost mysteries (and a bug?)
Post by: gwillybj on February 05, 2013, 06:40:28 PM
inho, the extra cost for 2 abilities is ok, because it reflects costs incurred due to added complexity; making them work together properly.
Title: Re: Unit cost mysteries (and a bug?)
Post by: BFG on February 05, 2013, 07:21:53 PM
inho, the extra cost for 2 abilities is ok, because it reflects costs incurred due to added complexity; making them work together properly.
Even when one of those abilities is Deep Radar (or another 0-cost ability)?
Title: Re: Unit cost mysteries (and a bug?)
Post by: gwillybj on February 05, 2013, 09:39:20 PM
Even for Deep Radar. Trance, too: sometimes it's free, depending on the combination. Notice there are times when Deep Radar is combined with Trance: they are both free! So I don't really mind the mixture of No-Cost, Low-Cost, and Regular-Cost.
Title: Re: Unit cost mysteries (and a bug?)
Post by: kyrub on February 05, 2013, 10:02:00 PM
Even for Deep Radar. Trance, too: sometimes it's free, depending on the combination. Notice there are times when Deep Radar is combined with Trance: they are both free! So I don't really mind the mixture of No-Cost, Low-Cost, and Regular-Cost.

Trance is free with Nerve Gas or Police, but with AAA, Clean reactor, High Morale or Fungicide Tanks, it costs extra. Comm Jammer is free with Nerve Gas as well, but even with High Morale or Clean Reactor (unlike Trance). It costs extra with AAA, Cloaked, Drop, Amphi. Deep radar is always free, unless used with Super formers (this combo is clearly complicated for radar to work well).

Trance and Ecm together are completely free (0% extra cost), but Trance + Trained costs 175%.

This is incredible mess. Alpha Centauri is a rational game, a game made with clear and universal rules. The current "unit cost" has no clarity at all, and it's most probably unintended by the designers.
Title: Re: Unit cost mysteries (and a bug?)
Post by: gwillybj on February 05, 2013, 10:22:06 PM
Okay, I think I didn't understand.
It isn't so much that one thing might cost more, normal, less, or free. It's the lack of consistency across-the-board in calculating those values when combinations are made. Is this a better understanding?
Title: Re: Unit cost mysteries (and a bug?)
Post by: ete on February 05, 2013, 10:35:39 PM
gwillybj: Yes, that's what makes us think it's a bug.
Title: Re: Unit cost mysteries (and a bug?)
Post by: Yitzi on February 05, 2013, 11:47:07 PM
The real question then is what proper functioning is: Clearly the +1 for two abilities was intended, the question is whether it was supposed to dis-apply for all free things and that got bugged, or was supposed to apply for all abilities and got bugged that way.  Based on how the bug works, I find the latter more likely, but I can code whatever the consensus says.  (If there's no clear consensus, I'll code it to apply the extra cost unless one of them is free, because that's in between what it does now and what the datalinks say.)
Title: Re: Unit cost mysteries (and a bug?)
Post by: kyrub on February 06, 2013, 01:03:09 AM
My final vote goes for +1 for all combined abilities, including the free ones.

Most intuitive solution, universal "combining any 2 abilities => needs more cost" logic. There will be fairly little change done to the game as well, ECM+Clean garrisons will cost more, Trance police as well, but that's it.
Title: Re: Unit cost mysteries (and a bug?)
Post by: ete on February 06, 2013, 01:12:59 AM
I'm for "combining two non-free abilities => needs more cost", having free abilities increase cost seems unintuitive to me. Letting them be thrown onto anything without being a problem seems positive.
Title: Re: Unit cost mysteries (and a bug?)
Post by: Earthmichael on February 06, 2013, 08:15:52 PM
I agree with ete.

I don't mind the extra for 2 abilities, BUT I would like to see that only apply if both abilities are not free.  If one ability is free, then I would rather it not count at all, so adding this ability remains zero cost, even if the unit already has one other ability.
Title: Re: Unit cost mysteries (and a bug?)
Post by: BFG on February 06, 2013, 09:16:17 PM
I could also see an argument for adding +0.5 cost for each non-free ability.  In other words, two freebies = 0 additional cost, one free and one costly = +0.5 additional cost, and two costly = +1 additional cost.  That seems like a decent compromise between the two opposing viewpoints here.
Title: Re: Unit cost mysteries (and a bug?)
Post by: Yitzi on February 06, 2013, 09:30:29 PM
I could also see an argument for adding +0.5 cost for each non-free ability.  In other words, two freebies = 0 additional cost, one free and one costly = +0.5 additional cost, and two costly = +1 additional cost.  That seems like a decent compromise between the two opposing viewpoints here.

It'd also be way too difficult to code; the game does not account for fractional costs.
Title: Re: Unit cost mysteries (and a bug?)
Post by: ete on February 06, 2013, 09:34:57 PM
The two viewpoints are "free abilities should always be free" and "two abilities should always add cost". Your suggestion is different from what was intended in the game, and would change the price of units with one ability which has cost, which no one wants.
Title: Re: Unit cost mysteries (and a bug?)
Post by: kyrub on February 07, 2013, 12:22:49 AM
Added poll.
Title: Re: Unit cost mysteries (and a bug?)
Post by: BFG on February 07, 2013, 05:08:11 AM
...and would change the price of (two-ability) units with one ability which has cost, which no one wants.
Well, I do...but it looks like I'm the only one  8)
Still, I can understand sticking to the original code only in this discussion.
Title: Re: Unit cost mysteries (and a bug?)
Post by: Earthmichael on February 07, 2013, 06:13:16 AM
If this is fixed (and I definitely think it is a bug fix), I hope that it is added to both  the scient and kyrub patches (and any other popular patches) so that we have consistency.

My case for free things remaining free (even if a new ability is added) is simply ease of player understanding.  If someone adds a cost ability as a second ability, most players may not notice if it if it costs a bit more than expected.  But if someone adds a free ability, and the cost suddenly jumps up, it appears to the player as a bug (even if it is supposed to work that way); after all, a zero cost addition should result in no change, duh!!!  Any not everyone is going to read this post to figure out why, especially if it makes the unit cost more than it did before the patch.  So they just think the patch introduced a bug, which is not what we want people to think.
Title: Re: Unit cost BUG (vote for solution, please)
Post by: Yitzi on February 12, 2013, 05:10:03 PM
So it seems to be a tie, so we'll go with free abilities staying free.
Title: Re: Unit cost BUG (vote for solution, please)
Post by: BFG on February 12, 2013, 06:36:11 PM
So it seems to be a tie, so we'll go with free abilities staying free.
As Earthmichael stated, that does seem to make the most intuitive sense.  Given that there were only 6 votes, though, it seems either there were few strong opinions on the topic, or few people who were interested (and understood) the discussion.
Title: Re: Unit cost BUG (vote for solution, please)
Post by: Yitzi on February 12, 2013, 08:55:52 PM
I am pleased to announce that I have finished coding the fix, and it will be included in the next patch version.
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 31 - 840KB. (show)
Queries used: 14.

[Show Queries]