The International Simutrans Forum

Development => Patches & Projects => Topic started by: prissi on November 19, 2008, 10:45:15 pm

Title: Wanted: New AIs
Post by: prissi on November 19, 2008, 10:45:15 pm
Since the AIs are now more or less complete in seperated files, I would like to include more AIs than the two standard ones. (ai_p****engers.cc and ai_goods.cc). Soon there will be also a chance to ****ingn slot to different AIs (i.e. have two p****enger AIs compete.) If you feel like trying, please do so!
Title: Re: Wanted: New AIs
Post by: z9999 on November 20, 2008, 06:06:01 am
Soon there will be also a chance to ****ingn slot to different AIs (i.e. have two p****enger AIs compete.)

Is it possible to select trucks only or freight trains only or both of them for each slot ?
Title: Re: Wanted: New AIs
Post by: prissi on November 20, 2008, 10:14:38 am
Soon, the saving and the slot ****ignment need debugging but works already for me. Just not yet comitted.
Title: Re: Wanted: New AIs
Post by: the almighty snark on November 26, 2008, 07:39:16 pm
Maby try and allow the AI to pick the cheapest route? Or the fastest route, so there will be a certain competition?
Title: Re: Wanted: New AIs
Post by: prissi on November 27, 2008, 09:31:54 pm
The current AI builts the best route it can do. YOu need a better AI to have such a setting.
Title: Re: Wanted: New AIs
Post by: TimWintle on December 06, 2008, 11:34:14 pm
No code to show, but I thought I'd mention what I've tried to avoid duplicate effort...

(I haven't ever written C++ beyond basics, and that was a long time ago, and my german isn't great, so I stuck to modifying the ai_goods.cc code, rather than starting from scratch)

I tried making the  decision over whether to build road or rail connections between towns based on the expected time to make a return on investment (ROI) - i.e. to choose whichever would make the money back the fastest.

That didn't work - it performed slightly worse than the existing method when I tested it (the existing method is based on which would make the most profit per month)

Then I decided to only use the ROI method for connections that would use a large percentage of the cash that the player has, to avoid going bankrupt.

That seems to work ok - but I'm not sure if it's better than the original. The players don't go bankrupt as quickly as they sometimes do with the current code, but they are more likely to at some point. I'm going to try playing around some more if I have any time - perhaps it's just a case of "you've got to spend money to make money"?

Edit: decided to share my patch after all if anyone is interested (or has comments about coding style/me not understanding something), there's not much there but it took a while to understand how the code works ( both C++ and simutrans ). Patch is taken direct from the file with "svn diff ai_goods.cc"
Title: Re: Wanted: New AIs
Post by: prissi on December 07, 2008, 07:16:35 pm
Well I started C++ with Simutrans, as Hajo did too. So do not fear and fell free to ask all kind of questions. It is good to know, that smebody works on a AI again!
Title: Re: Wanted: New AIs
Post by: prissi on December 12, 2008, 10:38:27 pm
oAI selection system now incorporated. YOu can now let several p****enger AI compete (not that is does make sense, but) ...
Title: Re: Wanted: New AIs
Post by: TimWintle on December 13, 2008, 05:15:16 pm
Quote
oAI selection system now incorporated.

How do you register a new AI with the game? I can't see where you say your subcl**** of ai_t is available for selecting in-game.
Title: Re: Wanted: New AIs
Post by: prissi on December 13, 2008, 08:50:26 pm
You have to change simplay.h, define a proper return value for your AI and add a name to player_frame.cc (see next revision).
Title: Re: Wanted: New AIs
Post by: z9999 on December 18, 2008, 10:17:55 pm
Back to my old question.

Is it possible to select trucks only or freight trains only or both of them for each slot ?
Soon, the saving and the slot ****ignment need debugging but works already for me. Just not yet comitted.

Currently, I can't select trucks only or freight trains only or both of them for each slot.
Is there an another patch for this ?
Title: Re: Wanted: New AIs
Post by: prissi on December 19, 2008, 04:01:27 pm
This is planned, together with p****word and naming of companies.
Title: Re: Wanted: New AIs
Post by: sojo on January 25, 2009, 08:32:45 pm
Works anybody on this projekt?

I think a lot of patches were made. But the AI is not really inteligent. That can be better.

Wants anyone to improve this?
Title: Re: Wanted: New AIs
Post by: Dwachs on February 08, 2009, 07:32:43 pm
Here is a small patch such that the p****enger ai can deal with carriages / kutschen. Starting more than one p****enger ai will now lead to traffic jams even as early as 1870  ;D
Title: Re: Wanted: New AIs
Post by: Dwachs on February 09, 2009, 07:58:41 am
In the current implementation the ai's are allowed to create vehicles everywhere they want. That is, they do not need to build them in a depot. Imho this looks like cheating. Is it wanted to change this to a more strict "build only in depots"?
Title: Re: Wanted: New AIs
Post by: z9999 on February 09, 2009, 09:50:15 am

Indeed. But they also have big penalty.
They must pay the cost of raise(lower) lands and cost of building stops and ways, even if they failed to connect their root.

And if they failed to connect their root, they must pat the cost of removing ways, too.
Title: Re: Wanted: New AIs
Post by: prissi on February 09, 2009, 10:46:35 am
The patch is not really complete, as the check for pulling engines needs to meet constraits. To have a general AI the constraits must be checked too.

As for depots (then of course for everything) just go ahead. But then you should of course try to use as few depots as possible. (Also the AI could start their convois and then removing the depot. WOuld be cheaper on the long run anyway ... )
Title: Re: Wanted: New AIs
Post by: Dwachs on February 09, 2009, 10:54:30 am
Ok, I was not aware of these vehicle constraints :) At least for pak.german, the p****enger AI's play with carriages.

And it would be even cheaper (for the goods AI) to sell the vehicles after unloading and buy a new one instead :D
Title: Re: Wanted: New AIs
Post by: jamespetts on February 09, 2009, 11:31:45 am
It would make sense generally if the AI had as few penalties/bonuses compared to human players as possible.
Title: Re: Wanted: New AIs
Post by: Spike on February 09, 2009, 03:26:57 pm
Is it wanted to change this to a more strict "build only in depots"?

This was requested fairly frequently in my old forum, so I ****ume the answer is yes.
Title: Re: Wanted: New AIs
Post by: TimWintle on February 22, 2009, 05:26:00 pm
Haven't had time to look at this since my very basic patch (start of December), but I just wanted to thank prissi for the translations.

Only a few changes, but they have made the code far more readable for me  :)

Title: Re: Wanted: New AIs
Post by: viktorht on January 01, 2010, 12:53:07 am
I want to help on this. Where can i start from? And somebody could help me on this, because I am a c++ beginner.
Title: Re: Wanted: New AIs
Post by: prissi on January 01, 2010, 02:54:21 pm
You can give it a try; if you are only new to C++ you could look into the folder "trunk/player", look at the code and ask for stuff you do not understand. The ai_goods.cc and ai_p****enger.cc are the respective code for the AIs.

If you are new to programming, then better search something less complex for the start than simutrans.
Title: Re: Wanted: New AIs
Post by: Dwachs on January 01, 2010, 03:01:00 pm
To get familiar with simutrans play it :) Then try to change things you dont like/find uncomfortable/find are missing etc.