您的位置:首页 > 编程语言 > C#

八数码问题的三种算法解答(C#源代码) (补充)

2007-06-17 13:59 459 查看
上一篇文章忘了贴八数码问题的数据结构,这里补充一下:

 


using System;




namespace Eight_Num_Fengart




...{




    /**//// <summary>


    /// 空格移动的方向


    /// </summary>


    enum Direction




    ...{


        None,


        Up,


        Left,


        Right,


        Down


    }






    /**//// <summary>


    /// 解答


    /// </summary>


    enum Answer




    ...{




        /**//// <summary>


        /// 不存在解答


        /// </summary>


        NotExist,




        /**//// <summary>


        /// 存在解答


        /// </summary>


        Exist,




        /**//// <summary>


        /// 在当前指定的搜索深度内不存在解答(需要扩大深度)


        /// </summary>


        NotExistInDepth


    }






    /**//// <summary>


    /// 局面状态信息


    /// </summary>


    class StateMsg




    ...{


        private int depth;


        private Direction dir;


        public int Depth




        ...{




            get ...{ return depth; }


        }


        public Direction Dir




        ...{




            get ...{ return dir; }


        }




        public StateMsg(int depth, Direction dir)




        ...{


            this.depth = depth;


            this.dir = dir;


        }


    }






    /**//// <summary>


    /// 局面状态


    /// </summary>


    class State : StateMsg




    ...{


        private long code;






        /**//// <summary>


        /// 棋盘的编码


        /// </summary>


        public long Code




        ...{




            get ...{ return code; }




            set ...{ code = value; }


        }




        public State(long code, int depth, Direction dir)


            : base(depth, dir)




        ...{


            this.code = code;


        }


    }






}



详细工程文件的下载地址: http://download.csdn.net/source/195320
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息