Diff
Not logged in

Differences From Artifact [a105238bfa87f17a]:

To Artifact [1b2e4ad2dae20251]:


98 98 return new Map(raw_data, params, trampo); 99 99 } 100 100 101 101 char[][] data; 102 102 Pos robot; 103 103 Pos lift; 104 104 int waterproof; 105 + // TODO: immutable 105 106 Pos[char] tr_target; 106 107 Pos[][char] tr_source; 107 108 108 109 Map clone() const { return new Map(this); } 109 110 this(in Map m) { 110 111 foreach(s; m.data) 111 112 this.data ~= s.dup; 112 113 this.robot = m.robot.clone(); 113 114 this.lift = m.lift.clone(); 114 115 this.waterproof = m.waterproof; 116 + this.tr_target = cast(Pos[char])m.tr_target; 117 + this.tr_source = cast(Pos[][char])m.tr_source; 115 118 } 116 119 117 120 this(string[] raw_data, string[string] params, char[char] trampo) 118 121 { 119 122 int width = 0; 120 123 foreach(r; raw_data) 121 124 width = max(width, r.length); ................................................................................ 141 144 tr_pos[c] = new Pos(y,x); 142 145 } 143 146 144 147 this.waterproof = params.get("Waterproof", "5").to!int(); 145 148 foreach(fr,to; trampo) { 146 149 tr_target[fr] = tr_pos[to]; 147 150 if(to !in tr_source) tr_source[to] = []; 148 - tr_source[to] ~= tr_pos[to]; 151 + tr_source[to] ~= tr_pos[fr]; 149 152 } 150 153 } 151 154 152 155 const @property { 153 156 int H() { return data.length; } 154 157 int W() { return data[0].length; } 155 158 } ................................................................................ 226 229 this[y+dy,x+dx]='R'; 227 230 robot = new Pos(y+dy,x+dx); 228 231 } else if(dy==0 && '*'==this[y+dy,x+dx] && ' '==this[y+dy*2,x+dx*2]) { 229 232 this[y,x]=' '; 230 233 this[y+dy,x+dx]='R'; 231 234 this[y+dy*2,x+dx*2]='*'; 232 235 robot = new Pos(y+dy,x+dx); 236 + } else if('A'<=this[y+dy,x+dx] && this[y+dy,x+dx]<='I') { 237 + this[y,x]=' '; 238 + Pos tp = tr_target[this[y+dy,x+dx]]; 239 + foreach(p; tr_source[this[tp]]) 240 + this[p] = ' '; 241 + this[tp] = 'R'; 242 + robot = tp; 233 243 } 234 244 if( update() ) 235 245 dead = true; 236 246 return tuple(lambda,dead); 237 247 } 238 248 239 249 bool update()