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 immutable char[] target_of_; 149 immutable char[] target_of_; 150 immutable char[][] source_of_; 150 immutable char[][] source_of_; 151 immutable Pos[] position_of_; 151 immutable Pos[] position_of_; 152 immutable char[] source_list_; 152 immutable char[] source_list_; 153 immutable char[] target_list_; 153 immutable char[] target_list_; 154 Trampoline clone() const { return cast(Trampoline) this; } 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 auto ta = new char['I'+1]; 158 auto ta = new char['I'+1]; 159 auto sr = new char[]['9'+1]; 159 auto sr = new char[]['9'+1]; 160 auto po = new Pos[max('I','9')+1]; 160 auto po = new Pos[max('I','9')+1]; 161 char[] sl, tl; 161 char[] sl, tl; 162 foreach(fr,to; tramparam) { 162 foreach(fr,to; tramparam) { 163 ta[fr] = to; 163 ta[fr] = to; ................................................................................................................................................................................ 441 } 441 } 442 442 443 //////////////////////////////////////////////////////////////////////////////// 443 //////////////////////////////////////////////////////////////////////////////// 444 444 445 class Game 445 class Game 446 { 446 { 447 mixin DeriveShow; 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 this(File input) 470 this(File input) 450 { 471 { 451 string[] raw_data; 472 string[] raw_data; 452 string[string] params; 473 string[string] params; 453 474 454 // Raw map data; read until empty line. 475 // Raw map data; read until empty line. ................................................................................................................................................................................ 461 string[] ss = line.split(); 482 string[] ss = line.split(); 462 if( ss.length == 2 ) 483 if( ss.length == 2 ) 463 params[ss[0]] = ss[1]; 484 params[ss[0]] = ss[1]; 464 if( ss.length == 4 && ss[0]=="Trampoline" && ss[2]=="tar 485 if( ss.length == 4 && ss[0]=="Trampoline" && ss[2]=="tar 465 trampo[ss[1][0]] = ss[3][0]; 486 trampo[ss[1][0]] = ss[3][0]; 466 } 487 } 467 488 468 this.map = new Map(raw_data, params, trampo); | 489 this.map_ = new Map(raw_data, params, trampo); 469 this.water = Water.load(params); | 490 this.water_ = Water.load(params); 470 this.hige = Hige.load(params); | 491 this.hige_ = Hige.load(params); 471 this.tr = new Trampoline(this.map, trampo); | 492 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; < 483 } 493 } 484 494 485 void command(char c) 495 void command(char c) 486 { 496 { 487 assert(c != 'A'); 497 assert(c != 'A'); 488 if(dead || cleared) 498 if(dead || cleared) 489 return; 499 return; 490 500 491 // TODO: clarify the event order 501 // TODO: clarify the event order 492 bool dead_now = map.command(c, turn, hige.is_growing_turn(turn), | 502 bool dead_now = map_.command(c, turn, hige.is_growing_turn(turn) 493 if( dead_now ) 503 if( dead_now ) 494 dead = true; | 504 dead_ = true; 495 if(!map.cleared) { 505 if(!map.cleared) { 496 if( map.robot.y <= water_level ) 506 if( map.robot.y <= water_level ) 497 ++under_water; 507 ++under_water; 498 else 508 else 499 under_water = 0; 509 under_water = 0; 500 if( under_water > map.waterproof ) 510 if( under_water > map.waterproof ) 501 dead = true; | 511 dead_ = true; 502 } 512 } 503 turn += 1; 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 @property const: 516 @property const: 517 long score() { return map.collected_lambda*(dead?25L:cleared?7 517 long score() { return map.collected_lambda*(dead?25L:cleared?7 518 int water_level() { return water.level(turn); } 518 int water_level() { return water.level(turn); } 519 int water_until_rise() { return water.until_rise(turn); } 519 int water_until_rise() { return water.until_rise(turn); } 520 int hige_until_rise() { return hige.until_rise(turn); } 520 int hige_until_rise() { return hige.until_rise(turn); } 521 int hp() { return map.waterproof - under_water; } 521 int hp() { return map.waterproof - under_water; } 522 bool cleared() { return map.cleared; } 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 private Solver sub_solver; 782 private Solver sub_solver; 783 } 783 } 784 784 785 alias 侵掠如火!(疾如風!(false)) FastSolver; 785 alias 侵掠如火!(疾如風!(false)) FastSolver; 786 786 787 alias Switcher MainSolver; 787 alias Switcher MainSolver; > 788 //alias FastSolver MainSolver; 788 //alias 徐如林 MainSolver; 789 //alias 徐如林 MainSolver;