home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / Abalone 1.4.2 / src / Strategies.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-21  |  2.4 KB  |  102 lines  |  [TEXT/MPS ]

  1. #ifndef STRATEGIES_H
  2. #define STRATEGIES_H
  3.  
  4.  
  5. #include "Board.h"
  6. #include "Rules.h"
  7. //#include "Arnold.h"
  8.  
  9. #ifndef THINK_C
  10. #include <Types.h>
  11. #endif
  12.  
  13.  
  14. //    A strategy should be a BoardJudgeProc or a MoveJudgeProc.
  15. //    Optionally, a PruneJudgeProc pruning function can be added.
  16. //    See source file Strategies.c for a more elaborate comment.
  17.  
  18. typedef short    (*BoardJudgeProc)    (BoardPtr, short);
  19. typedef short    (*MoveJudgeProc)    (BoardPtr, short, MovePtr);
  20. typedef Boolean    (*PruneJudgeProc)    (short, short, short);
  21.  
  22.  
  23.  
  24. //    You can join the internal competition in this program by implementing this
  25.  
  26. short    TheFinalStrategy (BoardPtr board, short player);    //    your BoardJudgeProc ?
  27.  
  28. //    As an option, you can add this
  29.  
  30. Boolean    TheFinalGardener (short, short, short);                //    your PruneJudgeProc ?
  31.  
  32.  
  33.  
  34. enum _findfunction            //    Toggle for union below
  35. {
  36.     boardMiniMax,            //    boardProc member will be used
  37.     boardMiniMaxNoFliche,    //    boardProc member will be used
  38.     boardMiniMaxGreedy,        //    boardProc member will be used
  39.     moveMiniMax                //    moveProc member will be used
  40. };
  41.  
  42.  
  43. typedef struct _strat {            //    This struct describes a strategy
  44.  
  45.     enum _findfunction    Type;
  46.     
  47.     union                        //    Choise depends on toggle above
  48.     {
  49.         BoardJudgeProc    boardProc;
  50.         MoveJudgeProc    moveProc;
  51.         
  52.     }                    JudgeProc;
  53.     
  54.     PruneJudgeProc        PruneProc;
  55.     
  56. //    The first few moves, resursion won't help much:
  57. //    the enemy is still out of reach (and so are you for the enemy),
  58. //    so a purely postional strategy can be used.
  59. //    Thus, the first few moves can usually be made with a recursion level of 0.
  60. //    This can win some valuable seconds.
  61. //    Think of this as of having an 'opening library'
  62.     
  63.     short                FastOpen;
  64.     #define                kDefaultFast    1
  65.     
  66.     unsigned char        Name [32];
  67.     
  68. } StrategyStruct;
  69.  
  70.  
  71. extern StrategyStruct gStrategies[];
  72.  
  73.  
  74. //    These are some strategies I implemented so far
  75.  
  76. short    Paul (BoardPtr board, short player);                    //    a sample  BoardJudgeProc
  77. short    Ross (BoardPtr board, short player);                    //    a BoardJudgeProc
  78. short    Bill (BoardPtr board, short player, MovePtr move);        //    a MoveJudgeProc
  79. extern
  80. short    Arnold (BoardPtr board, short player);                    //    a BoardJudgeProc
  81. extern
  82. short    Frankie (BoardPtr board, short player);                    //    a BoardJudgeProc
  83. short    Peter (BoardPtr board, short player);                    //    a BoardJudgeProc
  84.  
  85. //    These are the pruning functions
  86.  
  87. Boolean    Sarah (short, short, short);                            //    a PruneJudgeProc
  88.  
  89. #endif
  90.  
  91.  
  92. #ifdef STRATEGIES_C
  93.  
  94. #include "Game.h"
  95. #include "Global.h"
  96.  
  97. #include <Events.h>
  98. #include <StdLib.h>
  99.  
  100. #endif
  101.  
  102.