Author Topic: SMACX Thinker Mod  (Read 168270 times)

0 Members and 5 Guests are viewing this topic.

Offline PvtHudson

Re: SMACX Thinker Mod
« Reply #105 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.
become one with all the people

Offline Induktio

Re: SMACX Thinker Mod
« Reply #106 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 #107 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.
become one with all the people

Offline DrazharLn

Re: SMACX Thinker Mod
« Reply #108 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).

Re: SMACX Thinker Mod
« Reply #109 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

Offline DrazharLn

Re: SMACX Thinker Mod
« Reply #110 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 #111 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 #112 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.

Re: SMACX Thinker Mod
« Reply #113 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.

Re: SMACX Thinker Mod
« Reply #114 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.

Re: SMACX Thinker Mod
« Reply #115 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.

Offline Induktio

Re: SMACX Thinker Mod
« Reply #116 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.

Re: SMACX Thinker Mod
« Reply #117 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?

Offline DrazharLn

Re: SMACX Thinker Mod
« Reply #118 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.

Offline Induktio

Re: SMACX Thinker Mod
« Reply #119 on: November 30, 2018, 10:11:56 PM »
New release version 0.8 is now available from downloads. Changes since the last release:

* New combat logic for land-based units attempts to do counter attacks more often
* New code for selecting social engineering priorities
* AI understands the value of fungus and will sometimes plant it
* AI sometimes builds native units when the psi bonuses are high enough
* Faction placement option added: avoid bad spawns on tiny islands and equalize distances to neighbors
* Landmark selection options added to config
* Experimental load_expansion option added
* Many other fixes and adjustments
* Scient patch updated to v2.0

This new social engineering AI is probably really significant in boosting the AI capabilities. It should be able to fairly reliably pop boom via SE if +4 growth is just attainable. It also takes into consideration the distance to any enemies and might decide to switch out of Free market (or any other model with -police) to avoid the pacifism penalty. I'm not sure yet if the switch happens too soon though. Tell us here your experiences with the new SE priorities.

 

* 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

I wake, I work, I sleep, I die, the dark of space my only sky. My life has passed, and all I have been will never touch the Earth again.
~The Ballad of Sky Farm 3, Anonymous, Datalinks

* 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: 39.

[Show Queries]