📄 mycomputer.h
字号:
up_down_defence[row][line]+=2;
isadded=1;
}
temp_row++;
value++;
}
return value;
}
int ScanUpRightAttack(int row ,int line ,int (*condition)[MAX_ROW_LINE],int (*right_left_attack)[MAX_ROW_LINE],int (*attack)[MAX_ROW_LINE])
{
int temp_row;
int temp_line;
int value = 0;
int isadded = 0;
for(temp_line = line + 1,temp_row = row -1, value=0;
temp_row >=0&&
temp_line < line+WIN_NUM-1&&
temp_line <MAX_ROW_LINE &&
condition[temp_row][temp_line]==WHITE;
temp_row++,temp_line++,value++)
{
right_left_attack[row][line]+=5;
attack[row][line]++;
}
while(temp_row <MAX_ROW_LINE&&temp_line<MAX_ROW_LINE&&condition[temp_row][temp_line]==EMPTY)
{
if(isadded==0)
{
right_left_attack[row][line]+=2;
isadded=1;
}
temp_row--;
temp_line++;
value++;
}
return value;
}
int ScanDownLeftAttack(int row ,int line ,int (*condition)[MAX_ROW_LINE],int (*right_left_attack)[MAX_ROW_LINE],int (*attack)[MAX_ROW_LINE])
{
int temp_row;
int temp_line;
int value = 0;
int isadded = 0;
for(temp_line = line - 1,temp_row = row +1, value=0;
temp_row < MAX_ROW_LINE &&
temp_line >= 0 &&
temp_line >=line - WIN_NUM &&
condition[temp_row][temp_line]==WHITE;
temp_row++,temp_line--,value++)
{
right_left_attack[row][line]+=5;
attack[row][temp_line]++;
}
while(temp_row <MAX_ROW_LINE&&temp_line>=0&&condition[temp_row][temp_line]==EMPTY)
{
if(isadded==0)
{
right_left_attack[row][line]+=2;
isadded=1;
}
temp_row++;
temp_line--;
value++;
}
return value;
}
int ScanUpRightDefence(int row ,int line ,int (*condition)[MAX_ROW_LINE],int (*right_left_defence)[MAX_ROW_LINE],int (*defence)[MAX_ROW_LINE])
{
int temp_row;
int temp_line;
int value = 0;
int isadded = 0;
for(temp_line = line + 1,temp_row = row -1, value=0;
temp_row <= row + WIN_NUM -1&&
temp_row >=0 &&
temp_line <MAX_ROW_LINE &&
condition[temp_row][temp_line]==BLACK;
temp_row--,temp_line++,value++)
{
right_left_defence[row][line]+=5;
defence[row][line]++;
}
while(temp_row>=0&&temp_line<MAX_ROW_LINE&&condition[temp_row][temp_line]==EMPTY)
{
if(isadded==0)
{
right_left_defence[row][line]+=2;
isadded=1;
}
temp_row--;
temp_line++;
value++;
}
return value;
}
int ScanDownLeftDefence(int row ,int line ,int (*condition)[MAX_ROW_LINE],int (*right_left_defence)[MAX_ROW_LINE],int (*defence)[MAX_ROW_LINE])
{
int temp_row;
int temp_line;
int value = 0;
int isadded = 0;
for(temp_line = line - 1,temp_row = row +1, value=0;
temp_row < MAX_ROW_LINE&&
temp_line >=0 &&
temp_line >=line - WIN_NUM&&
condition[temp_row][temp_line]==BLACK;
temp_row++,temp_line--,value++)
{
right_left_defence[row][line]+=5;
defence[row][line]++;
}
while(temp_row <MAX_ROW_LINE&&temp_line>=0&&condition[temp_row][temp_line]==EMPTY)
{
if(isadded==0)
{
right_left_defence[row][line]+=2;
isadded=1;
}
temp_row++;
temp_line--;
value++;
}
return value;
}
int ScanUpLeftAttack(int row ,int line ,int (*condition)[MAX_ROW_LINE],int (*left_right_attack)[MAX_ROW_LINE],int (*attack)[MAX_ROW_LINE])
{
int temp_row;
int temp_line;
int value = 0;
int isadded = 0;
for(temp_line = line - 1,temp_row = row -1, value=0;
temp_row >=row - WIN_NUM &&
temp_row >=0 &&
temp_line>=0 &&
condition[temp_row][temp_line]==WHITE;
temp_row--,temp_line--,value++)
{
left_right_attack[row][line]+=5;
attack[row][line]++;
}
while(temp_row >=0&&temp_line>=0&&condition[temp_row][temp_line]==EMPTY)
{
if(isadded==0)
{
left_right_attack[row][line]+=2;
isadded=1;
}
temp_row--;
temp_line--;
value++;
}
return value;
}
int ScanDownRightAttack(int row ,int line ,int (*condition)[MAX_ROW_LINE],int (*left_right_attack)[MAX_ROW_LINE],int (*attack)[MAX_ROW_LINE])
{
int temp_row;
int temp_line;
int value = 0;
int isadded = 0;
for(temp_line = line + 1,temp_row = row +1, value=0;
temp_row <= row + WIN_NUM &&
temp_row < MAX_ROW_LINE &&
temp_line < MAX_ROW_LINE &&
condition[temp_row][temp_line]==WHITE;
temp_row++,temp_line++,value++)
{
left_right_attack[row][line]+=5;
attack[row][line]++;
}
while(temp_row <MAX_ROW_LINE&&temp_line<MAX_ROW_LINE&&condition[temp_row][temp_line]==EMPTY)
{
if(isadded==0)
{
left_right_attack[row][line]+=2;
isadded=1;
}
temp_row++;
temp_line++;
value++;
}
return value;
}
int ScanUpLeftDefence(int row ,int line ,int (*condition)[MAX_ROW_LINE],int (*left_right_defence)[MAX_ROW_LINE],int (*defence)[MAX_ROW_LINE])
{
int temp_row;
int temp_line;
int value = 0;
int isadded = 0;
for(temp_line = line - 1,temp_row = row -1, value=0;
temp_row >=row - WIN_NUM &&
temp_row >=0 &&
temp_line >=0 &&
condition[temp_row][temp_line]==BLACK;
temp_row--,temp_line--,value++)
{
left_right_defence[row][line]+=5;
defence[row][line]++;
}
while(temp_row >=0&&temp_line>=0&&condition[temp_row][temp_line]==EMPTY)
{
if(isadded==0)
{
left_right_defence[row][line]+=2;
isadded=1;
}
temp_row--;
temp_line--;
value++;
}
return value;
}
int ScanDownRightDefence(int row ,int line ,int (*condition)[MAX_ROW_LINE],int (*left_right_defence)[MAX_ROW_LINE],int (*defence)[MAX_ROW_LINE])
{
int temp_row;
int temp_line;
int value = 0;
int isadded = 0;
for(temp_line = line + 1,temp_row = row +1, value=0;
temp_row <= row + WIN_NUM &&
temp_row < MAX_ROW_LINE &&
temp_line <MAX_ROW_LINE &&
condition[temp_row][temp_line]==BLACK;
temp_row++,temp_line++,value++)
{
left_right_defence[row][line]+=5;
defence[row][line]++;
}
while(temp_row <MAX_ROW_LINE&&temp_line<MAX_ROW_LINE&&condition[temp_row][temp_line]==EMPTY)
{
if(isadded==0)
{
left_right_defence[row][line]+=2;
isadded=1;
}
temp_row++;
temp_line++;
value++;
}
return value;
}
int IsGameOver(int (*condition)[MAX_ROW_LINE])
{
int row = 0;
int line = 0;
int count_black=0;
int count_white=0;
int temp_row;
int temp_line;
int count;
for(row=0;row<MAX_ROW_LINE;row++)
for(line=0;line<MAX_ROW_LINE;line++)
{
if(condition[row][line]==BLACK||condition[row][line]==WHITE)
{
for(count = 0,count_black = 0,count_white= 0,temp_row = row,temp_line = line;count <MAX_NUM&&temp_line< MAX_ROW_LINE ; temp_line++,count++) //n
{//横行扫描
if(condition[temp_row][temp_line]==BLACK)
count_black++;//黑子数增加
if(condition[temp_row][temp_line]==WHITE)
count_white++;//白子数增加
}
if(count_black==5)
{
return BLACK;
}
else if(count_white==5)
{
return WHITE;
}
for(count = 0,count_black = 0,count_white= 0,temp_row = row,temp_line = line;count <MAX_NUM&&temp_row< MAX_ROW_LINE; temp_row++,count++) //n
{//列行扫描
if(condition[temp_row][temp_line]==BLACK)
count_black++;//黑子数增加
if(condition[temp_row][temp_line]==WHITE)
count_white++;//白子数增加
}
if(count_black==5)
{
return BLACK;
}
else if(count_white==5)
{
return WHITE;
}
for(count = 0,count_black = 0,count_white= 0,temp_row = row,temp_line = line; count <MAX_NUM&&temp_line < MAX_ROW_LINE && temp_row< MAX_ROW_LINE; temp_line++,temp_row++,count++) //n
{//-1扫描
if(condition[temp_row][temp_line]==BLACK)
count_black++;//黑子数增加
if(condition[temp_row][temp_line]==WHITE)
count_white++;//白子数增加
}
if(count_black==5)
{
return BLACK;
}
else if(count_white==5)
{
return WHITE;
}
for(count = 0,count_black = 0,count_white= 0,temp_row = row,temp_line = line; count <MAX_NUM&&temp_line>-1 && temp_line < MAX_ROW_LINE && temp_row>-1 && temp_row< MAX_ROW_LINE ; temp_line++,temp_row--,count++) //n
{//1扫描
if(condition[temp_row][temp_line]==BLACK)
count_black++;//黑子数增加
if(condition[temp_row][temp_line]==WHITE)
count_white++;//白子数增加
}
if(count_black==5)
{
return BLACK;
}
else if(count_white==5)
{
return WHITE;
}
}
}
return 0;
}
int GetMax(int one , int two)
{
if(one > two)
return one;
else
return two;
}
int GetMaxFour(int one , int two , int three ,int four)
{
int max=0;
max=one;
if(two>max)
max=two;
if(three>max)
max=three;
if(four>max)
max= four;
return max;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -