home *** CD-ROM | disk | FTP | other *** search
/ Aminet 10 / aminetcdnumber101996.iso / Aminet / game / board / Backgammon.lha / BackMenu.c < prev    next >
C/C++ Source or Header  |  1995-07-01  |  6KB  |  146 lines

  1. /********************************************************************/
  2. /*                                                                  */
  3. /*  Hoser BackGammon version 1.0                                    */
  4. /*                                                                  */
  5. /*      Robert Pfister                                              */
  6. /*                                                                  */
  7. /*      Rfd#3 Box 2340                home:(207)-873-3520           */
  8. /*      Waterville, Maine 04901                                     */
  9. /*                                                                  */
  10. /*      Pfister_rob%dneast@dec.decwrl                               */
  11. /*                                                                  */
  12. /*                                                                  */
  13. /*  Copyright  June,1987 all rights reserved.                       */
  14. /*                                                                  */
  15. /*  This program will play a game of backgammon at the novice level */
  16. /*                                                                  */
  17. /*  The code is in 4 parts...                                       */
  18. /*                                                                  */
  19. /*       1) back.c     - main driver                                */
  20. /*       2) eval.c     - evaluation of moves                        */
  21. /*   /   3) backscn.c  - screen stuff..                             */
  22. /* \/    4) backmenu.c - menu stuff, help text, and ``decoder''     */
  23. /*                                                                  */
  24. /* this was compiled under Manx 3.20a, using long integers          */
  25. /*                                                                  */
  26. /********************************************************************/
  27.  
  28. #include "exec/types.h"
  29. #include "proto/intuition.h"
  30.  
  31. char *Help[] =
  32.        {
  33.        "Help\0",
  34.        "To move a piece, click on it with the left mouse button,   \n",
  35.        "then click on the spike that you want to move the piece.   \n",
  36.        "                                                           \n",
  37.        "The `bar' is the center strip of the board.                \n",
  38.        "                                                           \n",
  39.        "If your move is invalid, an error message will be displayed\n",
  40.        "in the menu strip.                                         \n",
  41.        "                                                           \n",
  42.        "To `cast off' pieces, double click on the piece desired    \n",
  43.        "                                                           \n",      
  44.        "If you cannot move, click on your dice.                    \n",
  45.        "                                                           \n",
  46.        "The number that appears below the menu bar is the number   \n",
  47.        "of the position that's  being evaluated.  For doubles      \n",
  48.        "this number can reach around 5000,  so be patient          \n",
  49.        "                                                           \n",
  50.        "`Redo Move' returns board to the start of the move         \n",
  51.        "`Take Back' will back up one move                          \n",
  52.  
  53.        };
  54.  
  55. int NumHelp=18;
  56.  
  57. char *credits[] = {
  58.   "Credits\0",
  59.   "Hoser BackGammon    Copyright June 1987  Robert Pfister\n",
  60.   "\n",
  61.   "Written in Aztec 'C' 3.20  as an A.I. course project.  Uses\n",
  62.   "home-brewed heuristics to play like I would.\n",
  63.   "\n",
  64.   "Snail:        {donations accepted..I suppose}\n",
  65.   "    Robert Pfister\n",
  66.   "    Rfd#3 box 2340\n",
  67.   "    Waterville, Maine 04901        phone: 207-873-3520\n",
  68.   "\n",
  69.   "or E-Mail:   pfister_rob%dneast.dec@decwrl.dec.com\n",
  70.   "\n",
  71.   "Freely Distributable (if I'm credited with the original version)\n",
  72.   "\n",
  73.   "Extensively revised by E.M.Greene     4/11/92\n",
  74.   "Converted to SAS C 6.2         2/12/93\n"
  75.   "Upgraded some more w/SASC 6.5    11/18/94\n"
  76.   "More recent upgrade             7/ 1/95\n"
  77.   };
  78.  
  79. #define NumCredits    18
  80.  
  81. struct IntuiText IText[]=
  82.  {
  83.   {0,1,JAM1,CHECKWIDTH,0,NULL,"New Game "},    /*  0 */
  84.   {0,1,JAM1,CHECKWIDTH,0,NULL,"About    "},    /*  1 */
  85.   {0,1,JAM1,CHECKWIDTH,0,NULL,"Quit     "},    /*  2 */
  86.   {0,1,JAM1,CHECKWIDTH,0,NULL,"Help     "},    /*  3 */
  87.   {0,1,JAM1,CHECKWIDTH,0,NULL,"Back up  "},    /*  4 */
  88.   {0,1,JAM1,CHECKWIDTH,0,NULL,"Redo Move"}    /*  5 */
  89.   };
  90.  
  91. struct MenuItem menu_item[] = {
  92.   { &menu_item[1],              /* newgame 0: */
  93.     0,0,133,9,(ITEMTEXT|ITEMENABLED|HIGHCOMP|COMMSEQ),
  94.     NULL, (APTR) &IText[0], NULL,'N',NULL},
  95.   { &menu_item[2],              /* about  1: */
  96.     0,9,133,9,(ITEMTEXT|ITEMENABLED|HIGHCOMP|COMMSEQ),
  97.     NULL,(APTR) &IText[1],NULL,'I',NULL},
  98.   { NULL,                  /* quit  2: */
  99.     0,18,133,9,(ITEMTEXT|ITEMENABLED|HIGHCOMP|COMMSEQ),
  100.     NULL,(APTR) &IText[2],NULL,'Q',NULL},
  101.   { &menu_item[4],              /* help  3: */
  102.     0,0,133,9,(ITEMTEXT|ITEMENABLED|HIGHCOMP|COMMSEQ),
  103.     NULL,(APTR) &IText[3],NULL,'H',NULL},
  104.   { &menu_item[5],              /* Takeback 4:  */
  105.     0,9,133,9,(ITEMTEXT|ITEMENABLED|HIGHCOMP|COMMSEQ),
  106.     NULL,(APTR) &IText[4],NULL,'X',NULL},
  107.   { NULL,                  /* move hint  5: */
  108.     0,18,133,9,(ITEMTEXT|ITEMENABLED|HIGHCOMP|COMMSEQ),
  109.     NULL,(APTR) &IText[5],NULL,'B',NULL}
  110. };
  111.  
  112. struct Menu MyMenu[] = {
  113.   { &MyMenu[1], 0,0,83,0, MENUENABLED, "Project", &menu_item[0]},
  114.   { NULL,    80,0,80,0, MENUENABLED, "Cheating",&menu_item[3]}};
  115.  
  116. void    Restart(void);
  117. void    TextScreen(char **text, int lines);
  118. void    RecallMove(int n);
  119.  
  120. int DoMenu(int x)
  121. {
  122.   switch (x) {
  123.     case  31: /* new game */
  124.       Restart();
  125.       return(1);
  126.       break;
  127.     case  41: /* put up a window with the credits in it */
  128.       TextScreen(credits,NumCredits);
  129.       break;
  130.     case  51: /* quit */
  131.       return(-1);
  132.       break;
  133.     case 131: /* do it for help as well */
  134.       TextScreen(Help,NumHelp);
  135.       break;
  136.     case 141: /* take back a full move */
  137.       RecallMove(-1); 
  138.       break;
  139.     case 151:
  140.       RecallMove(0);
  141.       break;            
  142.     default:break;
  143.   }
  144.   return(0);
  145. }
  146.