Diff
Not logged in

Differences From Artifact [1b2e4ad2dae20251]:

To Artifact [06258bf9d419d24b]:


84 84 assert( 1 == w.level(3) ); 85 85 assert( 1 == w.level(4) ); 86 86 assert( 1 == w.level(5) ); 87 87 } 88 88 89 89 //////////////////////////////////////////////////////////////////////////////// 90 90 91 +class Hige 92 +{ 93 + public immutable int pace; 94 + mixin DeriveCreate; 95 + mixin DeriveCompare; 96 + mixin DeriveShow; 97 + Hige clone() const { return cast(Hige)this; } 98 + 99 + static load(string[string] params) 100 + { 101 + return new Hige(params.get("Growth", "25").to!int()); 102 + } 103 + 104 + bool is_growing_turn(int turn) const 105 + { 106 + return pace ? turn%pace == pace-1 : false; 107 + } 108 + 109 + int until_rise(int turn) const 110 + { 111 + return pace ? pace-turn%pace : int.max; 112 + } 113 +} 114 + 115 +//////////////////////////////////////////////////////////////////////////////// 116 + 91 117 class Map 92 118 { 93 119 mixin DeriveShow; 94 120 95 121 static Map load(string[] raw_data, string[string] params, char[char] trampo) 96 122 { 97 123 // TODO: choose optimal representation. ................................................................................ 101 127 char[][] data; 102 128 Pos robot; 103 129 Pos lift; 104 130 int waterproof; 105 131 // TODO: immutable 106 132 Pos[char] tr_target; 107 133 Pos[][char] tr_source; 134 + const(Hige) hige; 135 + int razor; 108 136 109 137 Map clone() const { return new Map(this); } 110 138 this(in Map m) { 111 139 foreach(s; m.data) 112 140 this.data ~= s.dup; 113 141 this.robot = m.robot.clone(); 114 142 this.lift = m.lift.clone(); 115 143 this.waterproof = m.waterproof; 116 144 this.tr_target = cast(Pos[char])m.tr_target; 117 145 this.tr_source = cast(Pos[][char])m.tr_source; 146 + this.hige = m.hige.clone(); 147 + this.razor = m.razor; 118 148 } 119 149 120 150 this(string[] raw_data, string[string] params, char[char] trampo) 121 151 { 122 152 int width = 0; 123 153 foreach(r; raw_data) 124 154 width = max(width, r.length); ................................................................................ 146 176 147 177 this.waterproof = params.get("Waterproof", "5").to!int(); 148 178 foreach(fr,to; trampo) { 149 179 tr_target[fr] = tr_pos[to]; 150 180 if(to !in tr_source) tr_source[to] = []; 151 181 tr_source[to] ~= tr_pos[fr]; 152 182 } 183 + 184 + this.hige = Hige.load(params); 185 + this.razor = params.get("Razors", "0").to!int(); 153 186 } 154 187 155 188 const @property { 156 189 int H() { return data.length; } 157 190 int W() { return data[0].length; } 158 191 } 159 192 ................................................................................ 385 418 // TODO: when adding members, take care of clone(). 386 419 // TODO: fix this poor design. 387 420 388 421 @property const { 389 422 long score() { return lambda*25L*(1+exit_bonus) - turn; } 390 423 int water_level() { return water.level(turn); } 391 424 int water_until_rise() { return water.until_rise(turn); } 425 + int hige_until_rise() { return map.hige.until_rise(turn); } 392 426 bool cleared() { return exit_bonus>0; } 393 427 int hp() { return map.waterproof - under_water; } 394 428 long score_if_abort_now() { return lambda*25*(1+max(1,exit_bonus)) - turn; } 395 429 } 396 430 } 397 - 398 -unittest 399 -{ 400 - Game.load(["###","...","#RL"], ["xxx":"yyy"]); 401 -}