Diff
Not logged in

Differences From Artifact [9d4255819d57ec36]:

To Artifact [0eb850e277f37179]:


391 Game clone() const { return new Game(this); } 391 Game clone() const { return new Game(this); } 392 this(in Game g) { 392 this(in Game g) { 393 map = g.map.clone(); 393 map = g.map.clone(); 394 water = g.water.clone(); 394 water = g.water.clone(); 395 turn = g.turn; 395 turn = g.turn; 396 dead = g.dead; 396 dead = g.dead; 397 lambda = g.lambda; 397 lambda = g.lambda; 398 exit_bonus = g.exit_bonus; | 398 cleared = g.cleared; 399 under_water = g.under_water; 399 under_water = g.under_water; 400 } 400 } 401 401 402 void command(char c) 402 void command(char c) 403 { 403 { > 404 assert(c != 'A'); 404 if(dead || cleared) 405 if(dead || cleared) 405 return; 406 return; 406 407 407 if(c == 'A') < 408 { < 409 exit_bonus = 1; < 410 return; < 411 } < 412 < 413 // TODO: clarify the event order 408 // TODO: clarify the event order 414 Tuple!(int,bool) ld = map.command(c, turn); 409 Tuple!(int,bool) ld = map.command(c, turn); 415 if( map.cleared() ) { 410 if( map.cleared() ) { 416 exit_bonus = 2; | 411 cleared = true; 417 } 412 } 418 else { 413 else { 419 lambda += ld[0]; 414 lambda += ld[0]; 420 if( ld[1] ) { | 415 if( ld[1] ) 421 dead = true; 416 dead = true; 422 } < 423 } 417 } 424 if( map.robot.y <= water_level ) 418 if( map.robot.y <= water_level ) 425 ++under_water; 419 ++under_water; 426 else 420 else 427 under_water = 0; 421 under_water = 0; 428 if( under_water > map.waterproof ) 422 if( under_water > map.waterproof ) 429 dead = true; 423 dead = true; ................................................................................................................................................................................ 431 } 425 } 432 426 433 Map map; 427 Map map; 434 Water water; 428 Water water; 435 int turn = 0; 429 int turn = 0; 436 bool dead = false; 430 bool dead = false; 437 int lambda = 0; 431 int lambda = 0; 438 int exit_bonus = 0; < 439 int under_water = 0; 432 int under_water = 0; > 433 bool cleared = false; 440 // TODO: when adding members, take care of clone(). 434 // TODO: when adding members, take care of clone(). 441 // TODO: fix this poor design. 435 // TODO: fix this poor design. 442 436 443 @property const { 437 @property const { 444 long score() { return lambda*25L*(1+exit_bonus) - turn; } | 438 long score() { return lambda*(dead ? 25L : cleared ? 75L : 50L) 445 int water_level() { return water.level(turn); } 439 int water_level() { return water.level(turn); } 446 int water_until_rise() { return water.until_rise(turn); } 440 int water_until_rise() { return water.until_rise(turn); } 447 int hige_until_rise() { return map.hige.until_rise(turn); } 441 int hige_until_rise() { return map.hige.until_rise(turn); } 448 bool cleared() { return exit_bonus>0; } < 449 int hp() { return map.waterproof - under_water; } 442 int hp() { return map.waterproof - under_water; } 450 long score_if_abort_now() { return lambda*25*(1+max(1,exit_bonus < 451 } 443 } 452 } 444 }