Event to give AI Companies access to a territory?

Tips and Tricks on Events, Economy, etc.
User avatar
Just Crazy Jim
Dispatcher
Posts: 413
Joined: Fri Oct 14, 2016 9:57 pm
Location: Coal Fields of WV

Event to give AI Companies access to a territory? Unread post

Hrm... I've tried several methods and none seem to work. I thought I had it figured out. Apparently not.

So how do I write an event that "when a company is started" "if AI company" then "set Territory access=True".

I've tried several ways, even tried "ignore territories on start" for AI, but nothing seems to actually give the AI companies free access to Canada on the Go West map.

It would be ever so lovely if this stuff were intuitively designed :D

What should I be testing against? AI company, AI player, or Territory?
"We have no patience with other people's vanity because it is offensive to our own."
-- François de La Rochefoucauld. Réflexions ou sentences et maximes morales. 1665.
User avatar
RulerofRails
CEO
Posts: 2061
Joined: Sun Dec 08, 2013 1:26 am

Re: Event to give AI Companies access to a territory? Unread post

Well, the documentation on the editor isn't complete. There's no way of knowing how the map creator may make use the many possibilities available so a guide will tend to be influenced by the author's logical process and what seems most "natural" to him.

The conditions used determine what the effects can be applied to. You need a dual test against both Territories and Companies.

Event I might use: (checking when a company is started)

Conditions from drop-down menu:
Force Test Against Companies and Force Test Against Territories. (located right at the top of the list).

Specify test against "AI companies only" and the exact Territory that you want to allow access in.


Effects:
Territory Allow All = TRUE.

The default application of effects "to the company \ territory for which the condition is TRUE" is correct


Notes:
I recommend not adding other effects to this event. I had some trouble with that once. I'm not sure which events would qualify for this specific joint company-territory application in the first place. If someone knows, please speak up.

Condition could also be ALWAYS TRUE without testing against players, but then you can't add other tests for a variable check, etc. etc. {Use your imagination} )
User avatar
Just Crazy Jim
Dispatcher
Posts: 413
Joined: Fri Oct 14, 2016 9:57 pm
Location: Coal Fields of WV

Re: Event to give AI Companies access to a territory? Unread post

Brilliant as ever, RoR. Your detailed instructions worked a charm. Much thanks! !$th_u$!

Now, all I have to do is figure out how to make Canada look attractive to the AI. Needs more trees I guess :D

But, seriously, I think the AI chooses a city pair before it forms a corporation. Or maybe it chooses the worst possible place to lay rails. Either could be true based on what I'm seeing. Even when they have lovely flat ground, you see tracks that are sort of wavy.
"We have no patience with other people's vanity because it is offensive to our own."
-- François de La Rochefoucauld. Réflexions ou sentences et maximes morales. 1665.
User avatar
Gumboots
CEO
Posts: 4813
Joined: Mon Aug 13, 2012 4:32 am
Location: Australia

Re: Event to give AI Companies access to a territory? Unread post

The AI tends to follow the grid squares. If a straight line can be laid between two cities, a human will do that. The AI often won't, or at least not unless the direct path follows the map grid. It's just one of many AI bugs in the game.

And sometimes they will choose two good cities to start with. Other times they're completely hopeless. There doesn't appear to be any rhyme or reason to it. You just have to accept that there is hardly any intelligence in the AI. It's basically Artificial Idiocy. *!*!*!

Oh yeah, the other things is they won't put bends in their track when they really should. If there is a mountain in the middle of a plain and it happens to be on the path the AI tells itself it should follow, they will just lay track straight up and over the mountain even when they could have avoided it completely with a slight detour.

Then they'll put their maintenance facilities halfway up the steepest grade, thus ensuring massive clustered attempts at reproduction. Which stops stuff being delivered. Which the AI concludes must be because it doesn't have enough trains on the run, so it will buy more of them, which compounds the problem. :mrgreen:
Grandma Ruth
CEO
Posts: 1237
Joined: Mon Nov 13, 2006 7:17 am
Location: West Yorkshire, England
Contact:

Re: Event to give AI Companies access to a territory? Unread post

{,0,} {,0,} {,0,} @RulerofRails
Thank you so much - couldn't figure out how to allow access at all!
zzc
Watchman
Posts: 65
Joined: Sat May 23, 2020 9:17 pm

Re: Event to give AI Companies access to a territory? Unread post

Test against all territory should allow the AI access anywhere.
User avatar
RulerofRails
CEO
Posts: 2061
Joined: Sun Dec 08, 2013 1:26 am

Re: Event to give AI Companies access to a territory? Unread post

Grandma Ruth, glad the info is helpful. :salute:

zzc is right, you can do it to all territories in one event.

Multiple territories is possible using a test against all territories condition, again make sure to Force Test Against Companies.
- by Territory ID
either using a range of Territory IDs
or combining several ID tests using "OR" (such conditions only combine properly if placed at the start of the event list, before Force Test Against Companies)

- by Territory Variable
(If there is a reason to group territories more than once you can setup Territory variables via ID, for further tests you can then test the variable.)
Reserve one of the territory variables for this use (at least till company setup is complete), For example Territory Variable 3 in all territories.
Setup so that one group of territories has TV3 = 1, another TV3 = 2, etc..
Then test TV3 = 2 to open the second group.

If you want some suggestions on other logic, I'm happy to oblige. :-D


Side-note about the AI's bad builds.
Over time I did have some ideas. Disclaimer: these methods haven't been properly tested.

A simple one would be to block the reserved-for-track cells in the direction that leads to a bad build with some hand-placed houses or other buildings. My theory is that the AI follows the reserved cell path when exiting/leaving cities. If it is forced to exit in a different direction, perhaps it makes a different connection or builds somewhere else. There is a risk he will just sit there useless.

A more advanced idea would be to forbid him in certain cities by pre-placing stations in some cities while in editor/build mode. To then just turn around a doze them under. The AI will not build in cities "already connected." This idea involves using a hex editor to reset the station names. Gumboots worked out how to reset the station naming while revamping the Latvia map. Details should be somewhere in that thread. The side-effect is that the haulage bonus/decay over time will no longer function, that could be a positive or negative depending on when you "build" your stations. This idea can probably be simplified: in a hex editor just change a byte or two for certain cities. It needs to be properly tested to be sure.
Post Reply