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

📄 bridgit.h

📁 数据挖掘中的bridgit算法的例子。 非常经典
💻 H
字号:
/*----------------------------------------------------------------------  File    : bridgit.h  Contents: bridg-it game with computer player  Author  : Christian Borgelt  History : 29.05.2001 file created            01.06.2001 first version completed----------------------------------------------------------------------*/#ifndef __BRIDGIT__#define __BRIDGIT__#include <stdio.h>#include "matrix.h"/*----------------------------------------------------------------------  Preprocessor Definitions----------------------------------------------------------------------*/#define BI_MINSIZE  2           /* minimum board size */#define BI_MAXSIZE  127         /* maximum board size */#define BI_HORZ     0x00000001  /* horizontal bridge / player */#define BI_VERT     0x00000002  /* vertical   bridge / player */#define BI_NONE     0           /* no bridge (or game is lost) */#define BI_BOARD    0           /* show the board *//*----------------------------------------------------------------------  Type Definitions----------------------------------------------------------------------*/typedef struct {                /* --- a bridg-it game --- */  int    size;                  /* number of points on the panels */  int    ptcnt;                 /* number of crossing points */  MATRIX *horz, *vert;          /* matrices of coefficients and */  double *vec;                  /* input vector of current equations */  MATRIX *tmp;                  /* temporary matrix for internal use */  double *sol;                  /* solution of the equation system */  int    *states;               /* states of the crossing points */  int    *buf;                  /* buffer for move selection */  int    mvcnt;                 /* number of moves made */  int    curr;                  /* current number of moves */  int    moves[1];              /* moves made in the game */} BRIDGIT;                      /* (bridg-it game) *//*----------------------------------------------------------------------  Bridge Functions----------------------------------------------------------------------*/extern int      bi_bridge (int player, int col, int row);extern int      bi_player (int bridge);extern int      bi_col    (int bridge);extern int      bi_row    (int bridge);extern int      bi_dir    (int bridge);extern int      bi_opp    (int player);/*----------------------------------------------------------------------  Bridg-it Functions----------------------------------------------------------------------*/extern BRIDGIT* bi_create (int size);extern void     bi_delete (BRIDGIT *bi);extern void     bi_init   (BRIDGIT *bi);extern int      bi_size   (BRIDGIT *bi);extern int      bi_hint   (BRIDGIT *bi, int player,                           double randfn (void));extern void     bi_build  (BRIDGIT *bi, int bridge);extern int      bi_move   (BRIDGIT *bi, int move);extern int      bi_mvcnt  (BRIDGIT *bi);extern int      bi_curr   (BRIDGIT *bi);extern int      bi_state  (BRIDGIT *bi, int col, int row);extern int      bi_undo   (BRIDGIT *bi);extern int      bi_redo   (BRIDGIT *bi);extern int      bi_save   (BRIDGIT *bi, FILE *file);extern BRIDGIT* bi_load   (FILE *file);#ifndef NDEBUGextern void     bi_show   (BRIDGIT *bi, int player);#endif/*----------------------------------------------------------------------  Preprocessor Definitions----------------------------------------------------------------------*/#define bi_bridge(p,c,r)  (((c) << 16) | ((r) << 8) | (p))#define bi_player(b)      ((b) & (BI_HORZ|BI_VERT))#define bi_col(b)         (((b) >> 16) & 0x00ff)#define bi_row(b)         (((b) >>  8) & 0x00ff)#define bi_dir(b)         (((b) & (BI_HORZ|BI_VERT)) ^ \                          ((((b) >> 8) & 1) ? 0 : (BI_HORZ|BI_VERT)))#define bi_opp(b)         ((b) ^ (BI_HORZ|BI_VERT))#define bi_size(b)        ((b)->size)#define bi_mvcnt(b)       ((b)->mvcnt)#define bi_curr(b)        ((b)->curr)#define bi_move(b,m)      ((b)->moves[m])#ifdef NDEBUG#define bi_show(b,p)#endif#endif

⌨️ 快捷键说明

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