[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: 170
Joined: 25 Jun 2005 10:44
Location: The Netherlands

Re: [NoGo] CityDomination

Post by LSky »

Question and/or feature suggestion.

Is it possible for the game to be restarted through a script? As in, once a goal is reached (or a number of goals, which opens up so much more possibilities by the way) all the players get messages on who the winner is and the game/map restarts itself for people (who get reconnected automatically, in the ideal situation) to start over again?
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [NoGo] CityDomination

Post by Zuu »

Scripts can't control servers to restart. But they can send messages to the Admin port. So a game script in combination with a server admin program, can do that.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: [NoGo] CityDomination

Post by frosch »

FS#5035 reported a problem. The GoalTown constructor does always passes 0 as TownID, so the GUI always scrolls to the same town.

Code: Select all

-		if(id == null) this.id = GSGoal.New(company, GSText(GSText.STR_GOAL_TOWN, town), GSGoal.GT_TOWN, 0);
+		if(id == null) this.id = GSGoal.New(company, GSText(GSText.STR_GOAL_TOWN, town), GSGoal.GT_TOWN, town);
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
11Runner
Engineer
Engineer
Posts: 92
Joined: 01 Sep 2011 19:23
Location: Oregon, USA

Re: [NoGo] CityDomination

Post by 11Runner »

FS#5035 reported a problem. The GoalTown constructor does always passes 0 as TownID, so the GUI always scrolls to the same town.
Thanks for the report. I will get this fixed this weekend. I am not familiar what "FS#5035" is...

EDIT:

Found the flyspray bug :)
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 »

Here is the tiny bugfix release for the goals issue. Any bug reports still welcome. No changes in english.txt if you would like to be a translator :D
Attachments
CityDomination-7.tar
(52 KiB) Downloaded 228 times
Image

SynTrans - A Synaptic Networking AI for OpenTTD
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: [NoGo] CityDomination

Post by 3iff »

Possibly a bug.

Began a small game that started with 2 towns. Although I got goals to dominate both towns, I didn't get the population target and I was completely unable to get ownership of either town. I guess the script needs a minimum of 3 towns to function?

Restarted and got a game with 3 towns. Got ownership immediately and a target of 5000 pop to dominate.
11Runner
Engineer
Engineer
Posts: 92
Joined: 01 Sep 2011 19:23
Location: Oregon, USA

Re: [NoGo] CityDomination

Post by 11Runner »

Possibly a bug.

Began a small game that started with 2 towns. Although I got goals to dominate both towns, I didn't get the population target and I was completely unable to get ownership of either town. I guess the script needs a minimum of 3 towns to function?

Restarted and got a game with 3 towns. Got ownership immediately and a target of 5000 pop to dominate.
Did you have a competitor in the game? Did the total population of the 2 towns exceed the amount of the goal?
Image

SynTrans - A Synaptic Networking AI for OpenTTD
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: [NoGo] CityDomination

Post by 3iff »

I was playing solo. I don't think the total population was high enough.

Another oddity from trying it again last night. A 256*256 game with 9 towns, solo play. I dominated all the towns except the last one. In my current 'goals' list I have to dominate this one town (where I can't get ownership at all) and two others where I'm already in control.

Something else that's bugging me...town growth for all towns is every 257 days regardless of whether I have a presence there or not. It does make trying to grow the towns much more difficult. My current game has a pop of 9,500 dominated with a target of 15,000 and I can't get the towns to grow. The only city I have is 3,500, lots of stations with trains and buses plus a goods supply but still only grows every 257 days.

Does this script NEED an opponent or two to make it function correctly?

Other than these small problems it is quite enjoyable...although I should have built a coal line or two first as a few passenger routes can't make enough money...

Using version 7 but the script complains that this version is older than the saved version which it isn't. (I think the version check hasn't been amended but that's a minor point).
11Runner
Engineer
Engineer
Posts: 92
Joined: 01 Sep 2011 19:23
Location: Oregon, USA

Re: [NoGo] CityDomination

Post by 11Runner »

I was playing solo. I don't think the total population was high enough.
OK, thanks for confirming :)
Another oddity from trying it again last night. A 256*256 game with 9 towns, solo play. I dominated all the towns except the last one. In my current 'goals' list I have to dominate this one town (where I can't get ownership at all) and two others where I'm already in control.
Did you make sure that you dominated the town for a full period of 3 months? The reason for the 3 month requirement is to make sure you have a solid domination of the town, if you know what I mean
Something else that's bugging me...town growth for all towns is every 257 days regardless of whether I have a presence there or not. It does make trying to grow the towns much more difficult. My current game has a pop of 9,500 dominated with a target of 15,000 and I can't get the towns to grow. The only city I have is 3,500, lots of stations with trains and buses plus a goods supply but still only grows every 257 days.
You are correct. I will fix that bug over the weekend. Thanks for your report :D
Does this script NEED an opponent or two to make it function correctly?
It is recommended that you have competitors, mainly because this script is designed for multiplayer gameplay primarily, however, it should still operate correctly in single player as well.
Using version 7 but the script complains that this version is older than the saved version which it isn't. (I think the version check hasn't been amended but that's a minor point).
Thanks, thats another bug which I will fix soon (hopefully this weekend) :)
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 »

New Release! CityDomination v8:

* Added complete cargo support

* Fixed all of 3iff's previously reported bugs

* Fixed a bug where building a station and not using it gives you perfect station ratings, which is not fair :wink:

As usual, CityDomination is also available on bananas.
Attachments
CityDomination-8.tar
(60 KiB) Downloaded 211 times
Image

SynTrans - A Synaptic Networking AI for OpenTTD
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: [NoGo] CityDomination

Post by 3iff »

Did you make sure that you dominated the town for a full period of 3 months? The reason for the 3 month requirement is to make sure you have a solid domination of the town, if you know what I mean
I was delivering stuff for 6 months or more yet couldn't get any ownership.

I'll give the new version a thorough test and report back if there are issues.
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: [NoGo] CityDomination

Post by 3iff »

Oops, managed to break it again...

Solo game, 5 towns. I got the initial goal of dominating 3 towns...and meanwhile, I dominated the other 2 towns in advance. That seems to have confused the script a bit.

So, once the TOTAL population reached 5000, I got the next target (15000) even though the HQ sign shows my domination population for the original 3 towns (excluding Mentstoke and St Nandean). Seems I'm not being credited with dominating those 2 towns for the HQ sign but I am getting credit for the overall population target. I also didn't get a message confirmation for getting those other 2 towns as they weren't on the goal list when I got them.

I have the savegame if you need it...and it's newgrf-free to make things easier.

(edit) Looks like the script has reset the dominated towns for the new goal of 15000. It now counts all 5 towns with the combined population total reporting correctly in the HQ sign.
Attachments
Testing, 23rd Oct 1951.png
Testing, 23rd Oct 1951.png (72.89 KiB) Viewed 7314 times
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: [NoGo] CityDomination

Post by 3iff »

Started a game with 4 computer players. Ran ok for a while but then it seemed to stop updating. I saved and quit then reloaded the game...the script crashed.

Savegame available if needed.
Attachments
Testing with AI, 30th Aug 1952.png
Testing with AI, 30th Aug 1952.png (35.12 KiB) Viewed 7302 times
11Runner
Engineer
Engineer
Posts: 92
Joined: 01 Sep 2011 19:23
Location: Oregon, USA

Re: [NoGo] CityDomination

Post by 11Runner »

Solo game, 5 towns. I got the initial goal of dominating 3 towns...and meanwhile, I dominated the other 2 towns in advance. That seems to have confused the script a bit.

So, once the TOTAL population reached 5000, I got the next target (15000) even though the HQ sign shows my domination population for the original 3 towns (excluding Mentstoke and St Nandean). Seems I'm not being credited with dominating those 2 towns for the HQ sign but I am getting credit for the overall population target. I also didn't get a message confirmation for getting those other 2 towns as they weren't on the goal list when I got them.

I have the savegame if you need it...and it's newgrf-free to make things easier.
A save file would be nice please :) (just so I can know which towns you dominated and figure out what happened)
Started a game with 4 computer players. Ran ok for a while but then it seemed to stop updating. I saved and quit then reloaded the game...the script crashed.

Savegame available if needed.
The crash I will fix promptly as well, although I would like the save file for this one too
Image

SynTrans - A Synaptic Networking AI for OpenTTD
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: [NoGo] CityDomination

Post by 3iff »

Saves enclosed. The crash one might have involved a crashing AI...I'm not sure. Anyway, the game continued eventually (after another save/restart).

I also learned about what constitutes dominating a town...it's transporting all cargo in its zone...not just passengers.

Hope these files help...

One thing, the original target is 5000 then it jumps to 15000...is this correct?
Attachments
Testing, 23rd Oct 1951.sav
(27.54 KiB) Downloaded 208 times
Testing with AI, 30th Aug 1952.sav
(38.71 KiB) Downloaded 217 times
11Runner
Engineer
Engineer
Posts: 92
Joined: 01 Sep 2011 19:23
Location: Oregon, USA

Re: [NoGo] CityDomination

Post by 11Runner »

I also learned about what constitutes dominating a town...it's transporting all cargo in its zone...not just passengers.
Actually, its the cargo ratings for each station are added up, and whoever has the highest station ratings dominates (actually, I wanted to determine it by how much cargo is transported by each individual company, but that was not available on the API, so I decided the station ratings were the closest).
One thing, the original target is 5000 then it jumps to 15000...is this correct?
No, it is not. I think that I will add a new parameter which changes how far the population jumps with each new goal :)

And thanks for the saves :wink:
Image

SynTrans - A Synaptic Networking AI for OpenTTD
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: [NoGo] CityDomination

Post by 3iff »

Actually, its the cargo ratings for each station are added up, and whoever has the highest station ratings dominates (actually, I wanted to determine it by how much cargo is transported by each individual company, but that was not available on the API, so I decided the station ratings were the closest).
Would it not be better to average the rating over the number of stations? Otherwise, a company could spam lots of stations getting 50% rating (say 10 @ 50% for 500) which would beat 4 stations at 100% but the 4 would surely be better than the 10. Alternatively, take the best 10 stations from each player in a town and total those. That at least gives a cutoff point to stop spamming dozens of stations and would make players focus on making some stations highly effective.

It might also help (if possible) to display the domination rating in the owner sign...something like...

Owner: 75% Jones Transport.

Then players would know how dominant an owner was.
CrazySquirrel
Engineer
Engineer
Posts: 3
Joined: 03 Apr 2012 20:58

Re: [NoGo] CityDomination

Post by CrazySquirrel »

Appears that player built towns can't be owned.
11Runner
Engineer
Engineer
Posts: 92
Joined: 01 Sep 2011 19:23
Location: Oregon, USA

Re: [NoGo] CityDomination

Post by 11Runner »

Would it not be better to average the rating over the number of stations? Otherwise, a company could spam lots of stations getting 50% rating (say 10 @ 50% for 500) which would beat 4 stations at 100% but the 4 would surely be better than the 10. Alternatively, take the best 10 stations from each player in a town and total those. That at least gives a cutoff point to stop spamming dozens of stations and would make players focus on making some stations highly effective.
I considered that, and to counter that, I ensured that the script will check to see if the station is actually transporting any cargo before counting it. This makes it much more difficult for a user to "spam the town, because he/she must actually continually use the stations in order for them to be counted. I also decided that more stations should transport more cargo typically than averaging all the stations, or else the user could just have 1 good station and win from that, even though another player could be transporting more cargo.

The cutoff I may consider, but for right now let me focus on other things ;)
Appears that player built towns can't be owned.
I think you are right! I will work on that too.

EDIT: One more question...

What is the owner rating you were talking about above the HQ 3iff?
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 »

OK here we go... CityDomination v9:

* Added new AI option to control step size of population goals

* Fixed gamesave bug reported by 3iff

* Fixed CrazySquirrel's bug where player built towns are not added to the processed towns list

As usual, available on bananas
Solo game, 5 towns. I got the initial goal of dominating 3 towns...and meanwhile, I dominated the other 2 towns in advance. That seems to have confused the script a bit.
I was unable to figure this one out... are you sure it wasnt a feature somehow? It takes 3 months after dominating the town for the goal to complete, in case you didnt know :wink:
Attachments
CityDomination-9.tar
(60 KiB) Downloaded 355 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: thesasgeek and 9 guests