The International Simutrans Forum

 

Author Topic: AI upgrade  (Read 2794 times)

0 Members and 1 Guest are viewing this topic.

Offline Tomas

  • *
  • Posts: 251
AI upgrade
« on: October 22, 2008, 07:10:46 PM »
Hi,
 recent AI is weak. I have idea how improve it:
Here is some basic attributes:
0) at the beginning of the game go through the list of available goods and sort it descending from best. Then, in the factories producing the best possible goods began to build.
1) every month, would took place checking "accounting" and according to the results would then respond.
2) I have a profit or loss?
 2.1) I have a profit - I have enough money to the next line?
   2.1.1) Yes - building line
   2.1.2) No, wait for the next month
  2.2) I have lost - why? Check the profitability of individual vehicle combinations.
3) if it is a combination of loss, find out why:
  3.1) my opponent takes the majority of goods? Deploy faster machines and increase the carrying capacity. If not next month to cancel lene and start elsewhere.
  3.1) a small production of goods? To reduce the carrying capacity. ''
  3.2) subscriber overcrowding? Why?
   3.2.1) Local performance customers? - Reduce the carrying capacity. ''
   3.2.2) The customer has no other outlet? - Build the line on sales.
   3.2.3) is missing more raw material for the production? - Build the line.

PS: sorry for english - it is automatically translated  :)

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9411
  • Languages: De,EN,JP
Re: AI upgrade
« Reply #1 on: October 22, 2008, 07:23:41 PM »
Actually the good AI is nearly optimal in its selection of factories, concerning the fact it does single lines and no network.

And of course it would be very easy to make the AI stronger. Just build the entire chain in the first day and wait for victory. But the waiting is in there for the human, that he/she do not find the AI "cheating" unfair; for the same reason the AI does not always select the best vehicle, as it would be boring very fast.

You can have a look at simplay.cc. It is quite well documented. By the way, you can only steal good from another opponent, if their station is overflowing or you offer a more direct route. Since the AI always offer direct routed (and tries to built exactly the amount of cars the factory can satisfy per month), there is little optimisation left.

Other than this: Vehicle micromanagement (do I have to much or is this just a line which has a long line in-between or do I block my own vehicles) is not quite forward is even the simple apporach now takes a lot of lines of code.

I would like to offer something like OpenTTD scriptable AI (it is in my todo-list for ages, since 2005 or so) but I am still worrying about the amount of work needed for this. So far, you better write your own AI, using the two examples provided in simplay.cc.

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: AI upgrade
« Reply #2 on: October 24, 2008, 05:59:11 AM »
I recently tested AI for about 2 weeks to make my own AI, and I thought most important things are accurate estimate for revenue and earnings, and making complete chain.

In most cases, convoys are too many.
Usually, amount of production are limited by the end consumer's amount of production. It is small, but they don't care about it.
And some goods consumption are limited by factor, for example cement is 23%, but they don't care about it.
As a result, they work 1 month and sleep 2 months. So, they can't pay maintenance of track, station and overhead power.
AI don't estimate maintenance costs of overhead power and station.

Another problem is AI can't make complete chain. This problem often happens.
They always try to make shortest route, so they always test the same tile to make stop. (Shortest route is not so important. Because they don't get mony from factory to factory, but from stop to stop.)
And also they check the tile only the length of station, so they don't know they can connect each stations.
As a result they often cause to fail to make route, and make complete chain.

This is the start of the death march.
If there are no money about 6 months, they remove route.
Remove route needs many money, sometimes causes bankrupt.
If the route are shared by other route, they can't find a route and are self destructed.
Self destructing don't remove stops and line, other player can't make the same route.

Passenger AI is the same, they can't make new route when they don't have cash.
So, they repeat sell bus and buy bus, and go bankrupt.
But good passenger AI is very difficult, it is like a gamble.



I think AI bankrupt is not fun.
« Last Edit: October 24, 2008, 06:10:45 AM by z9999 »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9411
  • Languages: De,EN,JP
Re: AI upgrade
« Reply #3 on: October 24, 2008, 08:10:44 AM »
Well, I would embrace any improvement submitted as patch or, maybe even as additional AI to add variety. Maybe there should a basic AI with some helper functions in an own directory. This should be not very difficult and can be a first step to easily making own AIs.

The passenger AI could be much better, by deciding beforehand on a plane for building a network and start lines, which are expected to be high traffic, as railway lines.

The most difficult things for any AI is (hard to believe) indeed the slection of a suitable station place.

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: AI upgrade
« Reply #4 on: October 25, 2008, 11:22:47 AM »
I think so, too. This is difficult but is most important thing.
After 2 weeks trying, I gave up at this point.  :)