Author Topic: SMACX Thinker Mod  (Read 13862 times)

0 Members and 1 Guest are viewing this topic.

Offline Induktio

Re: SMACX Thinker Mod
« Reply #120 on: November 23, 2018, 08:30:54 PM »
> Does AI build probe ships?

If the AIs have foils + probe team tech, they should also build probe foils randomly along with normal ships. So dunno why you might not be seeing any foils. They might develop slower on easier difficulty levels though. I don't think I've implemented any significant changes there.

> Another question about predefined units. On what condition AI builds disabled *Sea Formers and Sea Escape Pods?

Yeah, the meaning and order of the standard units is hardcoded. Those units are a fallback default type for the prototype picker if the factions don't have a custom prototype of that type even though they should have the tech. The code would behave weirdly if it's not able to produce the unit types it would have the techs for.

> Is it feasible to teach them to end turn in one tile with friendly defender, or as far from target as possible to cross in one turn (especially ships), or outside of enemy vision, or at least not adjacent to enemy if possible?

Sure it's feasible to rewrite some of the movement code and there's already some changes, but currently it doesn't directly affect unit types with the probe weapon. Remember that even if they stopped away from enemies now, the new attack code considers any tiles that can be reached by roads from the attackers current location in one turn (including the attack). Rovers are able to cover pretty large distances now. Any unit that has to end its turn next to enemy roads is now in *real* trouble, including other rovers.  Probe teams often have difficulty reaching their targets, sure, so they could probably use some improvements.

Offline PvtHudson

Re: SMACX Thinker Mod
« Reply #121 on: November 24, 2018, 11:22:28 AM »
Attached save crashes the game after pressing End Turn. Made entirely in Thinker-dev-20181120. Hope this will help to catch some bug. Satori custom faction is from http://alphacentauri2.info/index.php?action=downloads;sa=view;down=264.
Also looks like (at least Librarian) AI doesn't build any user-predefined units, i.e. beyond #UNITS line 23, despite having prerequisite tech.

Offline Induktio

Re: SMACX Thinker Mod
« Reply #122 on: November 25, 2018, 08:29:07 PM »
Hmm, that was quite a serious issue, but it should be now fixed in version 20181125. It should also properly build the user defined units listed in alphax.txt. It is now redundant to define probe foils in alphax.txt but it should cause no issues after this update. So basically you can continue playing that save game normally.

The code indeed crashed on a null pointer dereference, but the thing is, the source code included a check for this null value and it worked with optimizations disabled, but gcc decided to heuristically eliminate this check when using the -O2 switch! I actually had to check this from the emitted assembly code and the condition was really missing. I now have to override this behaviour with -fno-delete-null-pointer-checks.

Offline PvtHudson

Re: SMACX Thinker Mod
« Reply #123 on: November 27, 2018, 01:18:02 AM »
Such a quick fix, thanks a lot. Crash indeed gone, and AI is building user predefs. But so far no probe ships, neither predefined nor self-designed. Will see how it unfolds.

Offline DrazharLn

Re: SMACX Thinker Mod
« Reply #124 on: November 27, 2018, 07:03:17 AM »
Here's a quick port of the smac_in_smax files I wrote to the format thinker expects. labels.txt is just a copy of the base game's one.

Just extract this dir to your smac dir and set load_expansion = 0 in thinker.ini.

It differs from original smac_in_smax in that all SMAX features are disabled whereas the original release thru yitzi allowed and used selective enabling of some SMAX features (sealurks, landmarks).

Offline tnevolin

Re: SMACX Thinker Mod
« Reply #125 on: November 27, 2018, 11:57:52 PM »
Induktio,
By the way, did you see this mod? It seems to working on the same AI performance enhancement thing. Just FYI.
http://alphacentauri2.info/index.php?action=downloads;sa=view;down=260
Tim

Offline DrazharLn

Re: SMACX Thinker Mod
« Reply #126 on: November 28, 2018, 12:11:12 AM »
Re: combat mechanics, from an email chain with induktio but made public in case anyone has anything to add and for posterity.

There's no need to monte carlo it, the advantage is if you can find the right function you can let SMAC handle disengagement rules (including whether the unit can disengage due to surrounding units), different kinds of combat (e.g. artillery, naval), collateral damage, etc and you can just treat it as a black box. I suspect this is harder than one would like because of all the global state in SMAC, but maybe it's OK.

---

So from the manual and from some experiments done ages ago on apolyton[1][2], we can get a pretty accurate idea of what the real combat system is (SMAC combat system is very similar to Civ2, see [2]).

let ah, dh = attacker's health, defender's health.
let p = probability of attacker hitting in a single round (this seems to have a slight fudge factor on it in Civ2 and maybe also SMAC that benefits the stronger unit).

In post#5 in [1] they argue that the true probability of the attacker winning is the sum of the probability of hitting the defender dh times for all possible number of rounds that the attacker could survive for (they're using the probability mass function for the binomial for each round, except they subtract one from each operand in the combination, I don't know why they do that.).

let f(k, n, p) = probability of getting exactly k successes from n rounds with probability p of each success

(or mess with the combination like they do? I'd want to understand why).

Their formula in python:

probability of attacker winning = sum((f(dh, n, p) for n in range(dh, dh+ah-1))

In terms of efficiency, that's a linear time function if you make a lookup table for the factorials or n^2 if you don't, which is probably fast enough.

[1] also provides a constant time approximate formula.

---

I was going to plot the probabilities for a variety of initial healths for a range of strengths and see if I could fit a constant time model, but I haven't got around to it yet.

Any model you do use can also be tested against experimental data from SMAC in [3] and [2].

[1]: https://web.archive.org/web/20140905043718/http://apolyton.net/showthread.php/22856-Info-Combat-(GL)?s=
[2]: https://web.archive.org/web/20140907092936/http://apolyton.net/showthread.php/103023-Combat-results?s=
[3]: https://apolyton.net/forum/other-games/alpha-centauri/151230-combat-mechanics

Offline Induktio

Re: SMACX Thinker Mod
« Reply #127 on: November 28, 2018, 10:38:11 AM »
> Here's a quick port of the smac_in_smax files I wrote to the format thinker expects. labels.txt is just a copy of the base game's one.

Nice. I didn't check it yet myself but we could place this mod in a separate repo so it doesn't get lost in this thread. I'm also wondering whether I should supply a new alphax.txt with this mod, but anyway the recommended changes are visible in Details.md in the repo.

> By the way, did you see this mod? It seems to working on the same AI performance enhancement thing. Just FYI.

Yeah, but he made that using only binary patching. It's pretty hard to compare changes without source code. By developing Thinker using C++ we're basically unlimited in what kind of new algorithms the AI could use. Now that I also implemented the method where the patches can be applied dynamically at startup, it's pretty rare to even have to change the actual game binary.

> [1] also provides a constant time approximate formula.

Are you referring to this formula below? It's somewhat similar to what Thinker calculates now but "firepower" doesn't have the same meaning in this game as far as I know. There's only one value derived from A/D strength/modifiers that is used to scale the random numbers and determine winners in combat. I wouldn't make any assumptions the page is applicable to SMAC.

(click to show/hide)
« Last Edit: November 28, 2018, 10:56:06 AM by Induktio »

Offline DrazharLn

Re: SMACX Thinker Mod
« Reply #128 on: November 28, 2018, 01:13:06 PM »
Yes, that formula, but firepower is always 1 in SMAC. In [2] and [3] there's a discussion based on empirical data.

Also the description of the smac and civ2 combat systems is very similar: they're both multi-round you hit or I hit things.

Offline tnevolin

Re: SMACX Thinker Mod
« Reply #129 on: November 28, 2018, 02:32:48 PM »
they're using the probability mass function for the binomial for each round, except they subtract one from each operand in the combination, I don't know why they do that.

Because all possible chain of events should end up with loser to take the hit. So you put this last hit aside and everything else is a complete permutation.
For example, ah = 2, dh = 2. The probability the attacker winning the combat is p (last blow to defender) + sum of other combinations: 0 or 1 times attacker loses and 1 time defender loses.
Tim

Offline tnevolin

Re: SMACX Thinker Mod
« Reply #130 on: November 28, 2018, 02:35:43 PM »
> By the way, did you see this mod? It seems to working on the same AI performance enhancement thing. Just FYI.

Yeah, but he made that using only binary patching. It's pretty hard to compare changes without source code. By developing Thinker using C++ we're basically unlimited in what kind of new algorithms the AI could use. Now that I also implemented the method where the patches can be applied dynamically at startup, it's pretty rare to even have to change the actual game binary.

I didn't mean to integrate this patch blindly. Merely scan through a list of changes and think if you want any of them in yours.
Tim

Offline tnevolin

Re: SMACX Thinker Mod
« Reply #131 on: November 28, 2018, 02:41:51 PM »
Are you referring to this formula below? It's somewhat similar to what Thinker calculates now but "firepower" doesn't have the same meaning in this game as far as I know. There's only one value derived from A/D strength/modifiers that is used to scale the random numbers and determine winners in combat. I wouldn't make any assumptions the page is applicable to SMAC.

(click to show/hide)

Is this a formula SMAC uses to display odds? I understand it just multiplies round odds with both unit hit point proportion. That is incorrect combat odds due the fact it results in multi round binomial distribution which is not a direct multiple of hit points. In fact, stronger unit with smaller amount of hit points may have better combat chances even though the program displays the opposite.
:)

Anyway. Thank you for publishing it. It's a good information.
Tim

Offline Induktio

Re: SMACX Thinker Mod
« Reply #132 on: November 29, 2018, 11:07:25 PM »
Looks like the last big feature missing from the next release is doable after all, namely rewriting the AI social engineering. :)

I've had some really interesting results with the new SE code. The AI actually now considers all the possible society effects resulting from a SE change in an abstract manner, so it's able to understand the nonlinear effects of the different modifiers. For example +2 ECON +4 EFFIC is some of the combos it tries to achieve now. It is also able to understand pop booming and toggle growth modifiers based on that. It only considers the actual cumulative social effects, so it's not hardcoded to rely on any particular choice.

When doing some tests with the Technocrat Foundation custom faction, I noticed ROBUST modifier seems to be bugged in the game. It's supposed to cut some penalty modifiers by half, but sometimes it reduces BOTH the negative and positive modifiers by half. It seems really few custom factions make use of this modifier since it's so marginal, so I would suggest avoiding those. PENALTY modifier that only applies to one social model seems to be working okay though. Again, its use is probably really rare among the custom factions.

Offline tnevolin

Re: SMACX Thinker Mod
« Reply #133 on: November 29, 2018, 11:40:38 PM »
Interesting work.
By the way, were you able to determine original AI algorithm of SE model selection?
Tim

Offline DrazharLn

Re: SMACX Thinker Mod
« Reply #134 on: November 30, 2018, 03:15:46 PM »
they're using the probability mass function for the binomial for each round, except they subtract one from each operand in the combination, I don't know why they do that.

Because all possible chain of events should end up with loser to take the hit. So you put this last hit aside and everything else is a complete permutation.
For example, ah = 2, dh = 2. The probability the attacker winning the combat is p (last blow to defender) + sum of other combinations: 0 or 1 times attacker loses and 1 time defender loses.

Yes, that makes perfect sense :) Thanks.

 

* 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)
-=-
17 (6%)
XP Compatibility patch
-=-
8 (3%)
Gog version for Windows
-=-
69 (28%)
Scient (unofficial) patch
-=-
24 (9%)
Kyrub's latest patch
-=-
14 (5%)
Yitzi's latest patch
-=-
85 (34%)
AC for Mac
-=-
2 (0%)
AC for Linux
-=-
5 (2%)
Gog version for Mac
-=-
10 (4%)
No patch
-=-
12 (4%)
Total Members Voted: 246
AC2 Wiki Logo

* Random quote

That sunny dome! Those caves of ice! And all who heard should see them there, And all should cry, Beware! Beware! His flashing eyes, his floating hair! Weave a circle round him thrice, And close your eyes with holy dread, For he on honey-dew hath fed, And drunk the milk of Paradise.
~Samuel Taylor Coleridge, Datalinks

* Select your theme

*