Check-in [7bd1ed1180]
Not logged in
Overview
SHA1 Hash:7bd1ed11803e591a26404f604006c7eb54956e1d
Date: 2012-07-16 19:18:57
User: kinaba
Comment:more.
Timelines: family | ancestors | descendants | both | trunk
Diffs: redesign
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Modified src/game.d from [18f8bb38825744d0] to [521705f028ec7e74].

149 149 immutable char[] target_of_; 150 150 immutable char[][] source_of_; 151 151 immutable Pos[] position_of_; 152 152 immutable char[] source_list_; 153 153 immutable char[] target_list_; 154 154 Trampoline clone() const { return cast(Trampoline) this; } 155 155 156 - this(Map m, char[char] tramparam) 156 + this(in Map m, char[char] tramparam) 157 157 { 158 158 auto ta = new char['I'+1]; 159 159 auto sr = new char[]['9'+1]; 160 160 auto po = new Pos[max('I','9')+1]; 161 161 char[] sl, tl; 162 162 foreach(fr,to; tramparam) { 163 163 ta[fr] = to; ................................................................................ 441 441 } 442 442 443 443 //////////////////////////////////////////////////////////////////////////////// 444 444 445 445 class Game 446 446 { 447 447 mixin DeriveShow; 448 + 449 + private { 450 + Map map_; 451 + Water water_; 452 + Hige hige_; 453 + Trampoline tr_; 454 + int turn = 0; 455 + bool dead_ = false; 456 + int under_water = 0; 457 + } 458 + 459 + Game clone() const { return new Game(this); } 460 + this(in Game g) { 461 + map_ = g.map_.clone(); 462 + water_ = g.water_.clone(); 463 + hige_ = g.hige_.clone(); 464 + tr_ = g.tr_.clone(); 465 + turn = g.turn; 466 + dead_ = g.dead_; 467 + under_water = g.under_water; 468 + } 448 469 449 470 this(File input) 450 471 { 451 472 string[] raw_data; 452 473 string[string] params; 453 474 454 475 // Raw map data; read until empty line. ................................................................................ 461 482 string[] ss = line.split(); 462 483 if( ss.length == 2 ) 463 484 params[ss[0]] = ss[1]; 464 485 if( ss.length == 4 && ss[0]=="Trampoline" && ss[2]=="targets" ) 465 486 trampo[ss[1][0]] = ss[3][0]; 466 487 } 467 488 468 - this.map = new Map(raw_data, params, trampo); 469 - this.water = Water.load(params); 470 - this.hige = Hige.load(params); 471 - this.tr = new Trampoline(this.map, trampo); 472 - } 473 - 474 - Game clone() const { return new Game(this); } 475 - this(in Game g) { 476 - map = g.map.clone(); 477 - water = g.water.clone(); 478 - hige = g.hige.clone(); 479 - tr = g.tr.clone(); 480 - turn = g.turn; 481 - dead = g.dead; 482 - under_water = g.under_water; 489 + this.map_ = new Map(raw_data, params, trampo); 490 + this.water_ = Water.load(params); 491 + this.hige_ = Hige.load(params); 492 + this.tr_ = new Trampoline(this.map, trampo); 483 493 } 484 494 485 495 void command(char c) 486 496 { 487 497 assert(c != 'A'); 488 498 if(dead || cleared) 489 499 return; 490 500 491 501 // TODO: clarify the event order 492 - bool dead_now = map.command(c, turn, hige.is_growing_turn(turn), tr); 502 + bool dead_now = map_.command(c, turn, hige.is_growing_turn(turn), tr); 493 503 if( dead_now ) 494 - dead = true; 504 + dead_ = true; 495 505 if(!map.cleared) { 496 506 if( map.robot.y <= water_level ) 497 507 ++under_water; 498 508 else 499 509 under_water = 0; 500 510 if( under_water > map.waterproof ) 501 - dead = true; 511 + dead_ = true; 502 512 } 503 513 turn += 1; 504 514 } 505 515 506 - Map map; 507 - Water water; 508 - Hige hige; 509 - Trampoline tr; 510 - int turn = 0; 511 - bool dead = false; 512 - int under_water = 0; 513 - // TODO: when adding members, take care of clone(). 514 - // TODO: fix this poor design. 515 - 516 516 @property const: 517 517 long score() { return map.collected_lambda*(dead?25L:cleared?75L:50L)-turn; } 518 518 int water_level() { return water.level(turn); } 519 519 int water_until_rise() { return water.until_rise(turn); } 520 520 int hige_until_rise() { return hige.until_rise(turn); } 521 521 int hp() { return map.waterproof - under_water; } 522 522 bool cleared() { return map.cleared; } 523 + bool dead() { return dead_; } 524 + const(Map) map() { return map_; } 525 + const(Water) water() { return water_; } 526 + const(Hige) hige() { return hige_; } 527 + const(Trampoline) tr() { return tr_; } 523 528 }

Modified src/solver.d from [97e58dfa28df65c7] to [a342d9597f1d9525].

781 781 782 782 private Solver sub_solver; 783 783 } 784 784 785 785 alias 侵掠如火!(疾如風!(false)) FastSolver; 786 786 787 787 alias Switcher MainSolver; 788 +//alias FastSolver MainSolver; 788 789 //alias 徐如林 MainSolver;