This repository has been archived on 2023-04-18. You can view files and clone it, but cannot push or open issues or pull requests.
iaj/TP1/C-Cpp/includes/mysok.h

59 lines
1,009 B
C
Raw Permalink Normal View History

2023-01-27 17:24:27 +01:00
#ifndef MYSOK_H
#define MYSOK_H
2023-01-27 17:49:36 +01:00
2023-02-19 17:58:59 +01:00
#include <iostream>
#include <queue>
2023-02-19 18:23:59 +01:00
#include <stack>
2023-01-27 17:24:27 +01:00
#include <string>
#define NBL 20
#define NBC 20
2023-02-21 14:46:03 +01:00
#define MAX_DEPTH 60
2023-01-27 17:24:27 +01:00
2023-02-17 16:29:44 +01:00
enum movement { MOVE_U = 0, MOVE_D, MOVE_L, MOVE_R, MOVE_W };
2023-01-27 17:24:27 +01:00
2023-01-27 17:37:08 +01:00
enum board_str {
OUT = ' ',
FREE = '_',
TARGET = '.',
WALL = '#',
CRATE_ON_FREE = '$',
CRATE_ON_TARGET = '*',
MAN1_ON_FREE = '1',
MAN1_ON_TARGET = 'u',
MAN2_ON_FREE = '2',
MAN2_ON_TARGET = 'd',
END_OF_LINE = 'a'
};
2023-01-27 17:24:27 +01:00
2023-02-19 17:58:59 +01:00
const std::string move_str[] = {"Up", "Down", "Left", "Right", "Wait"};
const int dx[] = {-1, 1, 0, 0, 0};
const int dy[] = {0, 0, -1, 1, 0};
const int dsize = 5;
2023-01-27 17:24:27 +01:00
struct sok_board_t {
int board[NBL][NBC];
int board_nbl;
int man1_x;
int man1_y;
int man2_x;
int man2_y;
2023-02-19 17:58:59 +01:00
int num_crates_free;
2023-01-27 17:24:27 +01:00
sok_board_t();
void print_board();
void load(char *_file);
};
2023-02-19 17:58:59 +01:00
typedef struct {
sok_board_t state;
int path_len;
std::string path;
2023-02-19 18:23:59 +01:00
} Node;
2023-02-19 17:58:59 +01:00
2023-02-19 18:23:59 +01:00
int bfs(Node &result);
2023-02-21 14:09:08 +01:00
int dfs(Node &result, int depth, std::vector<Node> history);
2023-02-19 17:58:59 +01:00
2023-01-27 17:24:27 +01:00
#endif