‡CLAN‡さんとモバ友になろう!
日記・サークル・友達・楽しみいっぱい!
-
- 2010/1/6 13:49
- part2
-
- コメント(0)
- 閲覧(32)
-
-
- int *move(int PLAYER)
{
int *pt, *pt1;
pt = &board[0][0];
do pt1 = pt + (int) (rand() / (RAND_MAX + 1.0) * (SIZE + 2) * (SIZE + 2));
while (!(*pt1 == NO_PIECE &&
(*(pt1 - SIZE - 3) == BLACK || *(pt1 - SIZE - 3) == WHITE ||
*(pt1 - SIZE - 2) == BLACK || *(pt1 - SIZE - 2) == WHITE ||
*(pt1 - SIZE - 1) == BLACK || *(pt1 - SIZE - 1) == WHITE ||
*(pt1 - 1) == BLACK || *(pt1 - 1) == WHITE ||
*(pt1 + 1) == BLACK || *(pt1 + 1) == WHITE ||
*(pt1 + SIZE + 1) == BLACK || *(pt1 + SIZE + 1) == WHITE ||
*(pt1 + SIZE + 2) == BLACK || *(pt1 + SIZE + 2) == WHITE ||
*(pt1 + SIZE + 3) == BLACK || *(pt1 + SIZE + 3) == WHITE)));
*pt1 = PLAYER;
return pt1;
}
int check(int PLAYER, int *pt)
{
return 0;
}
void init(void)
{
int i, *pt, *pt1;
pt = &board[0][0];
pt1 = pt + (SIZE + 2)*(SIZE + 2);
do *--pt1 = 0; while (pt1 > pt);
for (pt1 = pt,i = 0;i < SIZE + 2; i++) *pt1++ = WALL;
for (pt1 = pt,i = 0;i < SIZE; i++) *(pt1 += SIZE + 2) = WALL;
for (pt1 = pt + (SIZE + 2)*(SIZE + 2) - 1,i = 0;i < SIZE + 2; i++) *pt1-- = WALL;
for (pt1 = pt + (SIZE + 2)*(SIZE + 2) - 1,i = 0;i < SIZE; i++) *(pt1 -= SIZE + 2) = WALL;
*(pt + ((SIZE + 2)*(SIZE + 2) - 1)/2) = 1;
}
void print_board(void)
{
int i,j;
for (i = 0;i < SIZE + 2; i++)
{
for (j = 0;j < SIZE + 2; j++) {
if (board[i][j] == 0) printf(" ");
else if (board[i][j] == BLACK) printf("(*)");
else if (board[i][j] == WHITE) printf("( )");
else if (board[i][j] == WALL) {
if (i == 0 && j == 0) printf(" ");
else if (i == 0 && j > 0 && j <= SIZE) printf("%3d", j);
else if (i > 0 && i <= SIZE && j == 0) printf("%3d", i);
}
}
printf("\n");
}
}
- int *move(int PLAYER)