#include "board2.h" // 盤面初期化 void init(BOARD *board) { int i; // 盤面初期化 for(i = 0; i < H_SIZE; i++){ // 壁(番兵) if(i <= B_SIZE || i >= H_SIZE - B_SIZE - 1 || i % (B_SIZE + 1) == 0){ board->data[i] = WALL; } // 空 else{ board->data[i] = EMPTY; } } // 初期配置 board->data[D4] = board->data[E5] = WHITE; board->data[D5] = board->data[E4] = BLACK; // 最初の色(黒) board->color = BLACK; } // 盤面表示 void printBoard(BOARD *board) { int i, j; // 黒番 or 白番を出力 printf("%s番\n", board->color == BLACK ? "●" : "○"); // X座標と上罫線出力 printf(" ABCDEFGH\n"); printf(" +----------------+\n"); // 石を出力 for(i = 0; i < B_SIZE; i++){ // Y座標と左罫線出力 printf("%d|", i); for(j = 0; j < B_SIZE; j++){ switch(board->data[(B_SIZE + 1) * i + j + B_SIZE + 2]){ // 黒 case BLACK:printf("●");break; // 白 case WHITE:printf("○");break; // 空白 default:printf(" ");break; } } // 右罫線出力 printf("|\n"); } // 下罫線出力 printf(" +----------------+\n"); } // メイン int main(int argc, char **argv) { BOARD board; init(&board); printBoard(&board); return 0; }