Jump to content

Sokoban: Difference between revisions

32 bytes removed ,  10 years ago
Updated first D entry
(Updated first D entry)
Line 792:
private bool move(in int x, in int y, in int dx,
in int dy, ref CTable data)
const pure /*nothrow*/ {
if (sData[(y+dy) * ncols + x + dx] == El.wall ||
data[(y+dy) * ncols + x + dx] != El.floor)
return false;
 
auto data2 = data.dup; // Not nothrow.
data2[y * ncols + x] = El.floor;
data2[(y + dy) * ncols + x + dx] = El.player;
Line 806:
private bool push(in int x, in int y, in int dx,
in int dy, ref CTable data)
const pure /*nothrow*/ {
if (sData[(y + 2*dy) * ncols + x+2*dx] == El.wall ||
data[(y + 2*dy) * ncols + x+2*dx] != El.floor)
return false;
 
auto data2 = data.dup; // Not nothrow.
data2[y * ncols + x] = El.floor;
data2[(y + dy) * ncols + x + dx] = El.player;
Line 826:
}
 
string solve() pure nothrow {
bool[immutable CTable] visitedSet = [dData: true];
 
Line 838:
tuple(-1, 0, 'l', 'L')];
 
while (!open.lengthempty) {
//immutable (cur, cSol, x, y) = open.pop;
immutable item = open.pop;
Cookies help us deliver our services. By using our services, you agree to our use of cookies.