游戏文件主干(test.c):
#include"game.h"
void menu()//游戏菜单
{
printf("************************************************\n");
printf("********** 1.play *********\n");
printf("********** 0.exit *********\n");
printf("************************************************\n");
}
void game()//游戏玩法实现主体(粗略)
{
printf("三子棋:>\n");
char board[LINE][ROW];
Init_checkerboard(board, LINE, ROW);//初始化棋盘
Print_checkerboard(board, LINE, ROW);//打印棋盘
char ret = 0;
while (1)//条件为1可以一直循环
{
Player_game(board, LINE, ROW);//玩家行动
Print_checkerboard(board, LINE, ROW);//玩家行动后的棋盘
ret = Iswin(board, LINE, ROW);//判断是否出现胜负
if (ret != 'c')//出现胜负就跳出循环
{
break;
}
Commputer_game(board, LINE, ROW);//电脑回合
Print_checkerboard(board, LINE, ROW);//电脑行动后的棋盘
ret = Iswin(board, LINE, ROW);//判断是否出现胜负
if (ret != 'c')
{
break;
}
}
if (ret == '*')
{
printf("玩家胜利!\n");
}
else if (ret == '#')
{
printf("电脑胜利!\n");
}
else
{
printf("平局\n");
}
}
int main()//整个源文件的入口
{
int input = 0;
srand((unsigned int)time(NULL));//电脑下棋的随机数
do
{
menu();
printf("请选择:>");
scanf("%d", &input);
switch (input)