Index: src/game.d ================================================================== --- src/game.d +++ src/game.d @@ -151,11 +151,11 @@ immutable Pos[] position_of_; immutable char[] source_list_; immutable char[] target_list_; Trampoline clone() const { return cast(Trampoline) this; } - this(Map m, char[char] tramparam) + this(in Map m, char[char] tramparam) { auto ta = new char['I'+1]; auto sr = new char[]['9'+1]; auto po = new Pos[max('I','9')+1]; char[] sl, tl; @@ -443,10 +443,31 @@ //////////////////////////////////////////////////////////////////////////////// class Game { mixin DeriveShow; + + private { + Map map_; + Water water_; + Hige hige_; + Trampoline tr_; + int turn = 0; + bool dead_ = false; + int under_water = 0; + } + + Game clone() const { return new Game(this); } + this(in Game g) { + map_ = g.map_.clone(); + water_ = g.water_.clone(); + hige_ = g.hige_.clone(); + tr_ = g.tr_.clone(); + turn = g.turn; + dead_ = g.dead_; + under_water = g.under_water; + } this(File input) { string[] raw_data; string[string] params; @@ -463,61 +484,45 @@ params[ss[0]] = ss[1]; if( ss.length == 4 && ss[0]=="Trampoline" && ss[2]=="targets" ) trampo[ss[1][0]] = ss[3][0]; } - this.map = new Map(raw_data, params, trampo); - this.water = Water.load(params); - this.hige = Hige.load(params); - this.tr = new Trampoline(this.map, trampo); - } - - Game clone() const { return new Game(this); } - this(in Game g) { - map = g.map.clone(); - water = g.water.clone(); - hige = g.hige.clone(); - tr = g.tr.clone(); - turn = g.turn; - dead = g.dead; - under_water = g.under_water; + this.map_ = new Map(raw_data, params, trampo); + this.water_ = Water.load(params); + this.hige_ = Hige.load(params); + this.tr_ = new Trampoline(this.map, trampo); } void command(char c) { assert(c != 'A'); if(dead || cleared) return; // TODO: clarify the event order - bool dead_now = map.command(c, turn, hige.is_growing_turn(turn), tr); + bool dead_now = map_.command(c, turn, hige.is_growing_turn(turn), tr); if( dead_now ) - dead = true; + dead_ = true; if(!map.cleared) { if( map.robot.y <= water_level ) ++under_water; else under_water = 0; if( under_water > map.waterproof ) - dead = true; + dead_ = true; } turn += 1; } - Map map; - Water water; - Hige hige; - Trampoline tr; - int turn = 0; - bool dead = false; - int under_water = 0; - // TODO: when adding members, take care of clone(). - // TODO: fix this poor design. - @property const: long score() { return map.collected_lambda*(dead?25L:cleared?75L:50L)-turn; } int water_level() { return water.level(turn); } int water_until_rise() { return water.until_rise(turn); } int hige_until_rise() { return hige.until_rise(turn); } int hp() { return map.waterproof - under_water; } bool cleared() { return map.cleared; } + bool dead() { return dead_; } + const(Map) map() { return map_; } + const(Water) water() { return water_; } + const(Hige) hige() { return hige_; } + const(Trampoline) tr() { return tr_; } } Index: src/solver.d ================================================================== --- src/solver.d +++ src/solver.d @@ -783,6 +783,7 @@ } alias 侵掠如火!(疾如風!(false)) FastSolver; alias Switcher MainSolver; +//alias FastSolver MainSolver; //alias 徐如林 MainSolver;