• Register

The near future: Trains are no longer controlled by humans. Instead, artificial intelligence is used to handle traffic. Program the best AI, beat challenges on various maps and watch it fight other AIs in live, online matches!

Forum Thread
  Posts  
Request: function call when waiting passenger spawns (Games : TrAInsported : Forum : Feature Requests : Request: function call when waiting passenger spawns) Locked
Thread Options
Apr 10 2013 Anchor

There is no way to discover if a passenger is waiting for pick up unless an empty passes by them. Can we have a function call like ai.spawnPassengers(passengers)? Then I can actually have a strategy for total cost effective pickup/dropoff.

I missed that this is already implemented. I now see that it is in one of your documentation links, but I found it via code.
I recommend having a 5th tutorial that covers this method and mentions the others that are not used in the tutorials.

(The signature is function ai.newPassenger(name, x, y, destX, destY, vipTime) for anyone who wants to know. But why not simply ai.newPassenger(passenger)?)

Apr 11 2013 Anchor

Hey,

You're right, that's the function you're looking for... there's also a function that tells you when a passenger is picked up by another player, so you delete him from your list of waiting passengers.

The parameters are like this for legacy reasons: I had this function there before I implemented the "passenger" table for the AI coding interface, and some AIs were already online and running, so I left it like this and just added new parameters to the end... Also, it takes a bit less time to compute the function call this way, otherwise I would need to make a new copy of the passenger for every AI which takes some time (not much, but hey).

The problem with a 5th tutorial is that if I only put this function in there, it might get pretty boring and theoretical.
If you have the time and want to, why not write a challenge map that gives the function names at the beginning as a hint? I could then include that map in the source... so it would act like a 5th tutorial, but wouldn't be so dry and boring?

Looking forward to seeing your AI online! :D

Edited by: Germanunkol

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.