home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / pd_share / games / gnugo / c / showbord < prev    next >
Encoding:
Text File  |  1995-03-11  |  6.1 KB  |  284 lines

  1. /*
  2.                 GNU GO - the game of Go (Wei-Chi)
  3.                 Version 1.1   last revised 3-1-89
  4.            Copyright (C) Free Software Foundation, Inc.
  5.                       written by Man L. Li
  6.                       modified by Wayne Iba
  7.                     documented by Bob Webber
  8. */
  9. /*
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation - version 1.
  13.  
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License in file COPYING for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with this program; if not, write to the Free Software
  21. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23. Please report any bug/fix, modification, suggestion to
  24.  
  25. mail address:   Man L. Li
  26.                 Dept. of Computer Science
  27.                 University of Houston
  28.                 4800 Calhoun Road
  29.                 Houston, TX 77004
  30.  
  31. e-mail address: manli@cs.uh.edu         (Internet)
  32.                 coscgbn@uhvax1.bitnet   (BITNET)
  33.                 70070,404               (CompuServe)
  34. */
  35. #include "header.h"
  36. #include <stdio.h>
  37.  
  38. void showboard()
  39. /* show go board */
  40.   {
  41.    int i, j, ii;
  42.  
  43. /* p = 0 for empty ,p = 1 for white piece, p = 2 for black piece */
  44.    printf("   A B C D E F G H J K L M N O P Q R S T\n");
  45. /* row 19 to 17 */
  46.    for (i = 0; i < 3; i++)
  47.      {
  48.       ii = 19 - i;
  49.       printf("%2d",ii);
  50.  
  51.       for (j = 0; j < 19; j++)
  52.     if (p[i][j] == EMPTY)
  53.        printf(" -");
  54.     else if (p[i][j] == WHITE)
  55.         printf(" O");
  56.          else printf(" X");
  57.  
  58.       printf("%2d",ii);
  59.       printf("\n");
  60.      }
  61. /* row 16 */
  62.    printf("16");
  63.  
  64.    for (j = 0; j < 3; j++)
  65.      if (p[3][j] == EMPTY)
  66.     printf(" -");
  67.      else if (p[3][j] == WHITE)
  68.          printf(" O");
  69.       else printf(" X");
  70.  
  71.    if (p[3][3] == 0)
  72.       printf(" +");
  73.    else if (p[3][3] == WHITE)
  74.        printf(" O");
  75.     else printf(" X");
  76.  
  77.    for (j = 4; j < 9; j++)
  78.      if (p[3][j] == EMPTY)
  79.     printf(" -");
  80.      else if (p[3][j] == WHITE)
  81.          printf(" O");
  82.       else printf(" X");
  83.  
  84.    if (p[3][9] == EMPTY)
  85.       printf(" +");
  86.    else if (p[3][9] == WHITE)
  87.        printf(" O");
  88.     else printf(" X");
  89.  
  90.    for (j = 10; j < 15; j++)
  91.      if (p[3][j] == EMPTY)
  92.     printf(" -");
  93.      else if (p[3][j] == WHITE)
  94.          printf(" O");
  95.       else printf(" X");
  96.  
  97.    if (p[3][15] == EMPTY)
  98.       printf(" +");
  99.    else if (p[3][15] == WHITE)
  100.        printf(" O");
  101.     else printf(" X");
  102.  
  103.    for (j = 16; j < 19; j++)
  104.      if (p[3][j] == EMPTY)
  105.     printf(" -");
  106.      else if (p[3][j] == WHITE)
  107.          printf(" O");
  108.       else printf(" X");
  109.  
  110.    printf("16");
  111.    if (umove == 1)
  112.       printf("     Your color: White O\n");
  113.    else
  114.       if (umove == 2)
  115.      printf("     Your color: Black X\n");
  116.       else
  117.      printf("\n");
  118. /* row 15 to 11 */
  119.    for (i = 4; i < 9; i++)
  120.      {
  121.       ii = 19 - i;
  122.       printf("%2d",ii);
  123.  
  124.       for (j = 0; j < 19; j++)
  125.     if (p[i][j] == EMPTY)
  126.        printf(" -");
  127.     else if (p[i][j] == WHITE)
  128.         printf(" O");
  129.          else printf(" X");
  130.  
  131.       printf("%2d",ii);
  132.       if (i == 4)
  133.     {
  134.      if (mymove == 1)
  135.         printf("     My color:   White O\n");
  136.      else
  137.         if (mymove == 2)
  138.            printf("     My color:   Black X\n");
  139.         else
  140.            printf("\n");
  141.        }
  142.       else
  143.      if (i != 8)
  144.         printf("\n");
  145.      else
  146.         printf("     You have captured %d pieces\n", mk);
  147.      }
  148. /* row 10 */
  149.    printf("10");
  150.  
  151.    for (j = 0; j < 3; j++)
  152.      if (p[9][j] == EMPTY)
  153.     printf(" -");
  154.      else if (p[9][j] == WHITE)
  155.          printf(" O");
  156.       else printf(" X");
  157.  
  158.    if (p[9][3] == EMPTY)
  159.       printf(" +");
  160.    else if (p[9][3] == WHITE)
  161.        printf(" O");
  162.     else printf(" X");
  163.  
  164.    for (j = 4; j < 9; j++)
  165.      if (p[9][j] == EMPTY)
  166.     printf(" -");
  167.      else if (p[9][j] == WHITE)
  168.          printf(" O");
  169.       else printf(" X");
  170.  
  171.    if (p[9][9] == EMPTY)
  172.       printf(" +");
  173.    else if (p[9][9] == WHITE)
  174.        printf(" O");
  175.     else printf(" X");
  176.  
  177.    for (j = 10; j < 15; j++)
  178.      if (p[9][j] == EMPTY)
  179.     printf(" -");
  180.      else if (p[9][j] == WHITE)
  181.          printf(" O");
  182.       else printf(" X");
  183.  
  184.    if (p[9][15] == EMPTY)
  185.       printf(" +");
  186.    else if (p[9][15] == WHITE)
  187.        printf(" O");
  188.     else printf(" X");
  189.  
  190.    for (j = 16; j < 19; j++)
  191.      if (p[9][j] == EMPTY)
  192.     printf(" -");
  193.      else if (p[9][j] == WHITE)
  194.          printf(" O");
  195.       else printf(" X");
  196.  
  197.    printf("10");
  198.    printf("     I have captured %d pieces\n", uk);
  199. /* row 9 to 5 */
  200.    for (i = 10; i < 15; i++)
  201.      {
  202.       ii = 19 - i;
  203.       printf("%2d",ii);
  204.  
  205.       for (j = 0; j < 19; j++)
  206.     if (p[i][j] == EMPTY)
  207.        printf(" -");
  208.     else if (p[i][j] == WHITE)
  209.         printf(" O");
  210.          else printf(" X");
  211.  
  212.       printf("%2d",ii);
  213.       printf("\n");
  214.      }
  215. /* row 4 */
  216.    printf(" 4");
  217.  
  218.    for (j = 0; j < 3; j++)
  219.      if (p[15][j] == EMPTY)
  220.     printf(" -");
  221.      else if (p[15][j] == WHITE)
  222.          printf(" O");
  223.       else printf(" X");
  224.  
  225.    if (p[15][3] == EMPTY)
  226.       printf(" +");
  227.    else if (p[15][3] == WHITE)
  228.        printf(" O");
  229.     else printf(" X");
  230.  
  231.    for (j = 4; j < 9; j++)
  232.      if (p[15][j] == EMPTY)
  233.     printf(" -");
  234.      else if (p[15][j] == WHITE)
  235.          printf(" O");
  236.       else printf(" X");
  237.  
  238.    if (p[15][9] == EMPTY)
  239.       printf(" +");
  240.    else if (p[15][9] == WHITE)
  241.        printf(" O");
  242.     else printf(" X");
  243.  
  244.    for (j = 10; j < 15; j++)
  245.      if (p[15][j] == EMPTY)
  246.     printf(" -");
  247.      else if (p[15][j] == WHITE)
  248.          printf(" O");
  249.       else printf(" X");
  250.  
  251.    if (p[15][15] == EMPTY)
  252.       printf(" +");
  253.    else if (p[15][15] == WHITE)
  254.        printf(" O");
  255.     else printf(" X");
  256.  
  257.    for (j = 16; j < 19; j++)
  258.      if (p[15][j] == EMPTY)
  259.     printf(" -");
  260.      else if (p[15][j] == WHITE)
  261.          printf(" O");
  262.       else printf(" X");
  263.  
  264.    printf(" 4");
  265.    printf("\n");
  266. /* row 3 to 1 */
  267.    for (i = 16; i < 19; i++)
  268.      {
  269.       ii = 19 - i;
  270.       printf("%2d",ii);
  271.  
  272.       for (j = 0; j < 19; j++)
  273.     if (p[i][j] == EMPTY)
  274.        printf(" -");
  275.     else if (p[i][j] == WHITE)
  276.         printf(" O");
  277.          else printf(" X");
  278.  
  279.       printf("%2d",ii);
  280.       printf("\n");
  281.      }
  282.    printf("   A B C D E F G H J K L M N O P Q R S T\n\n");
  283.  }  /* end showboard */
  284.