Diff
Not logged in

Differences From Artifact [1928257cf62dcd18]:

To Artifact [7c15481493257083]:


95 95 96 static Map load(string[] raw_data, string[string] params) 96 static Map load(string[] raw_data, string[string] params) 97 { 97 { 98 // TODO: choose optimal representation. 98 // TODO: choose optimal representation. 99 return new Map(raw_data, params); 99 return new Map(raw_data, params); 100 } 100 } 101 101 102 private { < 103 char[][] data; | 102 char[][] data; 104 Pos robot; | 103 Pos robot; 105 Pos lift; | 104 Pos lift; 106 int waterproof; | 105 int waterproof; 107 } | 106 108 Map clone() { return new Map(this); } 107 Map clone() { return new Map(this); } 109 this(Map m) { 108 this(Map m) { 110 foreach(s; m.data) 109 foreach(s; m.data) 111 this.data ~= s.dup; 110 this.data ~= s.dup; 112 this.robot = m.robot.clone(); 111 this.robot = m.robot.clone(); 113 this.lift = m.lift.clone(); 112 this.lift = m.lift.clone(); 114 this.waterproof = m.waterproof; 113 this.waterproof = m.waterproof; ................................................................................................................................................................................ 125 this.data[$-1][r.length..$] = ' '; 124 this.data[$-1][r.length..$] = ' '; 126 } 125 } 127 126 128 for(int y=1; y<=H; ++y) 127 for(int y=1; y<=H; ++y) 129 for(int x=1; x<=W; ++x) { 128 for(int x=1; x<=W; ++x) { 130 if(this[y,x] == 'R') 129 if(this[y,x] == 'R') 131 this.robot = new Pos(y,x); 130 this.robot = new Pos(y,x); 132 if(this[y,x] == 'L') | 131 if(this[y,x] == 'L' || this[y,x] == 'O') 133 this.lift = new Pos(y,x); 132 this.lift = new Pos(y,x); 134 } 133 } 135 134 136 this.waterproof = params.get("Waterproof", "5").to!int(); 135 this.waterproof = params.get("Waterproof", "5").to!int(); 137 } 136 } 138 137 139 const @property { 138 const @property { ................................................................................................................................................................................ 164 data[H-1-y][x] = c; 163 data[H-1-y][x] = c; 165 } 164 } 166 165 167 void opIndexAssign(char c, Pos p) 166 void opIndexAssign(char c, Pos p) 168 { 167 { 169 this[p.y, p.x] = c; 168 this[p.y, p.x] = c; 170 } 169 } > 170 > 171 Pos[] lambdas() { > 172 Pos[] ans; > 173 for(int y=1; y<=H; ++y) > 174 for(int x=1; x<=W; ++x) > 175 if(this[y,x] == '\\') > 176 ans ~= new Pos(y,x); > 177 return ans; > 178 } 171 179 172 bool cleared() 180 bool cleared() 173 { 181 { 174 for(int y=1; y<=H; ++y) 182 for(int y=1; y<=H; ++y) 175 for(int x=1; x<=W; ++x) 183 for(int x=1; x<=W; ++x) 176 if(this[y,x] == 'L' || this[y,x] == 'O') 184 if(this[y,x] == 'L' || this[y,x] == 'O') 177 return false; 185 return false;