Sokoban/C: Difference between revisions

168 bytes removed ,  12 years ago
various bugs
(adding modified solution: quite more complicated, but tends to be faster and use much less memory.)
 
(various bugs)
Line 8:
#include <stdbool.h>
 
#define inline
int w, h, n_boxes;
int offset[4] = {0, 0, 1, -1};
Line 87 ⟶ 86:
if (board[c + d] != wall && board[c + d * 2] != wall)
mark_live(c + d);
}
}
 
void show_live()
{
puts("live");
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++)
putchar(live[i * w + j] ? '+' : '.');
putchar('\n');
}
}
Line 189 ⟶ 178:
fill_limit = hash_size * 3 / 4; // 0.75 load factor
} else {
hash_size *= 24;
fill_limit *= 24;
}
 
buckets = realloc(buckets, state_sizesizeof(state_t*) * hash_size);
assert(buckets);
 
Line 485 ⟶ 474:
state_t *s = parse_board(
 
#define BIG 40
 
#if BIG == 0
Anonymous user