train speed

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
Bus
Engineer
Engineer
Posts: 32
Joined: 19 May 2010 15:28

train speed

Post 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?
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: train speed

Post by Eddi »

afair, trains move twice every tick, not sure how that affects your calculation, though.
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5656
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: train speed

Post 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>
Bus
Engineer
Engineer
Posts: 32
Joined: 19 May 2010 15:28

Re: train speed

Post by Bus »

Aha! Thanks Eddi. So does that mean that the train would move 5.78 tiles / day? Why does wiki mention 5.6?
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: train speed

Post 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. :)
User avatar
Lordmwa
President
President
Posts: 899
Joined: 20 May 2006 19:30
Location: West Sussex, England

Re: train speed

Post by Lordmwa »

*brain explodes*
The TT forums trivia tournament! Come along and join in the fun
http://www.funtrivia.com/private/main.cfm?tid=90722
audigex
Tycoon
Tycoon
Posts: 1998
Joined: 09 Dec 2007 21:28
Contact:

Re: train speed

Post 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.
Jon
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: train speed

Post 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...
audigex
Tycoon
Tycoon
Posts: 1998
Joined: 09 Dec 2007 21:28
Contact:

Re: train speed

Post by audigex »

haha I know - but I refused to miss an opportunity to paraphrase a simpsons quote.
Jon
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 9 guests