📄 maze.h
字号:
/*---------------------------------------------------------------------- File : maze.h Contents: maze management Author : Christian Borgelt History : 14.10.1997 file created 15.10.1997 first version completed----------------------------------------------------------------------*/#ifndef __MAZE__#define __MAZE__#include <stdio.h>/*---------------------------------------------------------------------- Preprocessor Definitions----------------------------------------------------------------------*//* --- wall flags --- */#define MZ_EAST (short)0x1000 /* there is a wall to the east */#define MZ_NORTH (short)0x2000 /* there is a wall to the north */#define MZ_WEST (short)0x4000 /* there is a wall to the west */#define MZ_SOUTH (short)0x8000 /* there is a wall to the south */#define MZ_WALLS (short)0xf000 /* mask for wall flags *//* --- field markers --- */#define MZ_MARK0 (short)0x0100 /* first field marker */#define MZ_MARK1 (short)0x0200 /* second field marker */#define MZ_MARK2 (short)0x0400 /* third field marker */#define MZ_HOME (short)0x0800 /* marker for home field */#define MZ_MARKS (short)0x0f00 /* mask for all field markers *//* --- number of items --- */#define MZ_ITEMS (short)0x00ff /* mask for number of items *//*---------------------------------------------------------------------- Type Definitions----------------------------------------------------------------------*/typedef struct { /* --- a maze --- */ int xext, yext; /* x- and y-extension */ int xpos, ypos; /* initial position */ short *map[1]; /* map of the maze */} MAZE; /* (maze) *//*---------------------------------------------------------------------- Functions----------------------------------------------------------------------*/extern MAZE* mz_create (int xext, int yext);extern void mz_delete (MAZE *maze);extern void mz_init (MAZE *maze, double (*randfn)(void), float wallprob, int total, int maxcnt);extern void mz_exts (MAZE *maze, int *x, int *y);extern void mz_getpos (MAZE *maze, int *x, int *y);extern void mz_setpos (MAZE *maze, int x, int y);extern short mz_getfld (MAZE *maze, int x, int y);extern short mz_setfld (MAZE *maze, int x, int y, short mask, short cont);extern int mz_save (MAZE *maze, FILE *file);extern MAZE* mz_load (FILE *file);/*---------------------------------------------------------------------- Preprocessor Definitions----------------------------------------------------------------------*/#define mz_exts(m,x,y) (*(x) = (m)->xext, *(y) = (m)->yext)#define mz_getpos(m,x,y) (*(x) = (m)->xpos, *(y) = (m)->ypos)#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -