[NoGo] CityDomination

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

LSky
Traffic Manager
Traffic Manager
Posts: 169
Joined: 25 Jun 2005 10:44
Location: The Netherlands
Contact:

Re: [NoGo] CityDomination

Post by LSky »

11Runner wrote:CityDomination v5 (also available on bananas)

New Improvements:

* Population related goals, measurments, and winners (thank you LSky)

* Brief bugfixes

Attached is english.txt if you would like to translate
You're my hero! Going to test this right away!

Edit;
First issue I noticed, if you build in a town that's close to another town, you dominate both of them right away.

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4554
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [NoGo] CityDomination

Post by Zuu »

swedish.txt in UTF-8
Attachments
swedish.txt
(1.21 KiB) Downloaded 93 times
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

mousepl
Engineer
Engineer
Posts: 5
Joined: 30 Nov 2010 20:48

Re: [NoGo] CityDomination

Post by mousepl »

OK. So i have CityDomination-5.tar in ~/openttd/game/ folder. No changes in cfg and still nothing...
openttd.cfg
configuration file
(9.75 KiB) Downloaded 99 times

11Runner
Engineer
Engineer
Posts: 92
Joined: 01 Sep 2011 19:23
Location: Oregon, USA

Re: [NoGo] CityDomination

Post by 11Runner »

Hmmmm... I seem to be stumped on this one. My game is validating your configuration and setting CityDomination as the mod. I have only been with OpenTTD since last October. You may want to ask one of the other devs about it.
Image

SynTrans - A Synaptic Networking AI for OpenTTD

Remi_Woler
Engineer
Engineer
Posts: 2
Joined: 04 Jan 2012 07:24

Re: [NoGo] CityDomination

Post by Remi_Woler »

Is there a reason why line 375 is commented-out? It looks like a vital call for the owner change to happen. With it commented-out (untouched download), owners never change. The AI Debug windows gives the following lines for loglevel 3:

Adding Station Drohall Airport
Adding Station Tonborough Airport
Adding Station Tonborough
Old Owner: Remi
New Owner: NiceCAB - v2.1.3
Winning Company: Remi

Since the town.owner never changes, oldowner == town.owner (assigned on line 372, asserted on line 377), so UpdateTownOwners(...) is never called (line 378).

Edit: Version 5
Edit2: Line 375 is unrelated, after digging some more. I now have the code in such a state that the AI can take over my towns, per the rules, only vice versa doesn't work yet. Trying some rewriting now, to get it less complex, and hopefully to actually work.

11Runner
Engineer
Engineer
Posts: 92
Joined: 01 Sep 2011 19:23
Location: Oregon, USA

Re: [NoGo] CityDomination

Post by 11Runner »

Since the town.owner never changes, oldowner == town.owner (assigned on line 372, asserted on line 377), so UpdateTownOwners(...) is never called (line 378).
Just to be clear (you probably already know this, but):

* The owner changes when a competing company becomes the technical "dominator" for at least the value specified in the "pending_days" GS option (you can turn this off by switching the option to 0)
* Line 375 was commented out because the code was outdated, but I wanted to keep it there so that I could revert back. I probobly should remove my comments before a release to minimize confusion.
* On line 374, the town will check itself for a new owner, and from there, it will call call ChangeOwner() if the town qualifies

If what I understand is correct, you are making an AI called NiceCAB, which you would like to make compatible with CityDomination. In any case I wish you luck :)
Image

SynTrans - A Synaptic Networking AI for OpenTTD

Remi_Woler
Engineer
Engineer
Posts: 2
Joined: 04 Jan 2012 07:24

Re: [NoGo] CityDomination

Post by Remi_Woler »

Actually, I'm not making an AI. It's an existing one. I just started it in the same map to see how the gamescript worked. It has absolutely no clue about the goals, but it will go for profit, so sooner or later it will start "dominating" a town (by accident).

I do realize that a new owner becomes pendingOwner first for 30 days (default), and only then takes over. However, that part of the code does have some issues. Right now, the AI company *is* able to take over "my" towns, however, I am not able to take over their towns. At best, I do become the pendingOwner, it gives me a pendingTime, but nothing happens after that. I could easily remain the owner for well over 30 days (seen 288 already with some extra logging), and still I don't become the new owner of the town. The following lines are shown, and when I add the score to the "Adding station" debug line, I see that I should have the town, or at least become the pendingOwner:

Adding Station Drohall Airport
Adding Station Tonborough Airport
Adding Station Tonborough
Old Owner: Remi
New Owner: NiceCAB - v2.1.3
Winning Company: Remi

Yet, I only very rarely become the pendingOwner, and I never become the real owner, even though it says I'm the winning company on every iteration of the GameLoop (I can wait years, and it still won't happen).

Also: if a company is merged, all towns get "no owner". Even if there is plenty of stations around it from the merge-into company. The town will stay with this "no owner" till a new AI starts (which has the same company name, but a different ID) and then the new AI gets *all* towns the old AI owned. This seems like a bug too.

I can't yet figure out why I am never considered for ownership. At first I thought maybe my companyid was 0 (0-based array is normal in programming) and maybe the const GSCompany.COMPANY_INVALID would have a value of 0 as well (so my company would always be considered as invalid), but I looked through the OpenTTD source and the const has a value of -1, so that isn't the issue either.

I am currently trying to refactor the script code to make it a lot more simple, which will hopefully either iron these bugs out, or at least tell what causes them. I'll post my version here when done. Edit: I started playing with cargodist/distpach, and don't need goals anymore to make the game enjoyable for more than an hour. Color me hooked :oops: Maybe I'll pick it up later, but don't count on it.
Last edited by Remi_Woler on 07 Feb 2012 18:26, edited 2 times in total.

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4554
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [NoGo] CityDomination

Post by Zuu »

CityDomination 5 don't seem to listen for the event that is sent from OpenTTD to your script when a company is merged. Maybe that is the problem of company merging?
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2367
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: [NoGo] CityDomination

Post by Lord Aro »

NiceCAB is just NoCAB with a 'peaceful' setting ;)
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra

mousepl
Engineer
Engineer
Posts: 5
Joined: 30 Nov 2010 20:48

Re: [NoGo] CityDomination

Post by mousepl »

mousepl wrote:OK. So i have CityDomination-5.tar in ~/openttd/game/ folder. No changes in cfg and still nothing...
openttd.cfg
Anyone have an idea how to solve this problem (run CityDomination on dedicated svr)?

Brumi
President
President
Posts: 905
Joined: 18 Jul 2009 17:54

Re: [NoGo] CityDomination

Post by Brumi »

Insert this section into your openttd.cfg:

Code: Select all

[game_scripts]
"City Domination" = 
Hopefully this works :)

akasoft
Engineer
Engineer
Posts: 120
Joined: 25 Aug 2011 11:48

Re: [NoGo] CityDomination

Post by akasoft »

Russian translation below, for v5.
russian.txt
(1.99 KiB) Downloaded 84 times

11Runner
Engineer
Engineer
Posts: 92
Joined: 01 Sep 2011 19:23
Location: Oregon, USA

Re: [NoGo] CityDomination

Post by 11Runner »

Thanks for the translations (Zuu and akasoft). They will be integrated into the next release
Image

SynTrans - A Synaptic Networking AI for OpenTTD

mousepl
Engineer
Engineer
Posts: 5
Joined: 30 Nov 2010 20:48

Re: [NoGo] CityDomination

Post by mousepl »

Brumi wrote:Insert this section into your openttd.cfg:

Code: Select all

[game_scripts]
"City Domination" = 
Hopefully this works :)
This section is in my openttd.cfg from a long time. You can check this by downloading my cfg file...

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4554
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [NoGo] CityDomination

Post by Zuu »

For version 3, 4 and 5 I believe that the correct long name is without a space. "CityDomination". In my GameScript list I also have "City Domination" with a space which says that it is version 2.

So my advice is to remove the space and try again.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

mousepl
Engineer
Engineer
Posts: 5
Joined: 30 Nov 2010 20:48

Re: [NoGo] CityDomination

Post by mousepl »

Zuu wrote:For version 3, 4 and 5 I believe that the correct long name is without a space. "CityDomination". In my GameScript list I also have "City Domination" with a space which says that it is version 2.

So my advice is to remove the space and try again.
Doesn't work with:

Code: Select all

CityDomination =
City Domination =
City_Domination =
Anybody tried run this script on svr?

User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13205
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Re: [NoGo] CityDomination

Post by Hyronymus »

mousepl wrote:
Zuu wrote:For version 3, 4 and 5 I believe that the correct long name is without a space. "CityDomination". In my GameScript list I also have "City Domination" with a space which says that it is version 2.

So my advice is to remove the space and try again.
Doesn't work with:

Code: Select all

CityDomination =
City Domination =
City_Domination =
Anybody tried run this script on svr?
You forgot double qoutes (").

Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: [NoGo] CityDomination

Post by Roujin »

I did a german translation. Hopefully no one beat me to it and sent it to you via pm or the likes. (was surprised to see no german translation yet, as usually a german translation tends to be posted rather quickly by someone)
Attachments
german.txt
(1.21 KiB) Downloaded 95 times
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage

11Runner
Engineer
Engineer
Posts: 92
Joined: 01 Sep 2011 19:23
Location: Oregon, USA

Re: [NoGo] CityDomination

Post by 11Runner »

Thanks Roujin for your German translation. It will be added to the upcoming release :D

I apologize for this next release taking so long. I am still testing the company merge support (which is most easily done on a server, but I need to update the trunk...).

Also, after this next release, I would like to make use of the new GSGoal.Question() function. My thought was to use CityDomination to ask the player whether or not to allow a contractor (or whatever to name the person) to build a route automatically as your company to a town the player is not connected to. This feature could be toggled off via the Game Script settings.

If you think you have a better idea, post it here before that release comes out :wink:
Image

SynTrans - A Synaptic Networking AI for OpenTTD

11Runner
Engineer
Engineer
Posts: 92
Joined: 01 Sep 2011 19:23
Location: Oregon, USA

Re: [NoGo] CityDomination

Post by 11Runner »

CityDomination v6 has been released!

Fixed: Company merging bug which did not convert the town to the new owner of the company
Added: translations (german and russian and swedish. No updates needed :wink: )

Planned improvements:

Feature: Measuring for all cargos
Feature: GSGoal.Question usage for something (hopefully) fun :D
Fix: Only measure the cargo if its actually being transported (if it is not transported, the station seems to automatically give a 100% rating :o )

GSGoal.Question() usage ideas are still welcome. Feel free to post your idea here if you would like to contribute :D

As always, the release is also available on bananas

EDIT:
Another Fix: No longer can you dominate to towns with one station alone (thanks LSky)
Attachments
CityDomination-6.tar
(60 KiB) Downloaded 100 times
english.txt
for translations
(1.13 KiB) Downloaded 94 times
Image

SynTrans - A Synaptic Networking AI for OpenTTD

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 3 guests