[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

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

[NoGo] CityDomination

Post by 11Runner » 22 Dec 2011 01:54

This is a game game script which deems people 'owner' of a town based on their station ratings. It is good for demonstrating:

1. SuperLib integration
2. Catching events
3. Placing Signs
4. Using Newsticker

Depends on:

SuperLib for NoGo(v19)

Please tell me if you have a suggestion.

Latest Download:

CityDomination v9

TIP: You can automatically get the latest version of CityDomination on the content download service

EDIT:
CityDomination no longer depends on Text, and added link to latest download
Attachments
CityDomination-1.tar
(40 KiB) Downloaded 436 times
Last edited by 11Runner on 15 Apr 2014 02:55, edited 4 times in total.
Image

SynTrans - A Synaptic Networking AI for OpenTTD

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

Re: [NoGo] CityDomination

Post by Zuu » 22 Dec 2011 09:04

11Runner wrote:Known Bug:
Signs build over themselves when replaced
Use Helper.SetSign(tile, "message", true) in SuperLib. It will look for existing signs on a tile and replace them with the new message. For AIs the case was that it would only see signs owned by its own company. For GS I would guess that it only see the GS/None-owned signs.
11Runner wrote:Text (v1)
I've marked this library obsolete on bananas as GSText now have the functionality that was provided by the library.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

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

Re: [NoGo] CityDomination

Post by 11Runner » 23 Dec 2011 20:56

CityDomination v2

New Release Improvements:

1. Goals per company added
Zuu wrote:
11Runner wrote:Known Bug:
Signs build over themselves when replaced
Use Helper.SetSign(tile, "message", true) in SuperLib. It will look for existing signs on a tile and replace them with the new message. For AIs the case was that it would only see signs owned by its own company. For GS I would guess that it only see the GS/None-owned signs.
11Runner wrote:Text (v1)
I've marked this library obsolete on bananas as GSText now have the functionality that was provided by the library.
2. Did Zuu's Improvements
3. Faster station checking
4. HQ now displays dominated towns
5. Creates news on who is doing the best, etc.
6. Towns grow with competition

Planned improvements:

1. Must dominate town for at least a month before it can be counted as your dominated town (so that the town doesn't switch who dominates so fast)

Also, I have included my english.txt. If you choose to translate, I will be greatful :D

CityDomination should also be available on bananas :wink:
Attachments
CityDomination-2.tar
(40 KiB) Downloaded 193 times
english.txt
For translating
(664 Bytes) Downloaded 268 times
Image

SynTrans - A Synaptic Networking AI for OpenTTD

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

Re: [NoGo] CityDomination

Post by Zuu » 23 Dec 2011 22:39

I fired up 2*CluelessPlus (in town-to-town only mode) and 2*Convoy to test this goal script. Here are some comments:
  • If an AI don't build a HQ (Convoy), you can't see how many towns it has dominated. I don't know if this is a problem or not, as I in general think that it is good that this script encourage you to build a HQ.
  • If you move the HQ, the old sign is not removed. If you take a look on my TransportGoals script (v2), you'll see that I actually use the API GSSign.BuildSign directly but store the sign id along with the other company specific data. This way I can remove the sign if the HQ has been moved without knowing the old location. (you could of course instead store the previous HQ location and just use Helper.SetSign(old_tile, "", true); to erase the old sign)
  • Your script crashes on load when I load a the game after having saved it. It looks like you are executing a DoCommand from inside your Load function. A solution is to just store the table with load data in your main class instance and then actually read and react on the data in the beginning of your Start() function. [you could again take a look on TransportGoals if you want inspiration]
  • I get a flood of news messages on a 256*512 game with four AIs.
  • The towns grow to large cities quite fast. In just 10 years I got about 20 towns with a size between 3000 and up to 9000 inhabitants. (no town house NewGRF) If this is good or bad is a question of what you want to do with your script. Perhaps there is some other ways to reward players that dominate a town than growing it? (as most towns will have a dominator/owner and thus grow)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

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

Re: [NoGo] CityDomination

Post by 11Runner » 24 Dec 2011 04:21

CityDomination v3

Thank you Zuu for your suggestions :D . My thoughts about them:
If an AI don't build a HQ (Convoy), you can't see how many towns it has dominated. I don't know if this is a problem or not, as I in general think that it is good that this script encourage you to build a HQ.
In some ways, I suppose it could be a problem. As of right now, there don't appear to be very many good ways to communicate with the user (I will be requesting such features later). Besides, if NoGo is intended for Multiplayer use, there will be less of a chance of having AI's with no ability to build an HQ.
If you move the HQ, the old sign is not removed. If you take a look on my TransportGoals script (v2), you'll see that I actually use the API GSSign.BuildSign directly but store the sign id along with the other company specific data. This way I can remove the sign if the HQ has been moved without knowing the old location. (you could of course instead store the previous HQ location and just use Helper.SetSign(old_tile, "", true); to erase the old sign)
That was fixed, thank you :)
Your script crashes on load when I load a the game after having saved it. It looks like you are executing a DoCommand from inside your Load function. A solution is to just store the table with load data in your main class instance and then actually read and react on the data in the beginning of your Start() function. [you could again take a look on TransportGoals if you want inspiration]
That was also fixed (And TransportGoals was my inspiration from the very start :D )
I get a flood of news messages on a 256*512 game with four AIs.
I was getting similar floods of messages too, but I was not sure how the community would react. As of now, I have limited some of the news messages to certain companies, depending on their relevance.
The towns grow to large cities quite fast. In just 10 years I got about 20 towns with a size between 3000 and up to 9000 inhabitants. (no town house NewGRF) If this is good or bad is a question of what you want to do with your script. Perhaps there is some other ways to reward players that dominate a town than growing it? (as most towns will have a dominator/owner and thus grow)
I am still considering such ideas. For right now, I have lowered the growth speed of towns.

An updated version of english.txt has been included if you would like to translate.
Attachments
CityDomination-3.tar
(40 KiB) Downloaded 160 times
english.txt
for translating
(726 Bytes) Downloaded 232 times
Image

SynTrans - A Synaptic Networking AI for OpenTTD

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

Re: [NoGo] CityDomination

Post by Zuu » 24 Dec 2011 10:53

Code: Select all

			// Right now we have to find the sign manually...
			local signlist = GSSignList();
			signlist.Valuate(GSSign.GetLocation);
			signlist.KeepValue(company.hq);
			GSSign.RemoveSign(signlist.Begin());
can be changed to

Code: Select all

Helper.SetSign(company.hq, "", true)
If you pass an empty string to SetSign, it will remove all signs from that tile.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

bokkie
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 19 Jan 2007 19:26

Re: [NoGo] CityDomination

Post by bokkie » 24 Dec 2011 12:50

11Runner wrote:CityDomination v3
The towns grow to large cities quite fast. In just 10 years I got about 20 towns with a size between 3000 and up to 9000 inhabitants. (no town house NewGRF) If this is good or bad is a question of what you want to do with your script. Perhaps there is some other ways to reward players that dominate a town than growing it? (as most towns will have a dominator/owner and thus grow)
I am still considering such ideas. For right now, I have lowered the growth speed of towns.
Maybe use some capture the flag system? As in, make a counter from x to 0 per company. If you dominate more cities than your opponent, your opponent loses points (depending on the number of towns). If someone reaches 0, he or she loses. Come to think of it, I think many game modes from other games now can directly be "copied" into OpenTTD :D

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

Re: [NoGo] CityDomination

Post by 11Runner » 24 Dec 2011 19:04

Maybe use some capture the flag system? As in, make a counter from x to 0 per company. If you dominate more cities than your opponent, your opponent loses points (depending on the number of towns). If someone reaches 0, he or she loses. Come to think of it, I think many game modes from other games now can directly be "copied" into OpenTTD
Unfortunately as of now, I do not know if it is possible to deem a player as "looser" well enough for it to impact the game or make players really care, and I dont think it would be very fair either. Every player should get another try :D ! However, your idea does make me think it possible to judge a winner every year based on the number of new towns a company has taken over. Hmmm... :)

Then again, I may not be understanding your idea clearly enough.
Image

SynTrans - A Synaptic Networking AI for OpenTTD

bokkie
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 19 Jan 2007 19:26

Re: [NoGo] CityDomination

Post by bokkie » 24 Dec 2011 21:45

Can't you give a dialog with 'Player x has won. Do you want to quit or keep playing?'.

To explain the system, I've googled for the game which I had in mind, which is Battlefield Vietnam. Source: http://www.gamespot.com/features/battle ... 19/?page=2
Each team starts out with a certain number of points (called 'tickets'). Whenever somebody on a team is killed, that team will lose one ticket. Whichever team runs out of tickets first loses the battle. Depending on which type of map you are playing on, having more control points in your team's possession will also cause the enemy's tickets to drain slowly away, even without them dying.
Remove the killing of course, and substitute control points with dominated cities.

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

Re: [NoGo] CityDomination

Post by Hyronymus » 24 Dec 2011 21:59

Just some thinking out loud: can this really neat looking script make building transport related objects more expensive for companies that aren't the dominating transport company? Or even cooler: force competing transport companies to buy transportation rights?

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

Re: [NoGo] CityDomination

Post by 11Runner » 26 Dec 2011 02:54

Thanks for all of the suggestions!
Can't you give a dialog with 'Player x has won. Do you want to quit or keep playing?'.
As far as I know, the best ways to communicate with the user is only news message or signs. There does not appear to be support (yet) for such a dialog, nor could I force a user out of buisness (you can double check the nogo docs: http://nogo.openttd.org/)
Can't you give a dialog with 'Player x has won. Do you want to quit or keep playing?'.

To explain the system, I've googled for the game which I had in mind, which is Battlefield Vietnam. Source: http://www.gamespot.com/features/battle ... 19/?page=2

Quote:
Each team starts out with a certain number of points (called 'tickets'). Whenever somebody on a team is killed, that team will lose one ticket. Whichever team runs out of tickets first loses the battle. Depending on which type of map you are playing on, having more control points in your team's possession will also cause the enemy's tickets to drain slowly away, even without them dying.


Remove the killing of course, and substitute control points with dominated cities.
I think the idea in itself is very good! I might modify it a bit (for example, each user starts with a set of towns, and if you loose all of them, you go out of business or similar. I don't think that there is a way to make a company bankrupt in the current API...). I will proboably try to implement that (possibly as a GS Option) in the future :)
Just some thinking out loud: can this really neat looking script make building transport related objects more expensive for companies that aren't the dominating transport company? Or even cooler: force competing transport companies to buy transportation rights?
I wish! I dont think NoGo supports that either... Forcing exclusive transport rights upon the company is possible, but it would make it much harder for competing companies to have better station ratings. I have been thinking of a way to make the dominator of a town have a greater (or lesser) advantage locally in the town.

I have been considering quoting comments like this and placing them on the NoGo thread as suggestions for new features! :wink:
Image

SynTrans - A Synaptic Networking AI for OpenTTD

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

Re: [NoGo] CityDomination

Post by Zuu » 26 Dec 2011 08:15

Kogut contributed a function to SuperLib.Money that will use up all money of the current company. It's called succide or similar. If you use GSCompanyMode around the call to that function you can probably use it, with the assumption that using GSCompanyMode affects how CURRENT_COMPANY is resolved.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: [NoGo] CityDomination

Post by Kogut » 26 Dec 2011 17:45

I am not sure but really large company may earn money faster than it is possible to spend.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD

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

Re: [NoGo] CityDomination

Post by 11Runner » 27 Dec 2011 01:11

CityDomination v4:

This is really more like a mini release!

Improvements:

* Fixed Crash on company out of buisness

* Added month delay to confirm "worthiness" for a town domination

english.txt is included for translating if you would like to do so :D
Attachments
CityDomination-4.tar
(40 KiB) Downloaded 143 times
english.txt
for translating
(726 Bytes) Downloaded 197 times
Image

SynTrans - A Synaptic Networking AI for OpenTTD

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

Re: [NoGo] CityDomination

Post by LSky » 27 Dec 2011 10:48

Perhaps a possible goal could be trying to achieve a set (though adjustable beforehand obviously) amount of people that is calculated by adding the populations of towns a company dominates?

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

Re: [NoGo] CityDomination

Post by 11Runner » 27 Dec 2011 19:50

LSky wrote:Perhaps a possible goal could be trying to achieve a set (though adjustable beforehand obviously) amount of people that is calculated by adding the populations of towns a company dominates?
That sounds like a feasable (and cool) idea. The program might even be able to determine the yearly winner based on that factor rather than number of towns dominated :) I will look into putting this into our next release :D
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 » 29 Dec 2011 19:36

How can I add this script to dedicated server? I've tried to add this script to cfg:

Code: Select all

[game_scripts]
CityDomination =
Next i've copyied .tar file to ~/openttd/content_download/game/ and it's doesn't work. On singleplayer game everything is fine.

Yexo
Tycoon
Tycoon
Posts: 3653
Joined: 20 Dec 2007 12:49

Re: [NoGo] CityDomination

Post by Yexo » 29 Dec 2011 22:30

mousepl wrote:How can I add this script to dedicated server? I've tried to add this script to cfg:

Code: Select all

[game_scripts]
CityDomination =
Next i've copyied .tar file to ~/openttd/content_download/game/ and it's doesn't work. On singleplayer game everything is fine.
Did you also copy the SuperLib and Text libraries to the proper directories? If you manually install it, you should copy it to ~/.openttd/game/ (and ~/.openttd/game/library/ respectively).

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

Re: [NoGo] CityDomination

Post by 11Runner » 29 Dec 2011 22:38

Yexo wrote:mousepl wrote:
How can I add this script to dedicated server? I've tried to add this script to cfg:
Code:
[game_scripts]
CityDomination =


Next i've copyied .tar file to ~/openttd/content_download/game/ and it's doesn't work. On singleplayer game everything is fine.

Did you also copy the SuperLib and Text libraries to the proper directories? If you manually install it, you should copy it to ~/.openttd/game/ (and ~/.openttd/game/library/ respectively).
Yexo is right, but the Text library is no longer needed (it is now depracated)

My thoughts if that is not the problem (some of this may be a bit obvious and simple, but it could be the problem):

* Ensure your server is running the OpenTTD trunk or test release of 1.2

* Ensure you are running CityDomination v4 (older versions used a different name which may confuse the configuration)

Otherwise you may want to give me your openttd.cfg

Finally, this is not likely to be an issue, but scripts downloaded or placed manually should be placed in $OPENTTD_ROOT/game, not $OPENTTD_ROOT/content_download/game. You may have to create the directory manually.
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 » 30 Dec 2011 01:54

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

EDIT:

The population goals and measurments are a settable option in the gamescript settings dialog. You must edit the setting before starting the game. It is turned on by default
Attachments
CityDomination-5.tar
(50 KiB) Downloaded 199 times
english.txt
for translating
(1.13 KiB) Downloaded 261 times
Last edited by 11Runner on 30 Dec 2011 06:42, edited 1 time in total.
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