随着又一次的人工智能与人类智能的世纪大战,我们不禁要思索,人工智能,是在呼唤上帝还是在召唤恶魔?此时正是时候研究一下人工智能相关理论,而本文主要论述计算机科学与技术专业大三下专业课《人工智能》第一个实验算法。
关键字:人工智能,搜索问题,树的深度优先搜索
The Missionaries and Cannibals Problem
Abstract: Beijing time on March 12 in the afternoon, Google AlphaGo and artificial intelligence, the third field of the south Korean chess player lee se-dol today, finally beat lee se-dol AlphaGo, won three consecutive victory.
Again, as the century of artificial intelligence and human intelligence war, we can not help but to think, artificial intelligence, in calling upon god or summon demons? Now is the time to study the related theory, artificial intelligence, this paper mainly discusses the computer science and technology under the junior in professional class "artificial intelligence" in the first experiment algorithm。
Keywords: artificial intelligence, search, depth first search tree
在河的左岸有 N 个传教士、 N 个野人和一条船,传教士们想用这条船把所有人都运过河去,但有以下条件限制:
(1)修道士和野人都会划船,但船每次最多只能运K个人;
(2)在任何岸边野人数目都不能超过修道士,否则修道士会被野人吃掉。
假定野人会服从任何一种过河安排,请规划出一个确保修道士安全过河的计划。
2.问题分析
2.1约束条件:
① M≧C 任何时刻两岸、船上都必须满足传教士人数不少于野人数(M=0时除外,既没有传教士)
② M+C≦K 船上人数限制在K以内
传教士与野人全部安全渡到对岸的解决方案
3.求解过程
3.1变量假设:
设 N=3,K=2 ( 三个 M 和三个 C, 每次渡河二人以下)
L: 左岸, R: 右岸,
B: 是否有船(0:无船,1:有船)
![图片](https://i-blog.csdnimg.cn/blog_migrate/78745740b8375277b43e1a1aee1a127a.png)
3.2状态表示
定义:用 三元组 (M L ,C L ,B L ) 表示左岸状态,其中:
0≦ M L ,C L ≦3, B L ∈ { 0,1}
如 :(0,3,1)表示左岸有三个野人,船在左岸。
从 (3,3,1) 到(0,0,0)的状态转换
状态空间:32 种状态,其中:
12种不合理状态:如 (1,0,1)说明右岸有2个 M,3 个 C ;
4 种不可能状态:如(3,3,0)说明所有 M 和 C 都在左岸,而船在右岸
∴ 可用的状态共16种 ,组成合理的状态空间
![图片](https://i-blog.csdnimg.cn/blog_migrate/f9470f655d8ea5b600174a547d9ea66d.png)
状态空间具体描述
![图片](https://i-blog.csdnimg.cn/blog_migrate/e73ade54283bfd65b74551d2128ea4b4.png)
3.2操作集
定义: Pmc 操作 :从左岸划向右岸