Index: game.d ================================================================== --- game.d +++ game.d @@ -97,16 +97,15 @@ { // TODO: choose optimal representation. return new Map(raw_data, params); } - private { - char[][] data; - Pos robot; - Pos lift; - int waterproof; - } + char[][] data; + Pos robot; + Pos lift; + int waterproof; + Map clone() { return new Map(this); } this(Map m) { foreach(s; m.data) this.data ~= s.dup; this.robot = m.robot.clone(); @@ -127,11 +126,11 @@ for(int y=1; y<=H; ++y) for(int x=1; x<=W; ++x) { if(this[y,x] == 'R') this.robot = new Pos(y,x); - if(this[y,x] == 'L') + if(this[y,x] == 'L' || this[y,x] == 'O') this.lift = new Pos(y,x); } this.waterproof = params.get("Waterproof", "5").to!int(); } @@ -166,10 +165,19 @@ void opIndexAssign(char c, Pos p) { this[p.y, p.x] = c; } + + Pos[] lambdas() { + Pos[] ans; + for(int y=1; y<=H; ++y) + for(int x=1; x<=W; ++x) + if(this[y,x] == '\\') + ans ~= new Pos(y,x); + return ans; + } bool cleared() { for(int y=1; y<=H; ++y) for(int x=1; x<=W; ++x) Index: gui.d ================================================================== --- gui.d +++ gui.d @@ -1,9 +1,10 @@ import dfl.all; import util; import game; import output; +//import solver; class GUI : Form { private { Game g; @@ -22,15 +23,14 @@ this.g = g; this.paint ~= &my_paint; this.keyDown ~= &my_keydown; - const MAX_SIZE = 640; this.formBorderStyle = FormBorderStyle.FIXED_DIALOG; this.maximizeBox = false; this.minimizeBox = false; - this.cell = MAX_SIZE / max(g.map.W, g.map.H); + this.cell = min(1024/g.map.W, 640/g.map.H); this.clientSize = Size(g.map.W*cell, g.map.H*cell); set_text(); // Resources this.font = new Font("MS Gothic", cell-2, GraphicsUnit.PIXEL); @@ -94,10 +94,11 @@ case Keys.UP: g.command('U'); break; case Keys.LEFT: g.command('L'); break; case Keys.RIGHT: g.command('R'); break; case Keys.W: g.command('W'); break; case Keys.A: g.command('A'); break; +// case Keys.G: solver.act(g); break; default: break; } if(g.cleared) Application.exit(); invalidate();