Poll

Combining of 2 special abilities for a unit costs extra 25% in SMACX. There is an incosistency, a bug: the "free cost" abilities (like Deep Radar or Trance and ECM) are sometimes free even in combination, sometimes not. How should it be solved?

Combining 2 abilities should always raise the price of the unit.
3 (33.3%)
A "cost free" ability should never raise the price, even when combined with another ability.
6 (66.7%)
...another solution (explain in thread)
0 (0%)

Total Members Voted: 9

Author Topic: Unit cost BUG (vote for solution, please)  (Read 6610 times)

0 Members and 1 Guest are viewing this topic.

Offline kyrub

Unit cost BUG (vote for solution, please)
« 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,

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?
« Last Edit: February 12, 2013, 12:52:11 PM by kyrub »

Offline kyrub

Re: Unit cost mysteries (and a bug?)
« Reply #1 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.

Offline BFG

Re: Unit cost mysteries (and a bug?)
« Reply #2 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

Offline Yitzi

Re: Unit cost mysteries (and a bug?)
« Reply #3 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)?

Offline ete

Re: Unit cost mysteries (and a bug?)
« Reply #4 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.

Offline kyrub

Re: Unit cost mysteries (and a bug?)
« Reply #5 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

Offline Yitzi

Re: Unit cost mysteries (and a bug?)
« Reply #6 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.)


Offline BFG

Re: Unit cost mysteries (and a bug?)
« Reply #8 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.

Offline kyrub

Re: Unit cost mysteries (and a bug?)
« Reply #9 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.

Offline BFG

Re: Unit cost mysteries (and a bug?)
« Reply #10 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.
« Last Edit: February 05, 2013, 02:24:00 AM by BFG »

Offline Yitzi

Re: Unit cost mysteries (and a bug?)
« Reply #11 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.

Offline gwillybj

Re: Unit cost mysteries (and a bug?)
« Reply #12 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.
Two possibilities exist: Either we are alone in the Universe or we are not. Both are equally terrifying. ― Arthur C. Clarke
I am on a mission to see how much coffee it takes to actually achieve time travel. :wave:

Offline BFG

Re: Unit cost mysteries (and a bug?)
« Reply #13 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)?

Offline gwillybj

Re: Unit cost mysteries (and a bug?)
« Reply #14 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.
Two possibilities exist: Either we are alone in the Universe or we are not. Both are equally terrifying. ― Arthur C. Clarke
I am on a mission to see how much coffee it takes to actually achieve time travel. :wave:

 

* User

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Select language:

* Community poll

SMAC v.4 SMAX v.2 (or previous versions)
-=-
24 (7%)
XP Compatibility patch
-=-
9 (2%)
Gog version for Windows
-=-
103 (32%)
Scient (unofficial) patch
-=-
40 (12%)
Kyrub's latest patch
-=-
14 (4%)
Yitzi's latest patch
-=-
89 (28%)
AC for Mac
-=-
3 (0%)
AC for Linux
-=-
6 (1%)
Gog version for Mac
-=-
10 (3%)
No patch
-=-
16 (5%)
Total Members Voted: 314
AC2 Wiki Logo
-click pic for wik-

* Random quote

You are the children of a dead planet, earthdeirdre, and this death we do not comprehend. We shall take you in, but may we ask this question?will we too catch the planetdeath disease?
~Lady Deirdre Skye 'Conversations With Planet'

* Select your theme

*
Templates: 5: index (default), PortaMx/Mainindex (default), PortaMx/Frames (default), Display (default), GenericControls (default).
Sub templates: 8: init, html_above, body_above, portamx_above, main, portamx_below, body_below, html_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 45 - 1228KB. (show)
Queries used: 42.

[Show Queries]