Ai assistant?

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

Post Reply
ThunderAI
Transport Coordinator
Transport Coordinator
Posts: 306
Joined: 26 Nov 2003 09:15

Ai assistant?

Post by ThunderAI »

Would it be possible to program an AI that works on your team?

For example, I want to build buses, trains, and planes, then let my AI assistant route them and set them up efficiently as I move on to the next inferstructure design.

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

Re: Ai assistant?

Post by Zuu »

In single player that would be possible without any modifications to OpenTTD. At the beginning of the game, use cheats to switch to the same company as your AI and then you build your stuf and place a sign to communicate with your AI.

In multiplayer that is not possible as you can't cheat in multiplayer.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
el koeno
Route Supervisor
Route Supervisor
Posts: 454
Joined: 24 Sep 2004 15:47

Re: Ai assistant?

Post by el koeno »

If infrastructure sharing and perhaps cargodist ever hit trunk, something might be possible: an AI managed subsidiary of your company that manages inner city road transport, while you focus on inter-city rail and air transport. If the AI sees one of your railway station with an attached bus stop that doesn´t actually have buses serving it, it might proceed to build and manage bus routes from that station for you. That might really save you some work.

If you could hand vehicles or infrastructure to other companies you might even hand over a train, and the AI will manage, it: clone or upgrade it, if it sees the need. Things can get complex there though: what if you want to add an extra station to a route? There would have to be a way to retake control of the vehicle.
ThunderAI
Transport Coordinator
Transport Coordinator
Posts: 306
Joined: 26 Nov 2003 09:15

Re: Ai assistant?

Post by ThunderAI »

Zuu wrote:In single player that would be possible without any modifications to OpenTTD. At the beginning of the game, use cheats to switch to the same company as your AI and then you build your stuf and place a sign to communicate with your AI.

In multiplayer that is not possible as you can't cheat in multiplayer.
Can you point me to a place where I can learn about "place a sign to communicate with your AI". Thanks.
ThunderAI
Transport Coordinator
Transport Coordinator
Posts: 306
Joined: 26 Nov 2003 09:15

Re: Ai assistant?

Post by ThunderAI »

el koeno wrote:If infrastructure sharing and perhaps cargodist ever hit trunk, something might be possible: an AI managed subsidiary of your company that manages inner city road transport, while you focus on inter-city rail and air transport. If the AI sees one of your railway station with an attached bus stop that doesn´t actually have buses serving it, it might proceed to build and manage bus routes from that station for you. That might really save you some work.

If you could hand vehicles or infrastructure to other companies you might even hand over a train, and the AI will manage, it: clone or upgrade it, if it sees the need. Things can get complex there though: what if you want to add an extra station to a route? There would have to be a way to retake control of the vehicle.
You understand my request very well. I'd imgien there would be more than one AI in your compnay. Serveal programmed just for routine actions that are trival in sandbox. For example, I forsee an advisor for each mode of transportation.

If I build some bus stations and setup some routes, the road advisor would balance them every so often, make upgrades to the buses if new vehicles come out (like the auto-update), retime and perhaps elimate buses because of that. In general I'd like to build a structure and move on to the next project and not ever think of the buses again (unless something major needs to be done). I'm mixed on if the AI should auto add new bus stations in (and probably shouldn't because I think that could be abused).

The same for airports, the advisor would reallocate flight times, perhaps destinations to make the route structure work as the cities grow.
Blustuff
Engineer
Engineer
Posts: 112
Joined: 21 Aug 2008 09:37
Location: France

Re: Ai assistant?

Post by Blustuff »

If existing AI could be used to assist you, this is not their purpose. Assisting a player is sometimes easier and sometimes harder. It is easier as you can let the player choose the global strategy and do only easy things that can obviously enhance profits. It is harder as you have to handle everything the player can do.

If someone wanted to write an assisting AI, he wouldn't probably do the same as if wanted to write a complete AI.
ThunderAI
Transport Coordinator
Transport Coordinator
Posts: 306
Joined: 26 Nov 2003 09:15

Re: Ai assistant?

Post by ThunderAI »

Blustuff wrote:If someone wanted to write an assisting AI, he wouldn't probably do the same as if wanted to write a complete AI.
Having read just the basics of making an AI, and not knowing OoP at all I am hard pressed to say if it would be easier or harder, but I do agree that it would be different in some ways. Probably the easist way to explain it would be that the scope would be much smaller.

Take PAXLink for example, it is designed (or was) with no brain at all. remove any of the desire to expand and just manage what exisits and you would have a good assistant.

You could have different levels of thought behind the AI, and unlock more advanced procedures as you the company expand and meet certian scores or goals. Like the how the trading AI works in X.

If you are limited to one AI by internal mechaniusm, you would need one Ai with many faces or facets that still is limited in scope.

In this case, I can dream up how I think such a system should work, but am powerless to implement it. Which is why I would like to know if there was anything from preventing it from working before I attmepted to make a simple Bus manager.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: Ai assistant?

Post by Kogut »

No, AI can do the same things as player (except timetables), so you can write ai managing routes constructed by player - just like normal ai but without building functions.
For beginning you can prepare ai replacing crashed vehicles.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
ThunderAI
Transport Coordinator
Transport Coordinator
Posts: 306
Joined: 26 Nov 2003 09:15

Re: Ai assistant?

Post by ThunderAI »

Kogut wrote:No, AI can do the same things as player (except timetables), so you can write ai managing routes constructed by player - just like normal ai but without building functions.
For beginning you can prepare ai replacing crashed vehicles.
intereting, that would be helpful.the thing with that though is, wouldn't the Ai have to check often because don't crashed objects get removed from game after some time?
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Ai assistant?

Post by planetmaker »

ThunderAI wrote: intereting, that would be helpful.the thing with that though is, wouldn't the Ai have to check often because don't crashed objects get removed from game after some time?
It would just have to respond to the crash message which it gets similar as a player gets it. Modern AI use that already to some degree in order to detect mean players trying to run over their trucks by evilly placed rails.
ThunderAI
Transport Coordinator
Transport Coordinator
Posts: 306
Joined: 26 Nov 2003 09:15

Re: Ai assistant?

Post by ThunderAI »

planetmaker wrote:
ThunderAI wrote: intereting, that would be helpful.the thing with that though is, wouldn't the Ai have to check often because don't crashed objects get removed from game after some time?
It would just have to respond to the crash message which it gets similar as a player gets it. Modern AI use that already to some degree in order to detect mean players trying to run over their trucks by evilly placed rails.
Could the AI replace the vehicles and then send a message to the "client" saying it did it, and where the crash occured?

I aske because if the player in on the computers team would the player even get those messages?
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: Ai assistant?

Post by Kogut »

AI can place sign or print output to ai debug console.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Ai assistant?

Post by Bilbo »

Well, I thought some time ago about patch that would allow to run some asistive AI under your company (thus both you and the AI will be in control), but I never got to any working implementation.

Few thoughts:
- you need some way to comunicate with AI (like tell it to build rail from X to Y), so you need code in the AI to export some function as callbacks (build_rail(tile,tile), build_road(tile,tile) along with description of the function and its parameters), then some GUI that will let you pick between these functions (You have selected "build railway segment". Pick starting and ending tile) and invoke them. Then you need to slightly modify the base AI code so it will be able to run "as you". This should then work even in multiplayer, probably....
- the AI API have some limitations, for example AI can't "see" opponents vehicles, stations, etc ... thus AI's does not have all the powers the humans have, though it is quite close
- It may somewhat spoil the game if you take the assistive powers too far, though there are already some patches designed to help you do the tedious stuff faster (my console commands patch, copy&paste patch, ...) - there are some complaints from few people that they make the game too easy, but more people are happy with these extra functions and use them :)
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Ai assistant?

Post by Zuu »

ThunderAI wrote:
Zuu wrote:In single player that would be possible without any modifications to OpenTTD. At the beginning of the game, use cheats to switch to the same company as your AI and then you build your stuf and place a sign to communicate with your AI.

In multiplayer that is not possible as you can't cheat in multiplayer.
Can you point me to a place where I can learn about "place a sign to communicate with your AI". Thanks.
Using an AISignList, an AI can get a list of all signs that it has. It will only see it's own signs, no other signs. That is why you need to use cheats to play as the same company as the AI. When you and the AI is at the same company, the AI can from time to time go through all signs it has and see if any of them contain a pre-defined message. On the same way the AI can place signs eg. near the HQ for the player to read.

If you don't want to miss any messages you could make the AI prefix all signs with an unusual character that you search for using my sign list patch. Another option is to make use of the AIDebug window and make it pause the game when an important message comes up.


If you want to see some code, checkout my Helper::BreakPoint, Helper::HasSign and Helper::SetSign functions in SuperLib: http://noai.openttd.org/svn/lib-super/helper.nut
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: Ai assistant?

Post by Dustin »

I have played as the same company as my AI a lot. However, I am usually the helper to the AI and not the other way round. :)

I think a helper AI could be a very neat project and fun to play with. I would love a function that would build double two way tracks between signs and signal them, for example. It would also be really nice to have an AI helper that would build a little something-something for every town early on to keep them all happy.

-D
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 7 guests