日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發布時間:2025/3/8 编程问答 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 大道五目Flash英文版(Renju Problems)程序分析之禁手判断 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

現在界面已經完成了,

?

剛剛完成了禁手算法,把代碼共享出來:

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;
????????}

就是通過一個遞歸判斷是否當前下子為禁手。

測試后發現可以判斷復雜的禁手,如:


轉載于:https://www.cnblogs.com/boringlamb/archive/2008/11/04/1326291.html

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。