现在界面已经完成了,

刚刚完成了禁手算法,把代码共享出来:

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)程序分析之禁手判断相关推荐

  1. 【原创】大道五目 Flash版 Demo

    写了一个demo,只有三关,左右键选择关卡,空格键显示/隐藏菜单,正式版本中会有120关,呵呵,不过这个作为DEMO已经足够了 想听听大家的建议---: http://files.cnblogs.co ...

  2. 第015课 NOR Flash操作原理及裸机程序分析

    #第001节_Nor Flash原理及硬件操作 # Nor Flash的连接线有地址线,数据线,片选信号读写信号等,Nor Flash的接口属于内存类接口,Nor Flash可以向内存一样读,但是不能 ...

  3. 【正点原子STM32连载】 第四十五章 FLASH模拟EEPROM实验 摘自【正点原子】STM32F103 战舰开发指南V1.2

    第四十五章 FLASH模拟EEPROM实验 STM32本身没有自带EEPROM,但是STM32具有IAP(在应用编程)功能,所以我们可以把它的FLASH当成EEPROM来使用.本章,我们将利用STM3 ...

  4. 支付宝五福53张自动领取程序 v2021

    简介: 临近过年,身边的朋友们都开始参加支付宝一年一度的集五福活动了!今天小编带来的这款支付宝五福53张自动领取程序能够帮助集福的朋友们更加轻松地完成任务,让用户一键完成53个任务并自动获取福卡,非常 ...

  5. 谭浩强《C程序分析》(第五版)第七章

    为什么要用函数 模块化程序设计 可以实现编好一批常用的函数来实现不同的功能,例如sin函数实现求一个数的正弦值,用abs函数实现求一个数的绝对值,把他们保存在函数库中.需要用时,直接在程序中写上sin ...

  6. 《C语言程序设计》(谭浩强第五版) 第2章 算法——程序的灵魂

    <C语言程序设计>(谭浩强第五版) 第2章 算法--程序的灵魂 习题解析与答案 你也可以上程序咖(https://meta.chengxuka.com),打开大学幕题板块,不但有答案,讲解 ...

  7. 未来五年,不懂人工智能的程序员不会被淘汰

    1. 话题背景 最近人工智能很火,区块链很火.都吹的上天的,工资非常高.空口无凭,来看看相关的数据. 薪资高,人才缺口大. 2.程序员的分类 程序员有很多工种,前端,后台,Android,java,c ...

  8. QT5.14入门教程GUI(五)第5个QT程序-SpinBox

    QT5.14入门教程GUI(五)第5个QT程序-SpinBox 本节,介绍SpinBox,DoubleSpinBox如何使用, 1.新建项目,改名称SpinBox; 2.改类名 3.打开UI界面,双击 ...

  9. 利用Photoscan处理五目相机空三,并导出CC空三文件

    利用Photoscan处理五目相机空三,并导出CC空三文件 前言 在近期photoscan很多朋友问如何利用五镜头数据导入photoscan,通过这一段时间摸索,现在把本人方法公布给大家做参考,如果有 ...

最新文章

  1. 跟益达学Solr5之Schema.xml详解
  2. Android获取挂载U盘的属性
  3. java properties文件_java的properties文件怎么创建
  4. Zernike函数拟合曲面--MATLAB实现
  5. haproxy是如何工作的?
  6. Dubbo -- 系统学习 笔记 -- 示例 -- 只订阅
  7. 使用java语言实现一个动态数组(详解)(数据结构)
  8. mysql程序设计考试app_MySQL数据库设计与应用知到APP期末考试完整答案
  9. w10系统 计算机快捷键大全,Win10电脑快捷键汇总_Win10系统快捷键大全_玩游戏网...
  10. 三角形的几何公式大全_椰岛数学:初中数学公式大全(文末分享PDF)
  11. harbor 安装启动遇到的keng
  12. 高并发解决方案——Redis(一)
  13. Linux内核由32位升到64,将Ubuntu从32位版本升级到64位版本
  14. 本地获取谷歌 获取经纬度 海拔
  15. 【C语言程序设计】实验 12
  16. 祛除装修异味的方法 总有一种适合你!
  17. ac远程web管理 r470gp tl_良心升级!TL-R470GP-AC一体化路由也支持无缝漫游了
  18. 创造属于自己的注册码
  19. 都是工作2年,你刚月薪过万,他却已拿到40万年薪
  20. 什么是电子邮箱地址?好用的电子邮箱注册申请

热门文章

  1. android 5.0 sd卡读写,如何使用为Android 5.0(Lollipop)提供的新SD卡存取API?
  2. 中国电信学院c语言题库,电脑题库试题精编版.doc
  3. arm中断保护和恢复_嵌入式ARM系统异常和中断处理知识总结
  4. 湖南省普通高等学校计算机应用水平,湖南省普通高等学校非计算机专业学生计算机应用水平二级考试大纲...
  5. mysql查看表描述_MySQL表记录操作介绍(重点介绍查询操作)
  6. AC_Dream 1216 G - Beautiful People
  7. axure原件 总是丢失_Axure实现提示文本单击显示后自动消失的效果
  8. hough变换检测圆周_Python OpenCV 霍夫变换
  9. c语言 函数指针开销,函数指针是否使程序变慢?
  10. 网站重新解析换服务器,更换解析服务器地址