• 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  
access trains (Games : TrAInsported : Forum : General AI questions : access trains) Locked
Thread Options
Apr 24 2013 Anchor

Hi,

is there any interface to access the current details of my own trains?

e.g. get the current position/direction?

If not: Do trains move at a constant speed (time per tile), so i could calculate the current position by time and last position? (or maybe some other hint)

thanks for this nice "game"

i'm looking forward to finishing my first competetive ai.

Apr 25 2013 Anchor

Trains does have .x and .y as current position and .dir as direction.
But you only get the train object when its delievered by the function.
Trains can be blocked and then they do not move.

Apr 25 2013 Anchor

Trains also slow down when picking up and dropping off passengers. So you can't calculate the exact position.

However, every time the train Object is passed to one of your function, you can get it's .x and .y value to see where you're currently at.

To see what values an object has, try this code (for the trAIn objetct):

function ai.chooseDirection( train, dirs )
	for k, v in pairs(train) do -- iterates through all the key, value pairs in the table "train"
		print(k, v)
	end
end

I think this is explained somewhere in the depths of tutorial three.

Edited by: Germanunkol

Apr 25 2013 Anchor

thanks for answers

guess have to estimate the exact position between relevant calls then...

btw. slowdown on drop / pickup ain't a problem as i get the exact position right at this event

i'm just trying to calc the "passenger value" for each train on newPassenger, so i can decide witch train might change it's way

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.