The International Simutrans Forum

 

Author Topic: Wanted: New AIs  (Read 17344 times)

0 Members and 1 Guest are viewing this topic.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10622
  • Languages: De,EN,JP
Wanted: New AIs
« 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_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!

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: Wanted: New AIs
« Reply #1 on: November 20, 2008, 06:06:01 AM »
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 ?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10622
  • Languages: De,EN,JP
Re: Wanted: New AIs
« Reply #2 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.

Re: Wanted: New AIs
« Reply #3 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?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10622
  • Languages: De,EN,JP
Re: Wanted: New AIs
« Reply #4 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.

Offline TimWintle

  • *
  • Posts: 16
Re: Wanted: New AIs
« Reply #5 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"
« Last Edit: December 06, 2008, 11:44:03 PM by TimWintle »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10622
  • Languages: De,EN,JP
Re: Wanted: New AIs
« Reply #6 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!

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10622
  • Languages: De,EN,JP
Re: Wanted: New AIs
« Reply #7 on: December 12, 2008, 10:38:27 PM »
oAI selection system now incorporated. YOu can now let several passenger AI compete (not that is does make sense, but) ...

Offline TimWintle

  • *
  • Posts: 16
Re: Wanted: New AIs
« Reply #8 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 subclass of ai_t is available for selecting in-game.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10622
  • Languages: De,EN,JP
Re: Wanted: New AIs
« Reply #9 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).

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: Wanted: New AIs
« Reply #10 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 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 ?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10622
  • Languages: De,EN,JP
Re: Wanted: New AIs
« Reply #11 on: December 19, 2008, 04:01:27 PM »
This is planned, together with password and naming of companies.

Offline sojo

  • Devotees (Inactive)
  • *
  • Posts: 851
  • Maintainer pak96.comic
    • German home of Simutrans
Re: Wanted: New AIs
« Reply #12 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?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4869
  • Languages: EN, DE, AT
Re: Wanted: New AIs
« Reply #13 on: February 08, 2009, 07:32:43 PM »
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

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4869
  • Languages: EN, DE, AT
Re: Wanted: New AIs
« Reply #14 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"?

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: Wanted: New AIs
« Reply #15 on: February 09, 2009, 09:50:15 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.
« Last Edit: February 09, 2009, 10:01:15 AM by z9999 »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10622
  • Languages: De,EN,JP
Re: Wanted: New AIs
« Reply #16 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 ... )

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4869
  • Languages: EN, DE, AT
Re: Wanted: New AIs
« Reply #17 on: February 09, 2009, 10:54:30 AM »
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

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20762
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Wanted: New AIs
« Reply #18 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.

Offline Spike

  • *
  • Posts: 1361
  • First Simutrans Developer and Graphics Artist
Re: Wanted: New AIs
« Reply #19 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 assume the answer is yes.

Offline TimWintle

  • *
  • Posts: 16
Re: Wanted: New AIs
« Reply #20 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  :)


viktorht

  • Guest
Re: Wanted: New AIs
« Reply #21 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.
« Last Edit: January 01, 2010, 02:55:25 AM by IgorTekton »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10622
  • Languages: De,EN,JP
Re: Wanted: New AIs
« Reply #22 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_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.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4869
  • Languages: EN, DE, AT
Re: Wanted: New AIs
« Reply #23 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.