News:

Simutrans Forum Archive
A complete record of the old Simutrans Forum.

Wanted: New AIs

Started by prissi, November 19, 2008, 10:45:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

prissi

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_passengers.cc and ai_goods.cc). Soon there will be also a chance to assingn slot to different AIs (i.e. have two passenger AIs compete.) If you feel like trying, please do so!

z9999

Quote from: prissi on November 19, 2008, 10:45:15 PM
Soon there will be also a chance to assingn slot to different AIs (i.e. have two passenger AIs compete.)

Is it possible to select trucks only or freight trains only or both of them for each slot ?

prissi

Soon, the saving and the slot assignment need debugging but works already for me. Just not yet comitted.

the almighty snark

Maby try and allow the AI to pick the cheapest route? Or the fastest route, so there will be a certain competition?

prissi

The current AI builts the best route it can do. YOu need a better AI to have such a setting.

TimWintle

#5
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"

prissi

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!

prissi

oAI selection system now incorporated. YOu can now let several passenger AI compete (not that is does make sense, but) ...

TimWintle

QuoteoAI selection system now incorporated.

How do you register a new AI with the game? I can't see where you say your subclass of ai_t is available for selecting in-game.

prissi

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).

z9999

Back to my old question.

Quote from: z9999 on November 20, 2008, 06:06:01 AM
Is it possible to select trucks only or freight trains only or both of them for each slot ?
Quote from: prissi on November 20, 2008, 10:14:38 AM
Soon, the saving and the slot assignment 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 ?

prissi

This is planned, together with password and naming of companies.

sojo

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?
"English is a easy language. But not for me." ;) sojo

follow simutrans_de on Twitter
- A home for Simutrans (in german)

Dwachs

Here is a small patch such that the passenger ai can deal with carriages / kutschen. Starting more than one passenger ai will now lead to traffic jams even as early as 1870  ;D
Parsley, sage, rosemary, and maggikraut.

Dwachs

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"?
Parsley, sage, rosemary, and maggikraut.

z9999

#15
Quote from: Dwachs on February 09, 2009, 07:58:41 AM
Imho this looks like cheating.

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.

prissi

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 ... )

Dwachs

Ok, I was not aware of these vehicle constraints :) At least for pak.german, the passenger 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
Parsley, sage, rosemary, and maggikraut.

jamespetts

It would make sense generally if the AI had as few penalties/bonuses compared to human players as possible.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Spike

Quote from: Dwachs on February 09, 2009, 07:58:41 AM
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 assume the answer is yes.

TimWintle

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  :)


viktorht

#21
I want to help on this. Where can i start from? And somebody could help me on this, because I am a c++ beginner.

prissi

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_passenger.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.

Dwachs

To get familiar with simutrans play it :) Then try to change things you dont like/find uncomfortable/find are missing etc.
Parsley, sage, rosemary, and maggikraut.