ASCII Train Golf

Python, 464

from curses import*
E,P,B,T,H,F,C='eJyNkM0NgDAIhe9MwVEPpBN0AxMHsKaLdHgfpVr7E+NHUyCQR4C5EiP5jKXBUeLj5ORvkDes5DtEiHeBoWo+hI36NtN9XurrRaVMQTSTEBizPo3+SGBBICLZ0/K9y0whtlDA/Gruj8SwyaRJA9tSPz16qmdTxqO9VeAvC5VloQ=='.decode('base64').decode('zlib').split('L')
i=[s.split('\n')for s in map(eval,raw_input()[::-1])]
h=max(sum(map(bool,s))for s in i)
w=initscr()
x=0
for t in i:[w.addstr(y,x,t[y+6-h])for y in range(h)];x+=len(t[-2])
w.addstr(h-2,x-2,'  ')
w.getch()
endwin()

I went for an approach using curses. It can't really compete, but I had some fun with it (~630 bytes):

train

from curses import*
E,P,B,T,H,F,C='eJyFkMENwCAIRe9M8Y/tgTiBGzTpALVxEYcvSFqiNO2DCAb8BgCnVsodu5ZEDceJlm/kPrBSniDsLCY1i6VsNDeZ6uMt1GEKMJU3ARYD1DX7F5DRBGbukZbvKeL7OkJF/nZL/wJxhrlFE6vooYtuviwlrso1JF745GMr'.decode('base64').decode('zlib').split('L')
i=[s.split('\n')for s in map(eval,raw_input()[::-1])]
h=max(sum(map(bool,s))for s in i)
w=initscr()
m=w.getmaxyx()[1]
for o in range(-sum(2+len(t[-2])for t in i),m):
 x=o
 for t in i:
  if m>x>o:w.addnstr(h-2,max(x,0),'--'[max(0,-x):],m-x);x+=2
  [w.addnstr(y,max(x,0),t[y+6-h][max(0,-x):],m-x)for y in range(h)if x<m];x+=len(t[-2])
 w.move(h,0);w.refresh();w.clear();napms(90)
endwin()

Perl, 265 bytes

Since this entry contains bytes that do not correspond to printable ASCII characters, it cannot be copy-pasted here directly. Instead, I am providing it as a hex dump. Users on Unix-ish systems can reconstruct the script by feeding the following hex dump to the xxd -r command:

0000000: 7573 6520 436f 6d70 7265 7373 275a 6c69  use Compress'Zli
0000010: 623b 6576 616c 2075 6e63 6f6d 7072 6573  b;eval uncompres
0000020: 7320 2778 daad 9241 6b83 3014 c7ef f914  s 'x...Ak.0.....
0000030: ef10 6add f67c 5ed6 8b06 c646 476f dda1  ..j..|^....FGo..
0000040: 3723 c183 1d85 8212 c740 087e f625 a6a3  7#.......@.~.%..
0000050: b1f6 24fd 3de1 3d7f e8fb e790 b74a 74ed  ..$.=.=......Jt.
0000060: f9f4 c3e9 25cf a328 6310 a094 6b4c 8c78  ....%..(c...kL.x
0000070: 2569 5406 8a12 8cf8 c7ab 09b1 ff71 0222  %iT..........q."
0000080: 833d da02 b874 2981 c10d 3333 df74 39c1  .=...t)...33.t9.
0000090: f531 d6dc 0f03 8f9f 9666 a12d 7021 6e7a  .1.......f.-p!nz
00000a0: 6416 2807 228e dd99 3584 c40f cc52 53ac  d.(."...5....RS.
00000b0: 9160 82a2 4559 0bcd a22c ff2e 1cc1 0e63  .`..EY...,.....c
00000c0: 9d09 6f85 25b8 13b3 8470 3fe3 5c27 a1eb  ..o.%....p?.\'..
00000d0: df5a 7735 b44d 2b86 9eb6 5fef 87dd e707  .Zw5.M+..._.....
00000e0: a5b8 219d b1ae eaed 3743 4709 f1aa d83c  ..!.....7CG....<
00000f0: f1d5 3357 257d 6be7 1039 9186 63a3 214d  ..3W%}k..9..c.!M
0000100: 9257 f607 1251 a1e7 27                   .W...Q..'

The script uses the Perl 5.10 say feature, and so needs to be run with perl -M5.010. It takes a single command line argument consisting of the letters EPBTHFC and outputs the corresponding train car arrangement. For example, the input FEH produces the following output:

                             __                     
                 ======      \/                     
_______________  | [] |=========                    
\ | | | | | | /  |              )                   
===============--================--===============
 O-O       O-O    O-O-O   O-O-O \\  O-O       O-O   

The readable code at the beginning of the script simply decompressed the zlib-compressed string containing the body of the script and evals it. The decompressed code, in turn, looks like this:

@a=split$/,<<'';
            __    
======      \/    
| [] |=========   
|              )  
================--
 O-O-O   O-O-O \\ 


===============  
| [] [] [] [] |  
===============--
 O-O       O-O   


===============  
|-|-|  |  |-|-|  
===============--
 O-O       O-O   


 _____---_____   
(             )  
===============--
 O-O       O-O   


_______________  
\ | | | | | | /  
===============--
 O-O       O-O   




===============--
 O-O       O-O   

    =====      
====|   |====  
| []     [] |  
=============--
 O-O     O-O   

$i=reverse pop=~y/EPBTHFC/0-6/r;
say$i=~s/./$a[6*$&+$_]/gr=~s/--$//r for 0..5

Note that all the train cars have their lines padded with spaces to a uniform length, and include the coupling (which is stripped from the rightmost car by the output loop). The DEFLATE compression used by zlib is very good at compressing such repetitive data, so there's no need to try and compress it by hand.

Note that this is a quick first attempt. I'm sure it would be possible to shave several bytes off the length by playing with variations such as reordering the train cars in the source.


Python (582 488 476 450 Chars)

import sys
A=sys.argv[1]
h=0
c='eJyVkrEKAzEIhnef4h97g9x+kOVKS7d2uK0peZE8fNXQS3NCpb+BREU/YnIhfKkUgJKpBfIsgYrnCzV9pIFBE6WDCHcWk1zbMy0PGovg/GMPw+6rujwaAY0CWtb/ESwG6NJTjNhChMxQxMy2g06/R+URtxBRRlGWC3SbY8Q1vkXgh4gz+Qb7v7Jy/US1P7TKP3NvbG3fy/V/Cw=='.decode('base64').decode('zlib').split(':')
C={}
for x in c:X=x.split('\n');C[X[0]]=X[1:-1]
for c in A:h=max(h,1+('F..CE'.find(c)+1or 3))
for y in range(6-h,6):print(' -'[y==4]*2).join(C[c][y]for c in A[::-1])

The ascii-salad is a base64 encoded zlib-compressed string containing the figures...