Chinaunix首页 | 论坛 | 博客
  • 博客访问: 543544
  • 博文数量: 855
  • 博客积分: 40000
  • 博客等级: 大将
  • 技术积分: 5005
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-16 19:08
文章分类

全部博文(855)

文章存档

2011年(1)

2008年(854)

我的朋友

分类:

2008-10-16 19:17:49

    搜索是电脑棋手AI的核心,有效的搜索算法很关键。本文给出了一些常用的搜索算法代码,以及这些算法的改进。例如配合置换表,历史启发表,开局库。算法的深入学习可以参考注释里给出的地址 : )


    view plaincopy to clipboardprint?
    /*

     * @(#)SearchEngine.java

     * Author: 88250 <>,

     * Created on May 24, 2008, 10:51:52 AM

     *

     * This program is free software; you can redistribute it and/or modify

     * it under the terms of the GNU General Public License as published by

     * the Free Software Foundation; either version 3 of the License, or

     * (at your option) any later version.

     *

     * This program is distributed in the hope that it will be useful,

     * but WITHOUT ANY WARRANTY; without even the implied warranty of

     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

     * GNU Library General Public License for more details.

     *

     * You should have received a copy of the GNU General Public License

     * along with this program; if not, write to the Free Software

     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

     */

    package cn.edu.ynu.sei.chinesechess.infrastructure.search;

 

    import cn.edu.ynu.sei.chinesechess.infrastructure.common.Motion;

    import cn.edu.ynu.sei.chinesechess.infrastructure.common.Situation;

    import cn.edu.ynu.sei.chinesechess.infrastructure.search.TranspositionTable.NodeType;

    import java.util.Collections;

    import java.util.List;

 

    /**

     * This class descripts some search algorithms of game tree.

     * @author 88250 <>,

     * @version 1.1.2.6, Jun 7, 2008

     */

    public class SearchEngine {

 

        /**

         * value while win a game

         */

        public static final int WIN = 54;

        /**

         * chessboard situation

         */

        public Situation situation;

        /**

         * the best move

         */

        public Motion bestMotion;

        /**

         * situation libaray

         */

        private Book book = new Book();

        /**

         * default search depth

         */

        public static int SEARCH_DEPTH = 5;

 

        /**

         * For Performance Test.

         * @param args should be null

         */

        public static void main(String[] args) {

            SearchEngine instance;

            instance = new SearchEngine(new Situation());

 

            System.out.println("Getting start search!");

            long startTime = System.nanoTime();

            //instance.basicAlphaBetaSearch(SEARCH_DEPTH, -WIN, WIN);

            //instance.alphaBetaWithHistoryHeuristicSearch(SEARCH_DEPTH, -WIN, WIN);

            //instance.alphaBetaWithTranspositonSearch(SEARCH_DEPTH, -WIN, WIN);

            //instance.principalVariationSearch(SEARCH_DEPTH, -WIN, WIN);

            //instance.principalVariationWithHHSearch(SEARCH_DEPTH, -WIN, WIN);

            instance.negaScoutWithHHTTSearch(SEARCH_DEPTH, -WIN, WIN);

 

[1]         

【责编:landy】

--------------------next---------------------

阅读(253) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~