home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume28 / ldb / part01 / board.c next >
Encoding:
C/C++ Source or Header  |  1992-03-15  |  2.1 KB  |  73 lines

  1. /* board.c        8/3/91
  2.  *
  3.  * Copyright 1991  Perry R. Ross
  4.  *
  5.  * Permission to use, copy, modify, and distribute this software and its
  6.  * documentation without fee is hereby granted, subject to the restrictions
  7.  * detailed in the README file, which is included here by reference.
  8.  * Any other use requires written permission from the author.  This software
  9.  * is distributed "as is" without any warranty, including any implied
  10.  * warranties of merchantability or fitness for a particular purpose.
  11.  * The author shall not be liable for any damages resulting from the
  12.  * use of this software.  By using this software, the user agrees
  13.  * to these terms.
  14.  */
  15.  
  16. #include "ldb.h"
  17.  
  18. /*----------------------------------------------------------------------
  19.  *    newboard -- set up a board array for a new game
  20.  *
  21.  * This function initializes a board array so that it is set up
  22.  * properly for a new game.  It is passed two characters that are
  23.  * used to draw the pieces for the board.  C1 is the color for the
  24.  * upbound player, and c2 is the color for the downbound player.
  25.  *----------------------------------------------------------------------
  26.  */
  27.  
  28. newboard(b,c1,c2)
  29. board b;
  30. char c1, c2;
  31. {
  32. int i;
  33.  
  34. for (i = 0; i < BOARDSIZE; i++) {
  35.     b[i].qty = 0;            /* init to empty */
  36.     b[i].color = 'x';        /* init to invalid color */
  37.     }
  38. b[1].qty = 2;                /* 2 c1's on 1 point */
  39. b[1].color = c1;
  40. b[6].qty = 5;                /* 5 c2's on 6 point */
  41. b[6].color = c2;
  42. b[8].qty = 3;                /* 3 c2's on 8 point */
  43. b[8].color = c2;
  44. b[12].qty = 5;                /* 5 c1's on 12 point */
  45. b[12].color = c1;
  46. b[13].qty = 5;                /* 5 c2's on 13 point */
  47. b[13].color = c2;
  48. b[17].qty = 3;                /* 3 c1's on 17 point */
  49. b[17].color = c1;
  50. b[19].qty = 5;                /* 5 c1's on 19 point */
  51. b[19].color = c1;
  52. b[24].qty = 2;                /* 2 c2's on 24 point */
  53. b[24].color = c2;
  54. }
  55.  
  56.  
  57. /*----------------------------------------------------------------------
  58.  *    copyboard -- make a copy a board array
  59.  *
  60.  * This is a convenience function that copies an entire board. The
  61.  * source is given as "f", and the destination as "t".
  62.  *----------------------------------------------------------------------
  63.  */
  64.  
  65. copyboard(f,t)
  66. board f, t;
  67. {
  68. int i;
  69.  
  70. for (i = 0; i < BOARDSIZE; i++)
  71.     t[i] = f[i];
  72. }
  73.