Page 1 of 1

train speed

Posted: 19 May 2010 15:41
by Bus
I've been looking at the source code to figure out how fast are vehicles (trains) in the game actually moving. The wiki says that a train moving at 100mph travels 5.6 tile per day. In source codes I found this:

1. Train::UpdateSpeed in train_cmp.cpp says that a train can travel 3/4 cur_speed every tick.
2. TrainLocoHandler in train_cmp.cpp advances the train one pixel for each 192 accumulated speed (assuming the train is moving parallel to the gridlines).
3. TileVirtXY in map_func.h suggests that one tile is 16 pixels wide.

Now assuming there are 74 ticks in one day, a train travelling at speed 160 (which corresponds to 100mph right?) should move (74*3/4*160)/192/16 = 2.89 tiles per day. Could anyone point out what part(s) of this calculation is(are) wrong?

Re: train speed

Posted: 19 May 2010 18:32
by Eddi
afair, trains move twice every tick, not sure how that affects your calculation, though.

Re: train speed

Posted: 19 May 2010 18:43
by andythenorth
To find out how fast they are *actually* moving I would count the number of pixels they travel per second. Because they are usually moving diagonally, you may need some help from our friend pythagoras :twisted:

</unhelpful coments>

Re: train speed

Posted: 19 May 2010 18:58
by Bus
Aha! Thanks Eddi. So does that mean that the train would move 5.78 tiles / day? Why does wiki mention 5.6?

Re: train speed

Posted: 19 May 2010 23:33
by PikkaBird
andythenorth wrote:To find out how fast they are *actually* moving I would count the number of pixels they travel per second. Because they are usually moving diagonally, you may need some help from our friend pythagoras :twisted:

</unhelpful coments>
Except classical geometry doesn't really work in TTD land. TTD's squares are actually circles. :)

Re: train speed

Posted: 25 May 2010 20:42
by Lordmwa
*brain explodes*

Re: train speed

Posted: 11 Jun 2010 04:54
by audigex
Squares don't look like squares in OTTD, you have to use diamonds instead.

If we need a diamond, we usually just tape a bunch of triangles together.

Re: train speed

Posted: 12 Jun 2010 01:12
by PikkaBird
audigex wrote:Squares don't look like squares in OTTD, you have to use diamonds instead.

If we need a diamond, we usually just tape a bunch of triangles together.
They're not squares or diamonds. :P

Check out how many regular-length train vehicles fit on a tile in each of the 4 orientations...

Re: train speed

Posted: 14 Jun 2010 23:05
by audigex
haha I know - but I refused to miss an opportunity to paraphrase a simpsons quote.