#pragma once typedef struct { int oil, locator, sphere; } MarkovChain; void generator(struct map_struct maze[HEIGHT][WIDTH], int nx, int ny){ double valA = (double)rand() / RAND_MAX; if(valA < 0.15){ double val = (double)rand() / RAND_MAX; printf("AA= %f\n", val); if (val < 0.07) maze[nx][ny].itom = 2; // 7% else if (val < 0.25) maze[nx][ny].itom = 3; // 25% else if (val < 0.75) maze[nx][ny].itom = 1; // 75% } } void initMaze(struct map_struct maze[HEIGHT][WIDTH]) { for (int i = 0; i < HEIGHT; i++) for (int j = 0; j < WIDTH; j++) maze[i][j].wall = 1; // Заполняем стенами maze[1][1].wall = 0; // Начальная точка } void carveMaze(struct map_struct maze[HEIGHT][WIDTH], int x, int y) { int dx[] = {0, 2, 0, -2}; int dy[] = {2, 0, -2, 0}; for (int i = 0; i < 4; i++) { int dir = rand() % 4; int nx = x + dx[dir], ny = y + dy[dir]; if (nx > 0 && nx < HEIGHT && ny > 0 && ny < WIDTH && maze[nx][ny].wall) { maze[nx][ny].wall = 0; // Открываем клетку generator(maze, nx, ny); maze[x + dx[dir] / 2][y + dy[dir] / 2].wall = 0; // Прореживаем стену carveMaze(maze, nx, ny); } } } void printMaze(struct map_struct maze[HEIGHT][WIDTH]) { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) printf(maze[i][j].wall ? "#" : " "); printf("\n"); } }