⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 server.h

📁 数据挖掘中de一个算法 hamster的实例
💻 H
字号:
/*----------------------------------------------------------------------  File    : server.h  Contents: hamster control, additional server functions  Author  : Christian Borgelt  History : 16.10.1997 file created            18.10.1997 structure definition moved from hamster.h            19.10.1997 field 'score' added to HAMSTER structure            01.11.1997 parameters x and y removed from hms_create            17.01.1998 counter for crashes against walls added----------------------------------------------------------------------*/#ifndef __HMS_SERVER__#define __HMS_SERVER__#include "maze.h"#include "hamster.h"/*----------------------------------------------------------------------  Preprocessor Definitions----------------------------------------------------------------------*//* --- commands for display function --- */#define HMS_CREATED  0          /* hamster created (0)      */#define HMS_DELETED  1          /* hamster deleted (0)      */#define HMS_MOVED    2          /* hamster moved   (dir)    */#define HMS_TURNED   3          /* hamster turned  (turn)   */#define HMS_FIELD    4          /* field changed   (0)      */#define HMS_SCORED   5          /* score changed   (amount) *//*----------------------------------------------------------------------  Type Definitions----------------------------------------------------------------------*/typedef void (*DISPFN)(HAMSTER *ham, int msg, int arg);/* The display function is called, if something happens that *//* requires an update of the display of the hamster or the maze. *//* The parameter 'msg' identifies the event that occurred, the *//* value of 'arg' depends on the value of 'msg' (see above). */struct hamster {                /* --- a hamster --- */  int    id;                    /* identifier */  int    x, y;                  /* position in maze */  int    dir;                   /* direction (line of sight) */  int    load;                  /* amount of corn in cheeks */  int    corncnt;               /* total corn collected */  int    movecnt;               /* number of moves made */  int    crshcnt;               /* number of crashes against walls */  int    score;                 /* score achieved so far */  MAZE   *maze;                 /* maze the hamster is in */  DISPFN disp;                  /* display function */};                              /* (type HAMSTER) *//*----------------------------------------------------------------------  Functions----------------------------------------------------------------------*/extern HAMSTER* hms_create  (MAZE *maze, int id, int dir, DISPFN disp);extern void     hms_delete  (HAMSTER *hms);extern int      hms_id      (HAMSTER *hms);extern MAZE*    hms_maze    (HAMSTER *hms);extern int      hms_corncnt (HAMSTER *hms);extern int      hms_movecnt (HAMSTER *hms);extern int      hms_crshcnt (HAMSTER *hms);extern int      hms_score   (HAMSTER *hms);/*----------------------------------------------------------------------  Preprocessor Definitions----------------------------------------------------------------------*/#define hms_id(h)           ((h)->id)#define hms_maze(h)         ((h)->maze)#define hms_corncnt(h)      ((h)->corncnt)#define hms_movecnt(h)      ((h)->movecnt)#define hms_crshcnt(h)      ((h)->crshcnt)#define hms_score(h)        ((h)->score)#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -