Build strategically to earn $10k before time is up, click: water to terraform, land to place station. Clear 5 levels to win.
for(_='&&jj(Z==Qe,@),ws*.v[i]`f`>.5?_w_vO/s)Nd-=W++)V=0;Uif(D1:.C0,B*sL(i%sL+KNL+J);I~~(Hc.fillG,BswG() ",c.beginPath(wc.arcKv5,HiJv5,s*.5 IbreakGStyle="#.7 ,[h]<=d+=m(1Qg5>e?Math.random()e=HLLIiUi<sQP`?He.client=[],for(,t(@;iV:s,_s:v`Z g[e]D[i+m(R`)]:0wHiJ(_0:v",GRectK(_v=function(@o){Lafgl=Bmreturn.2C-C7s:-s},n=@Mq=!Brk=He/200IDk>l){R=P.slice(IR`Z?(P`=1.6:.6C1.3:.1,d+=Mj1<M?3*M:0):(P=P`,P`=0wd--Iu--;WS;1>uZq=!1,alert(1E4?2>n?":A":"E"+(7-n):":("))}0272.2 ;g 0611722Qg 4a3.4 If 99922O66w06144O22)IP 39f11O88)I 900ed1ed1";GText(["$"+d,6-n,Hu*.2)],BsL+sIl=k;q?requestAnimationFrame(r):1E4j1<nja(n-1)},s=2Bd=sL*@tk=!0;h=e;Dhow.5<o||HhNQHeN){j0<i){M=i;}3^gZk=!1)}jk)P[e+m(o)]=o,h=@{hoI);f=o}},u=50*e+50BPSU*.4{;)FUF<s*2;FV{;;)eI=.1<?3:2}}r(Ionclicke=YJX/sI!j20?(=3,W20):3Qj50Z=1,W50.1).3).6)1wSV}};a(5)';g=/[- G-LB-DU-WNO_`vw@QZj]/.exec(_);)with(_.split(g))_=join(shift());eval(_)
Zm9yKF89JyYmamooWj09UWUsQCksd3MqLnZbaV1gZmA+LjU/X3dfdk8vcylOZC09VysrKVY9MDtVaWYoRDE6LkMwLEIqc0woaSVzTCtLTkwrSik7SX5+KEhjLmZpbGxHLEJzd0coKSAiLGMuYmVnaW5QYXRoKHdjLmFyY0t2NSxIaUp2NSxzKh8fLjUgSR5icmVhax1HU3R5bGU9IiMcHy43ICwcG1toXRo8PWQZKz1tKBgxUWcXNT5lPxZNYXR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4oc2hpZnQoKSk7ZXZhbChfKQ==
//a = function - start level at difficulty e (higher = easier) - overwrites shim reference to canvas
a = function( e, o ){
//b = body (unused)
//c = context
//d = money (declared below 's' as derived from s)
//e = event or location index or difficulty
//f = track directions,
f = [],
//g = grid
// 1 = station
// 2 = hills
// 3 = grass
g = [],
//h = temporary location index
//i = iterator
//j = iterator
//k = are all tiles in line grass, or current time
//l = last time called
l = 0,
//m = function - move one tile in param direction
// 0-0.25 = right = 1
// 0.25-0.5 = left = -1
// 0.5-0.75 = down = s
// 0.75-1 = up = -s
m = function( e, o ){
return .25 > e ? 1 : .5 > e ? -1 : .75 > e ? s : -s
},
//n = difficulty
n = e,
//o = function param, usually a direction 0-1
//p = station lengths array
p = [],
//q = bool: keep running - set to false to halt
q = !0,
//r = main loop
//main loop
r = function( e, o ){
//every 5th of a s
k = ~~( e / 200 )
if( k > l ){
//copy trains to temp array as we are modifying train array
w = v.slice()
//iterate over map tiles
for( i = 0; i < s * s; i++ )
//if train at this tile
w[ i ] && (
//get next tile in train's direction
//if it's a station turn around
1 == g[ i + m( w[ i ] ) ] ? (
//set the train direction
v[ i ] =
//currently going up, change to down
1 == v[ i ] ?
.6 :
//currently going down, change to up
.6 == v[ i ] ?
1 :
//right, go left
.1 == v[ i ] ?
.3 :
//left, go right
.1,
//at a station, collect income for delivering passengers
//does station have a length
d += p[ i + m( w[ i ] ) ] &&
//is station length at least two (not a transfer)
1 < p[ i + m( w[ i ] ) ] ?
//award length * 3
3 * p[ i + m( w[ i ] ) ] :
//nothing
0
) : (
//move to next tile
v[ i + m( w[ i ] ) ] = v[ i ],
//delete train at old tile
v[ i ] = 0
),
//deduct $2 for train running costs
d--
)
//time remaining
u--;
//station costs
d -= z;
//if out of time
1 > u &&(
//stop running
q = !1,
//end of game message
alert( 1E4 <= d ? 2 > n ? ':D' : 'L' + ( 7 - n ) : ':(' )
)
}
//draw water
for( i = 0; i < s * s; i++ )
c.fillStyle = '#027',
c.beginPath(),
c.arc( i % s * s + s * .5, ~~( i / s ) * s + s * .5, s * 2.2, 0, s ),
c.fill();
//draw grass
for( i = 0; i < s * s; i++ )
g[ i ] && (
c.fillStyle = '#061',
c.beginPath(),
c.arc( i % s * s + s * .5, ~~( i / s ) * s + s * .5, s * .7, 0, s ),
c.fill(),
c.fillStyle = '#172',
c.beginPath(),
c.arc( i % s * s + s *.5, ~~( i / s ) * s + s * .5, s * .5, 0, s ),
c.fill()
)
//draw hills
for( i = 0; i < s * s; i++ )
2 == g[ i ] && (
c.fillStyle = '#4a3',
c.beginPath(),
c.arc( i % s * s + s * .5, ~~( i / s ) * s + s * .5, s * .4, 0, s ),
c.fill()
)
//draw tracks
for( i = 0; i < s * s; i++ )
f[ i ] && (
c.fillStyle = '#999',
c.fillRect( i % s * s + ( f[ i ] > .5 ? s * .2 : 0 ), ~~( i / s ) * s + ( f[ i ] > .5 ? 0 : s * .2 ), f[ i ] > .5 ? s * .6 : s, f[ i ] > .5 ? s : s * .6 ),
c.fillStyle = '#061',
c.fillRect( i % s * s + ( f[ i ] > .5 ? s * .4 : 0 ), ~~( i / s ) * s + ( f[ i ] > .5 ? 0 : s * .4 ), f[ i ] > .5 ? s * .2 : s, f[ i ] > .5 ? s : s * .2 )
)
//draw trains
for( i = 0; i < s * s; i++ )
v[ i ] && (
c.fillStyle = '#39f',
c.fillRect( i % s * s + ( f[ i ] > .5 ? s * .1 : 0 ), ~~( i / s ) * s + ( f[ i ] > .5 ? 0 : s * .1 ), f[ i ] > .5 ? s * .8 : s, f[ i ] > .5 ? s : s * .8 )
)
//draw stations
for( i = 0; i < s * s; i++ )
1 == g[ i ] && (
c.fillStyle = '#900',
c.beginPath(),
c.arc( i % s * s + s * .5, ~~( i / s ) * s + s * .5, s * .7, 0, s ),
c.fill(),
c.fillStyle = '#ed1',
c.beginPath(),
c.arc( i % s * s + s * .5, ~~( i / s ) * s + s * .5, s * .5, 0, s ),
c.fill()
)
//draw money, level and time left
c.fillStyle = '#ed1';
c.fillText( [ '$' + d, 6 - n, ~~( u * .2 ) ], 0, s * s + s )
//copy current time into last time
l = k;
//keep running if not halt
q ?
requestAnimationFrame( r ) :
//or if won level go next
1E4 <= d && 1 < n &&
a( n - 1 )
},
//s = size - both tile size and grid width & height
s = 20,
//d = money
d = s * s * e,
//t = function try lay track at location e in direction o
t = function( e, o ){
//was able to place
k = !0;
//copy location to temp
h = e;
//draw s long line to determine if all tiles in line are grass
for( i = 0; i < s; i++ )
//move temp location along one tile in direction o
//if moving vertically or temp on same row as original
if( h += m( o ), .5 < o || ~~( h / s ) == ~~( e / s ) ){
//if this tile is a station and line is at least 1 tile long
if( 1 == g[ h ] && 0 < i ) {
//store length of line at this station and stop looping
p[ h ] = i;
break
}
//remember if any tile in the line isn't grass
3 ^ g[ h ] && ( k = !1 )
}
//every tile was grass and we ended on a station
if( 1 == g[ h ] && k )
//add a train one tile over from the station
//copy location to temp
//set the tiles on the map to track
for( v[ e + m( o ) ] = o, h = e, i = 0; i < s; i++ ){
//move temp location along
h += m( o );
//stop when we reach the station
if( 1 == g[ h ] ) break;
//set tile at temp to track
f[ h ] = o
}
},
//u = time left until end of round (in ticks, tick = 0.2s)
u = 50 * e + 500,
//trains array, stores direction of each train
v = [],
//w = unused
//x = unused
//y = unused
//station count
z = 0
//create islands
//pick a random start tile
for( i = 0; i < s * .4; i++ ){
//if the tile is occupied pick a different one
for( e = ~~( Math.random() * s * s); g[ e ]; )
e = ~~( Math.random() * s * s )
//place s*2 pieces of land
for( j = 0; j < s * 2; j++ ){
//move randomly until we find an unoccupied tile
for( ; g[ e ] ; )
e += m( Math.random() )
//set the current tile to either grass or hill
g[ e ] = .1 < Math.random() ? 3 : 2
}
}
//start
r()
//user trying to terraform or build
onclick = function( e, o ){
//convert event coords to grid index
e = ~~( e.clientY / s ) * s + ~~( e.clientX / s )
//if water and can afford to make land
!g[ e ] && 20 <= d ? (
//set to land
g[ e ] = 3,
//deduct $20
d -= 20
//otherwise if it's land and can afford to build station
) : 3 == g[ e ] && 50 <= d && (
//set to station
g[ e ] = 1,
//deduct $50
d -= 50,
//try and connect to another station
t( e, .1 ),
t( e, .3 ),
t( e, .6 ),
t( e, 1 ),
//increment station count
z++
)
}
}
//start on level 5 (easiest)
a(5)