Diff
Not logged in

Differences From Artifact [a105238bfa87f17a]:

To Artifact [1b2e4ad2dae20251]:


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