日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

大道五目Flash英文版(Renju Problems)程序分析之禁手判断

發(fā)布時(shí)間:2025/3/8 63 豆豆
生活随笔 收集整理的這篇文章主要介紹了 大道五目Flash英文版(Renju Problems)程序分析之禁手判断 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

現(xiàn)在界面已經(jīng)完成了,

?

剛剛完成了禁手算法,把代碼共享出來(lái):

Code
private?function?IsForbidden(x:int,?y:int,?board:Array):int?{
????????????var?index:
int?=?x*15+y;
????????????
????????????
//?set?this?position(x,y)?to?black.
????????????board[index]?=?CellType.BLACK;
????????????
????????????
//?1st?check?whether?there?is?overline.
????????????var?array:Array?=this.GetAnalyseArray(x,y,board);
????????????
????????????
if(this.IsOverline(array))?{
????????????????board[index]?
=?CellType.EMPTY;
????????????????
return?ResultType.OVERLINE;
????????????}

????????????
????????????
//?use?recursion?to?check?whether?there?is?double-4?or?double-3.
????????????
//?the?check?methord?is?count?the?open?3?and?open?4's?count,
????????????
//?if?one?of?them?larger?than?1?so?is?a?forbidden.
????????????var?count3:int?=?0;
????????????var?count4:
int?=?0;
????????????
????????????var?i,?j:
int?=?0;
????????????
for(i=0;?i<4;?i++)?{
????????????????
????????????????
//?calculate?open?4's?count.
????????????????for(j=3;?j<7;?j++)?{
????????????????????
//?patten:??0x000?
????????????????????if(array[i][j]==CellType.BLACK&&this.IsEmpty(i,j+1,array)&&?
????????????????????????array[i][j
+2]==CellType.BLACK&&array[i][j+3]==CellType.BLACK&&
????????????????????????array[i][j
+4]==CellType.BLACK&&
????????????????????????
this.IsNotBlack(i,j-1,array)&&this.IsNotBlack(i,j+5,array))?{
????????????????????????count4
++;
????????????????????????
continue;????
????????????????????}

????????????????????
//?patten:??00x00?
????????????????????if(array[i][j]==CellType.BLACK&&array[i][j+1]==CellType.BLACK&&?
????????????????????????
this.IsEmpty(i,j+2,array)&&array[i][j+3]==CellType.BLACK&&
????????????????????????array[i][j
+4]==CellType.BLACK&&
????????????????????????
this.IsNotBlack(i,j-1,array)&&this.IsNotBlack(i,j+5,array))?{
????????????????????????count4
++;
????????????????????????
continue;
????????????????????}

????????????????????
//?patten:??000x0?
????????????????????if(array[i][j]==CellType.BLACK&&array[i][j+1]==CellType.BLACK?&&?
????????????????????????array[i][j
+2]==CellType.BLACK&&this.IsEmpty(i,j+3,array)?&&
????????????????????????array[i][j
+4]==CellType.BLACK&&
????????????????????????
this.IsNotBlack(i,j-1,array)&&this.IsNotBlack(i,j+5,array))?{
????????????????????????count4
++;
????????????????????????
continue;
????????????????????}

????????????????????
//?patten:???0000??
????????????????????
//?not?like?above?three,?this?check?index?is?the?above?index?plus?1.
????????????????????
//?in?other?words,?the?check?index?is?4?to?8?and?above?index?is?3?to?7.
????????????????????if(array[i][j+1]==CellType.BLACK&&array[i][j+2]==CellType.BLACK&&?
????????????????????????array[i][j
+3]==CellType.BLACK&&array[i][j+4]==CellType.BLACK)?{
????????????????????????
if(this.IsEmpty(i,j,array)&&this.IsNotBlack(i,j-1,array)&&this.IsNotBlack(i,j+5,array))?{
????????????????????????????count4
++;
????????????????????????????
continue;
????????????????????????}

????????????????????????
if(this.IsEmpty(i,j+5,array)&&this.IsNotBlack(i,j+4,array)&&this.IsNotBlack(i,j,array))?{
????????????????????????????count4
++;
????????????????????????????
continue;
????????????????????????}

????????????????????}

????????????????}

????????????????
????????????????var?tmpIndex:
int;
????????????????
//?calculate?open?3's?count
????????????????for(j=4;?j<7;?j++)?{
????????????????????
//?patten:???0x00??
????????????????????if(array[i][j]==CellType.BLACK&&this.IsEmpty(i,j+1,array)&&
????????????????????????array[i][j
+2]==CellType.BLACK&&array[i][j+3]==CellType.BLACK&&
????????????????????????
this.IsEmpty(i,j-1,array)&&this.IsEmpty(i,j+4,array)&&
????????????????????????(
this.IsNotBlack(i,j-2,array)||this.IsNotBlack(i,j+5,array)))?{
????????????????????????tmpIndex?
=?this.IndexConverter(i,j+1,x,y);
????????????????????????
if(this.IsForbidden(Math.floor(tmpIndex/15),tmpIndex%15,board)==ResultType.NOTHING){
????????????????????????????count3
++;
????????????????????????}

????????????????????????
continue;
????????????????????}

????????????????????
//?patten:???00x0??
????????????????????if(array[i][j]==CellType.BLACK&&array[i][j+1]==CellType.BLACK&&
????????????????????????
this.IsEmpty(i,j+2,array)&&array[i][j+3]==CellType.BLACK&&
????????????????????????
this.IsEmpty(i,j-1,array)&&this.IsEmpty(i,j+4,array)&&
????????????????????????(
this.IsNotBlack(i,j-2,array)||this.IsNotBlack(i,j+5,array)))?{
????????????????????????tmpIndex?
=?this.IndexConverter(i,j+2,x,y);
????????????????????????
if(this.IsForbidden(Math.floor(tmpIndex/15),tmpIndex%15,board)==ResultType.NOTHING)?{????
????????????????????????????count3
++;
????????????????????????}

????????????????????????
continue;
????????????????????}

????????????????????
//?patten:???000??
????????????????????if(array[i][j]==CellType.BLACK&&array[i][j+1]==CellType.BLACK&&array[i][j+2]==CellType.BLACK)?{
????????????????????????
if(this.IsEmpty(i,j-2,array)&&this.IsEmpty(i,j-1,array)&&
????????????????????????????
this.IsEmpty(i,j+3,array)&&this.IsNotBlack(i,j-3,array))?{
????????????????????????????tmpIndex?
=?this.IndexConverter(i,j-1,x,y);
????????????????????????????
if(this.IsForbidden(Math.floor(tmpIndex/15),tmpIndex%15,board)==ResultType.NOTHING)?{
????????????????????????????????count3
++;
????????????????????????????????
continue;
????????????????????????????}

????????????????????????}

????????????????????????
if(this.IsEmpty(i,j-1,array)&&this.IsEmpty(i,j+3,array)&&
????????????????????????????
this.IsEmpty(i,j+4,array)&&this.IsNotBlack(i,j+5,array))?{
????????????????????????????tmpIndex?
=?this.IndexConverter(i,j+3,x,y);
????????????????????????????
if(this.IsForbidden(Math.floor(tmpIndex/15),tmpIndex%15,board)==ResultType.NOTHING)?{
????????????????????????????????count3
++;
????????????????????????????????
continue;
????????????????????????????}

????????????????????????}

????????????????????}

????????????????}

????????????}
????
????????????
????????????
//?reset?the?position?to?empty?and?return?result.
????????????board[index]?=?CellType.EMPTY;
????????????
if(count3>1)?{
????????????????
return?ResultType.DOUBLE_THREE;
????????????}

????????????
if(count4>1)?{
????????????????
return?ResultType.DOUBLE_FOUR;
????????????}

????????????
return?ResultType.NOTHING;
????????}

就是通過(guò)一個(gè)遞歸判斷是否當(dāng)前下子為禁手。

測(cè)試后發(fā)現(xiàn)可以判斷復(fù)雜的禁手,如:


轉(zhuǎn)載于:https://www.cnblogs.com/boringlamb/archive/2008/11/04/1326291.html

總結(jié)

以上是生活随笔為你收集整理的大道五目Flash英文版(Renju Problems)程序分析之禁手判断的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。