当前位置:首页 > 代码 > 正文

黑白棋c语言代码(黑白棋源码)

admin 发布:2022-12-19 02:54 141


本篇文章给大家谈谈黑白棋c语言代码,以及黑白棋源码对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

c语言小程序--黑白棋

你想做什么?

人人对战的代码我有,但是人机对战的AI写不好

是个国际难题

//=====othello=====

#includeiostream

#includecstdio

using namespace std;

int board[8][8],saveboard[60][8][8];

int cx,cy,col,pass,empty,black,white;

void init(){ //initialization

memset(board,-1,sizeof(board));

board[3][3]=0;

board[3][4]=1;

board[4][4]=0;

board[4][3]=1;

col=0;

pass=0;

empty=60;

black=2;

white=2;

}

int input(){

char s[1000]="";

scanf("%s",s);

if(s[0]='a' s[0]='h')

cy=s[0]-'a';

else if(s[0]='A' s[0]='H')

cy=s[0]-'A';

else return 0;

if(s[1]='1' s[1]='8'){

cx=s[1]-'1';

return 1;

}

return 0;

}

int judge(int x,int y){

int i,j,temp;

temp=(col+1)%2;

//left up

if(board[x-1][y-1]==temp){

for(i=x-1,j=y-1; i=0 j=0; i--,j--){

if(board[i][j]0) break;

if(col==board[i][j]) return 1;

}

}

//up

if(board[x-1][y]==temp){

for(i=x-1; i=0; i--){

if(board[i][y]0) break;

if(col==board[i][y]) return 1;

}

}

//right up

if(board[x-1][y+1]==temp){

for(i=x-1,j=y+1; i=0 j8; i--,j++){

if(board[i][j]0) break;

if(col==board[i][j]) return 1;

}

}

//right

if(board[x][y+1]==temp){

for(j=y+1; j8; j++){

if(board[x][j]0) break;

if(col==board[x][j]) return 1;

}

}

//right down

if(board[x+1][y+1]==temp){

for(i=x+1,j=y+1; i8 j8; i++,j++){

if(board[i][j]0) break;

if(col==board[i][j]) return 1;

}

}

//down

if(board[x+1][y]==temp){

for(i=x+1; i8; i++){

if(board[i][y]0) break;

if(col==board[i][y]) return 1;

}

}

//left down

if(board[x+1][y-1]==temp){

for(i=x+1,j=y-1; i8 j=0; i++,j--){

if(board[i][j]0) break;

if(col==board[i][j]) return 1;

}

}

//left

if(board[x][y-1]==temp){

for(j=y-1; j=0; j--){

if(board[x][j]0) break;

if(col==board[x][j]) return 1;

}

}

return 0;

}

void move(int x,int y){

int i,j,temp,count;

temp=(col+1)%2;

count=0;

//left up

if(board[x-1][y-1]==temp){

for(i=x-1,j=y-1; i=0 j=0; i--,j--){

if(board[i][j]0) break;

if(col==board[i][j]){

while(i!=x){

board[++i][++j]=col;

count++;

}

count--;

break;

}

}

}

//up

if(board[x-1][y]==temp){

for(i=x-1; i=0; i--){

if(board[i][y]0) break;

if(col==board[i][y]){

while(i!=x){

board[++i][y]=col;

count++;

}

count--;

break;

}

}

}

//right up

if(board[x-1][y+1]==temp){

for(i=x-1,j=y+1; i=0 j8; i--,j++){

if(board[i][j]0) break;

if(col==board[i][j]){

while(i!=x){

board[++i][--j]=col;

count++;

}

count--;

break;

}

}

}

//right

if(board[x][y+1]==temp){

for(j=y+1; j8; j++){

if(board[x][j]0) break;

if(col==board[x][j]){

while(j!=y){

board[x][--j]=col;

count++;

}

count--;

break;

}

}

}

//right down

if(board[x+1][y+1]==temp){

for(i=x+1,j=y+1; i8 j8; i++,j++){

if(board[i][j]0) break;

if(col==board[i][j]){

while(i!=x){

board[--i][--j]=col;

count++;

}

count--;

break;

}

}

}

//down

if(board[x+1][y]==temp){

for(i=x+1; i8; i++){

if(board[i][y]0) break;

if(col==board[i][y]){

while(i!=x){

board[--i][y]=col;

count++;

}

count--;

break;

}

}

}

//left down

if(board[x+1][y-1]==temp){

for(i=x+1,j=y-1; i8 j=0; i++,j--){

if(board[i][j]0) break;

if(col==board[i][j]){

while(i!=x){

board[--i][++j]=col;

count++;

}

count--;

break;

}

}

}

//left

if(board[x][y-1]==temp){

for(j=y-1; j=0; j--){

if(board[x][j]0) break;

if(col==board[x][j]){

while(j!=y){

board[x][++j]=col;

count++;

}

count--;

break;

}

}

}

board[x][y]=col;

if(col){

black+=count;

white-=count;

black++;

}

else{

black-=count;

white+=count;

white++;

}

empty--;

}

void output(){

char c;

printf(" ");

for(int i=0; i8; i++){

c='A'+i;

printf("%2c",c);

}

printf("\n");

for(int i=0; i8; i++){

printf("%d",i+1);

for(int j=0; j8; j++){

if(board[i][j]==-1)

c=' ';

else if(board[i][j]==0)

c='O';

else

c='X';

printf("%2c",c);

}

printf("\n");

}

printf("Black:%3d White:%3d\n",black,white);

}

int passjudge(){

int f=0;

for(int i=0; i8; i++)

for(int j=0; j8; j++)

if(board[i][j]0)

f+=judge(i,j);

return f;

}

void startprint(){

printf("1、New game\n2、setboard\n0、Exit\n");

}

void pvp(){

while(empty pass2){

//black or white

col++;

col%=2;

output();

//input

if(!input()){

if(!passjudge()){

printf("Pass!\n");

pass++;

}

else {

col++;

printf("No pass!\nPlease input right stone!\n");

}

continue;

}

if(judge(cx,cy)){

move(cx,cy);

pass=0;

}

else{

col++;

printf("Miss stone\n");

}

}

output();

if(blackwhite)

printf("Black Win!\n");

else if(blackwhite)

printf("White Win!\n");

else

printf("Draw Game!\n");

startprint();

}

void setboard(){

char c;

for(int i=0; i8; i++)

for(int j=0; scanf("%c",c) c!='\n'; j++){

if(j=8) continue;

if(c=='o' c=='O')

board[i][j]=0;

else if(c=='x' c=='X')

board[i][j]=1;

}

printf("White start or Black start?\n(W/B)");

scanf("%c",c);

if(c=='w' || c=='W')

col=1;

if(c=='b' || c=='B')

col=0;

}

int main(int argc, char* argv[]){

int n;

startprint();

while(scanf("%d",n) n){

init();

if(n==1)

pvp();

if(n==2){

setboard();

pvp();

}

}

return 0;

}

求一个C语言的黑白棋程序

#include "graphics.h" /*图形系统头文件*/

#define LEFT 0x4b00 /*光标左键值*/

#define RIGHT 0x4d00 /*光标右键值*/

#define DOWN 0x5000 /*光标下键值*/

#define UP 0x4800 /*光标上键值*/

#define ESC 0x011b /* ESC键值*/

#define ENTER 0x1c0d /* 回车键值*/

int a[8][8]={0},key,score1,score2;/*具体分数以及按键与存放棋子的变量*/

char playone[3],playtwo[3];/*两个人的得分转换成字符串输出*/

void playtoplay(void);/*人人对战函数*/

void DrawQp(void);/*画棋盘函数*/

void SetPlayColor(int x);/*设置棋子第一次的颜色*/

void MoveColor(int x,int y);/*恢复原来棋盘状态*/

int QpChange(int x,int y,int z);/*判断棋盘的变化*/

void DoScore(void);/*处理分数*/

void PrintScore(int n);/*输出成绩*/

void playWin(void);/*输出胜利者信息*/

/******主函数*********/

void main(void)

{

int gd=DETECT,gr;

initgraph(gd,gr,"c:\\tc"); /*初始化图形系统*/

DrawQp();/*画棋盘*/

playtoplay();/*人人对战*/

getch();

closegraph();/*关闭图形系统*/

}

void DrawQp()/*画棋盘*/

{

int i,j;

score1=score2=0;/*棋手一开始得分都为0*/

setbkcolor(BLUE);

for(i=100;i=420;i+=40)

{

line(100,i,420,i);/*画水平线*/

line(i,100,i,420); /*画垂直线*/

}

setcolor(0);/*取消圆周围的一圈东西*/

setfillstyle(SOLID_FILL,15);/*白色实体填充模式*/

fillellipse(500,200,15,15); /*在显示得分的位置画棋*/

setfillstyle(SOLID_FILL,8); /*黑色实体填充模式*/

fillellipse(500,300,15,15);

a[3][3]=a[4][4]=1;/*初始两个黑棋*/

a[3][4]=a[4][3]=2;/*初始两个白棋*/

setfillstyle(SOLID_FILL,WHITE);

fillellipse(120+3*40,120+3*40,15,15);

fillellipse(120+4*40,120+4*40,15,15);

setfillstyle(SOLID_FILL,8);

fillellipse(120+3*40,120+4*40,15,15);

fillellipse(120+4*40,120+3*40,15,15);

score1=score2=2; /*有棋后改变分数*/

DoScore();/*输出开始分数*/

}

void playtoplay()/*人人对战*/

{

int x,y,t=1,i,j,cc=0;

while(1)/*换棋手走棋*/

{

x=120,y=80;/*每次棋子一开始出来的坐标,x为行坐标,y为列坐标*/

while(1) /*具体一个棋手走棋的过程*/

{

PrintScore(1);/*输出棋手1的成绩*/

PrintScore(2);/*输出棋手2的成绩*/

SetPlayColor(t);/*t变量是用来判断棋手所执棋子的颜色*/

fillellipse(x,y,15,15);

key=bioskey(0);/*接收按键*/

if(key==ESC)/*跳出游戏*/

break;

else

if(key==ENTER)/*如果按键确定就可以跳出循环*/

{

if(y!=80a[(x-120)/40][(y-120)/40]!=1

a[(x-120)/40][(y-120)/40]!=2)/*如果落子位置没有棋子*/

{

if(t%2==1)/*如果是棋手1移动*/

a[(x-120)/40][(y-120)/40]=1;

else/*否则棋手2移动*/

a[(x-120)/40][(y-120)/40]=2;

if(!QpChange(x,y,t))/*落子后判断棋盘的变化*/

{

a[(x-120)/40][(y-120)/40]=0;/*恢复空格状态*/

cc++;/*开始统计尝试次数*/

if(cc=64-score1-score2) /*如果尝试超过空格数则停步*/

{

MoveColor(x,y);

fillellipse(x,y,15,15);

break;

}

else

continue;/*如果按键无效*/

}

DoScore();/*分数的改变*/

break;/*棋盘变化了,则轮对方走棋*/

}

else/*已经有棋子就继续按键*/

continue;

}

else /*四个方向按键的判断*/

if(key==LEFTx120)/*左方向键*/

{

MoveColor(x,y);

fillellipse(x,y,15,15);

SetPlayColor(t);

x-=40;

fillellipse(x,y,15,15);

}

else

if(key==RIGHTx400y80)/*右方向键*/

{

MoveColor(x,y);

fillellipse(x,y,15,15);

SetPlayColor(t);

x+=40;

fillellipse(x,y,15,15);

}

else

if(key==UPy120)/*上方向键*/

{

MoveColor(x,y);

fillellipse(x,y,15,15);

SetPlayColor(t);

y-=40;

fillellipse(x,y,15,15);

}

else

if(key==DOWNy400)/*下方向键*/

{

MoveColor(x,y);

fillellipse(x,y,15,15);

SetPlayColor(t);

y+=40;

fillellipse(x,y,15,15);

}

}

if(key==ESC)/*结束游戏*/

break;

if((score1+score2)==64||score1==0||score2==0)/*格子已经占满或一方棋子为0判断胜负*/

{

playWin();/*输出最后结果*/

break;

}

t=t%2+1; /*一方走后,改变棋子颜色即轮对方走*/

cc=0; /*计数值恢复为0*/

} /*endwhile*/

}

void SetPlayColor(int t)/*设置棋子颜色*/

{

if(t%2==1)

setfillstyle(SOLID_FILL,15);/*白色*/

else

setfillstyle(SOLID_FILL,8);/*灰色*/

}

void MoveColor(int x,int y)/*走了一步后恢复原来格子的状态*/

{

if(y100)/*如果是从起点出发就恢复蓝色*/

setfillstyle(SOLID_FILL,BLUE);

else/*其他情况如果是1就恢复白色棋子,2恢复黑色棋子,或恢复蓝色棋盘*/

switch(a[(x-120)/40][(y-120)/40])

{

case 1:

setfillstyle(SOLID_FILL,15);break; /*白色*/

case 2:

setfillstyle(SOLID_FILL,8);break; /*黑色*/

default:

setfillstyle(SOLID_FILL,BLUE); /*蓝色*/

}

}

int QpChange(int x,int y,int t)/*判断棋盘的变化*/

{

int i,j,k,kk,ii,jj,yes;

yes=0;

i=(x-120)/40; /*计算数组元素的行下标*/

j=(y-120)/40; /*计算数组元素的列下标*/

SetPlayColor(t);/*设置棋子变化的颜色*/

/*开始往8个方向判断变化*/

if(j6)/*往右边*/

{

for(k=j+1;k8;k++)

if(a[k]==a[j]||a[k]==0)/*遇到自己的棋子或空格结束*/

break;

if(a[k]!=0k8)

{

for(kk=j+1;kkkk8;kk++)/*判断右边*/

{

a[kk]=a[j]; /*改变棋子颜色*/

fillellipse(120+i*40,120+kk*40,15,15);

}

if(kk!=j+1) /*条件成立则有棋子改变过颜色*/

yes=1;

}

}

if(j1)/*判断左边*/

{

for(k=j-1;k=0;k--)

if(a[k]==a[j]||!a[k])

break;

if(a[k]!=0k=0)

{

for(kk=j-1;kkkk=0;kk--)

{

a[kk]=a[j];

fillellipse(120+i*40,120+kk*40,15,15);

}

if(kk!=j-1)

yes=1;

}

}

if(i6)/*判断下边*/

{

for(k=i+1;k8;k++)

if(a[k][j]==a[j]||!a[k][j])

break;

if(a[k][j]!=0k8)

{

for(kk=i+1;kkkk8;kk++)

{

a[kk][j]=a[j];

fillellipse(120+kk*40,120+j*40,15,15);

}

if(kk!=i+1)

yes=1;

}

}

if(i1)/*判断上边*/

{

for(k=i-1;k=0;k--)

if(a[k][j]==a[j]||!a[k][j])

break;

if(a[k][j]!=0k=0)

{

for(kk=i-1;kkkk=0;kk--)

{

a[kk][j]=a[j];

fillellipse(120+kk*40,120+j*40,15,15);

}

if(kk!=i-1)

yes=1;

}

}

if(i1j6)/*右上*/

{

for(k=i-1,kk=j+1;k=0kk8;k--,kk++)

if(a[k][kk]==a[j]||!a[k][kk])

break;

if(a[k][kk]k=0kk8)

{

for(ii=i-1,jj=j+1;iikk=0;ii--,jj++)

{

a[ii][jj]=a[j];

fillellipse(120+ii*40,120+jj*40,15,15);

}

if(ii!=i-1)

yes=1;

}

}

if(i6j1)/*左下*/

{

for(k=i+1,kk=j-1;k8kk=0;k++,kk--)

if(a[k][kk]==a[j]||!a[k][kk])

break;

if(a[k][kk]!=0k8kk=0)

{

for(ii=i+1,jj=j-1;iikk8;ii++,jj--)

{

a[ii][jj]=a[j];

fillellipse(120+ii*40,120+jj*40,15,15);

}

if(ii!=i+1)

yes=1;

}

}

if(i1j1)/*左上*/

{

for(k=i-1,kk=j-1;k=0kk=0;k--,kk--)

if(a[k][kk]==a[j]||!a[k][kk])

break;

if(a[k][kk]!=0k=0kk=0)

{

for(ii=i-1,jj=j-1;iikk=0;ii--,jj--)

{

a[ii][jj]=a[j];

fillellipse(120+ii*40,120+jj*40,15,15);

}

if(ii!=i-1)

yes=1;

}

}

if(i6j6)/* 右下*/

{

for(k=i+1,kk=j+1;kk8kk8;k++,kk++)

if(a[k][kk]==a[j]||!a[k][kk])

break;

if(a[k][kk]!=0kk8k8)

{

for(ii=i+1,jj=j+1;iikk8;ii++,jj++)

{

a[ii][jj]=a[j];

fillellipse(120+ii*40,120+jj*40,15,15);

}

if(ii!=i+1)

yes=1;

}

}

return yes;/*返回是否改变过棋子颜色的标记*/

}

void DoScore()/*处理分数*/

{

int i,j;

score1=score2=0;/*重新开始计分数*/

for(i=0;i8;i++)

for(j=0;j8;j++)

if(a[j]==1)/*分别统计两个人的分数*/

score1++;

else

if(a[j]==2)

score2++;

}

void PrintScore(int playnum)/*输出成绩*/

{

if(playnum==1)/*清除以前的成绩*/

{

setfillstyle(SOLID_FILL,BLUE);

bar(550,100,640,400);

}

setcolor(RED);

settextstyle(0,0,4);/*设置文本输出样式*/

if(playnum==1)/*判断输出哪个棋手的分,在不同的位置输出*/

{

sprintf(playone,"%d",score1);

outtextxy(550,200,playone);

}

else

{

sprintf(playtwo,"%d",score2);

outtextxy(550,300,playtwo);

}

setcolor(0);

}

void playWin()/*输出最后的胜利者结果*/

{

settextstyle(0,0,4);

setcolor(12);

if(score2score1)/*开始判断最后的结果*/

outtextxy(100,50,"black win!");

else

if(score2score1)

outtextxy(100,50,"white win!");

else

outtextxy(60,50,"you all win!");

}

C语言编制黑白棋游戏:

我写的人机对战的:

#include stdio.h

#include ctype.h

#define SIZE 8

void display(char board[][SIZE]);

int valid_moves(char board[][SIZE],int moves[][SIZE],char player);

void make_move(char board[][SIZE],int row,int col,char player);

void computer_move(char board[][SIZE],int moves[][SIZE],char player);

int get_score(char board[][SIZE],char player);

int best_move(char board[][SIZE],int moves[][SIZE],char player);

void main()

{

char board[SIZE][SIZE]={0};

int moves[SIZE][SIZE]={0};

int row=0;

int col=0;

int no_of_games=0;

int no_of_moves=0;

int invalid_moves=0;

int comp_score=0;

int user_score=0;

char y=0;

char x=0;

char again=0;

int player=0;

printf("\nREVERSI\n\n");

printf("You can go first on the first game,then we will take truns.\n");

printf(" You will be white - (0)\n I will be black - (@).\n");

printf("Select a square for your move by typing a digit for the row\n"

"and a letter for the column with no spaces between.\n");

printf("\nGood luck! press Enter to start.\n");

scanf("%c",again);

do

{

player=++no_of_games%2;

no_of_moves=4;

for(row=0;rowSIZE;row++)

for(col=0;colSIZE;col++)

board[row][col]=' ';

board[SIZE/2-1][SIZE/2-1]=board[SIZE/2][SIZE/2]='0';

board[SIZE/2-1][SIZE/2]=board[SIZE/2][SIZE/2-1]='@';

do

{

display(board);

if(player++%2)

{

if(valid_moves(board,moves,'0'))

{

for(;;)

{

fflush(stdin);

printf("Please enter your move (row column): ");

scanf("%d%c",x,y);

y=tolower(y)-'a';

x--;

if(x=0y=0xSIZEySIZEmoves[x][y])

{

make_move(board,x,y,'0');

no_of_moves++;

break;

}

else

printf("Not a valid move,try again.\n");

}

}

else

if(++invalid_moves2)

{

fflush(stdin);

printf("\nYou have to pass,press return");

scanf("%c",again);

}

else

printf("\nNeither of us can go, so the game is over.\n");

}

else

{

if(valid_moves(board,moves,'@'))

{

invalid_moves=0;

computer_move(board,moves,'@');

no_of_moves++;

}

else

{

if(++invalid_moves2)

printf("\nI have to pass, your go\n");

else

printf("\nNeither of us can go, so the game is over.\n");

}

}

}while(no_of_movesSIZE*SIZEinvalid_moves2);

display(board);

comp_score=user_score=0;

for(row=0;rowSIZE;row++)

for(col=0;colSIZE;col++)

{

comp_score+=board[row][col]=='@';

user_score+=board[row][col]=='0';

}

printf("The final score is:\n");

printf("Computer %d\n User %d\n\n",comp_score,user_score);

fflush(stdin);

printf("Do you want to play again (y/n): ");

scanf("%c",again);

}while(tolower(again)=='y');

printf("\nGoodbye\n");

}

void display(char board[][SIZE])

{

int row=0;

int col=0;

char col_label='a';

printf("\n ");

for(col=0;colSIZE;col++)

printf(" %c",col_label+col);

printf("\n");

for(row=0;rowSIZE;row++)

{

printf(" +");

for(col=0;colSIZE;col++)

printf("---+");

printf("\n%2d|",row+1);

for(col=0;colSIZE;col++)

printf(" %c |",board[row][col]);

printf("\n");

}

printf(" +");

for(col=0;colSIZE;col++)

printf("---+");

printf("\n");

}

int valid_moves(char board[][SIZE],int moves[][SIZE],char player)

{

int rowdelta=0;

int coldelta=0;

int row=0;

int col=0;

int x=0;

int y=0;

int no_of_moves=0;

char opponent=(player=='0')?'@':'0';

for(row=0;rowSIZE;row++)

for(col=0;colSIZE;col++)

moves[row][col]=0;

for(row=0;rowSIZE;row++)

for(col=0;colSIZE;col++)

{

if(board[row][col]!=' ')

continue;

for(rowdelta=-1;rowdelta=1;rowdelta++)

for(coldelta=-1;coldelta=1;coldelta++)

{

if(row+rowdelta0||row+rowdelta=SIZE||

col+coldelta0||col+coldelta=SIZE||

(rowdelta==0coldelta==0))

continue;

if(board[row+rowdelta][col+coldelta]==opponent)

{

x=row+rowdelta;

y=col+coldelta;

for(;;)

{

x+=rowdelta;

y+=coldelta;

if(x0||x=SIZE||y0||y=SIZE)

break;

if(board[x][y]==' ')

break;

if(board[x][y]==player)

{

moves[row][col]=1;

no_of_moves++;

break;

}

}

}

}

}

return no_of_moves;

}

void make_move(char board[][SIZE],int row,int col,char player)

{

int rowdelta=0;

int coldelta=0;

int x=0;

int y=0;

char opponent=(player=='0')?'@':'0';

board[row][col]=player;

for(rowdelta=-1;rowdelta=1;rowdelta++)

for(coldelta=-1;coldelta=1;coldelta++)

{

if(row+rowdelta0||row+rowdelta=SIZE||

col+coldelta0||col+coldelta=SIZE||

(rowdelta==0coldelta==0))

continue;

if(board[row+rowdelta][col+coldelta]==opponent)

{

x=row+rowdelta;

y=col+coldelta;

for(;;)

{

x+=rowdelta;

y+=coldelta;

if(x0||x=SIZE||y0||y=SIZE)

break;

if(board[x][y]==' ')

break;

if(board[x][y]==player)

{

while(board[x-=rowdelta][y-=coldelta]==opponent)

board[x][y]=player;

break;

}

}

}

}

}

int get_score(char board[][SIZE],char player)

{

int score=0;

int row=0;

int col=0;

char opponent=player=='0'?'@':'0';

for(row=0;rowSIZE;row++)

for(col=0;colSIZE;col++)

{

score-=board[row][col]==opponent;

score+=board[row][col]==player;

}

return score;

}

int best_move(char board[][SIZE],int moves[][SIZE],char player)

{

int row=0;

int col=0;

int i=0;

int j=0;

char opponent=player=='0'?'@':'0';

char new_board[SIZE][SIZE]={0};

int score=0;

int new_score=0;

for(row=0;rowSIZE;row++)

for(col=0;colSIZE;col++)

{

if(!moves[row][col])

continue;

for(i=0;iSIZE;i++)

for(j=0;jSIZE;j++)

new_board[i][j]=board[i][j];

make_move(new_board,row,col,player);

new_score=get_score(new_board,player);

if(scorenew_score)

score=new_score;

}

return score;

}

void computer_move(char board[][SIZE],int moves[][SIZE],char player)

{

int row=0;

int col=0;

int best_row=0;

int best_col=0;

int i=0;

int j=0;

int new_score=0;

int score=100;

char temp_board[SIZE][SIZE];

int temp_moves[SIZE][SIZE];

char opponent=player=='0'?'@':'0';

for(row=0;rowSIZE;row++)

for(col=0;colSIZE;col++)

{

if(moves[row][col]==0)

continue;

for(i=0;iSIZE;i++)

for(j=0;jSIZE;j++)

temp_board[i][j]=board[i][j];

make_move(temp_board,row,col,player);

valid_moves(temp_board,temp_moves,opponent);

new_score=best_move(temp_board,temp_moves,opponent);

if(new_scorescore)

{

score=new_score;

best_row=row;

best_col=col;

}

}

make_move(board,best_row,best_col,player);

}

我已经用英文说明了如何操作了......看不懂的我在这个说一下.

先按回车开始游戏,然后输入行号和列号就可以了...一局结束之后,

会提示是否再来一盘输入大写的Y继续大写的N结束程序!!!

我已经对操作说的很明确了!~~~~~你控制的是白棋(0),首先按回车开始游戏,然后输入行号(数字),列号(字符)就行了.......如果还是不行的话,那就是你更本不懂黑白棋的规则....

黑白棋c语言代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于黑白棋源码、黑白棋c语言代码的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/1271.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载