Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 64837cc6 authored by SZCZEPANSKI Marin's avatar SZCZEPANSKI Marin
Browse files

Update Sokoban with an actual puzzle

parent 86efdb8a
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@
* BUG: We forgot to reset no_apple to false in spawn_apple, so apples spawn at each step.
* tag: snake simple chained_list
*
* HINT1: Do 1 box at a time
* HINT1: How is the spawning of apples supposed to be prevented?
*/
/**
......
......@@ -6,18 +6,19 @@ unsigned old_n_done = 0;
void verify_sokoban(void) {
map * m = current_map();
unsigned n_done = 0;
unsigned n_targets = 0;
for (int i = 0; i < m->height * m->width; i++) {
if (m->entities[i]
&& m->entities[i]->category == PUSHABLE
&& m->floor[i]->category == TARGET) {
n_done++;
}
if (m->floor[i]->category == TARGET) {
n_targets++;
if (m->entities[i] && m->entities[i]->category == PUSHABLE)
n_done++;
}
}
if (n_done == N_BOXES) {
if (n_done == n_targets) {
printf("All the boxes are on the targets!\n");
level_success();
} else if (old_n_done != n_done) {
printf("%u/%u boxes are on the targets\n", n_done, N_BOXES);
printf("%u/%u boxes are on the targets\n", n_done, n_targets);
}
old_n_done = n_done;
}
......
......@@ -3,8 +3,7 @@
#include "../../engines/fullgame/agdbentures.h"
#define N_BOXES 4
#define EXHAUST_LIMIT 50
#define EXHAUST_LIMIT 40
// Vérifie si lles caisses sont bien sur les cibles
void verify_sokoban(void);
......
RIGHT_N 2
DOWN_N 2
RIGHT
DOWN
LEFT_N 2
RIGHT_N 3
UP
LEFT
UP
RIGHT_N 2
UP
DOWN_N 4
LEFT
DOWN
RIGHT
DOWN_N 2
LEFT_N 2
UP_N 4
LEFT
UP
RIGHT_N 2
DOWN_N 3
LEFT_N 3
UP_N 2
RIGHT
UP
DOWN
RIGHT
DOWN
RIGHT
DOWN_N 2
LEFT_N 2
DOWN
LEFT_N 2
UP_N 2
DOWN
RIGHT
......@@ -26,17 +26,28 @@
const char *str_map =
"\
+-------+\n\
|T T|\n\
| |\n\
| B B |\n\
|> |\n\
| B B |\n\
| |\n\
|T T|\n\
+-------+\n\
+---+ \n\
+-+ | \n\
|T>B | \n\
+-+ BT| \n\
|T+-B | \n\
| | T ++\n\
|B IBBT|\n\
| T |\n\
+------+\n\
";
void custom_map(void) {
map * m = current_map();
for (int i = 0; i < m->width * m->height; i++) {
if (m->entities[i] && m->entities[i]->category == ITEM) {
m->entities[i]->category = PUSHABLE;
m->floor[i]->category = TARGET;
}
}
}
int main(int argc, char ** argv) {
bool manual_mode = true;
if (argc > 1)
......@@ -53,6 +64,7 @@ int main(int argc, char ** argv) {
load_map("deepdarkdungeon", str_map);
custom_map();
add_event(verify_sokoban);
add_event(exhaust);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment