如何编写C#程序来解决9-Queen问题 [英] How Can I Write C# Program To Solve The 9-Queen Problem

查看:57
本文介绍了如何编写C#程序来解决9-Queen问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用遗传算法编写c#程序来解决9-queen问题,该算法通过随机化使用的随机数生成器生成不同的解决方案。每代使用6个样本。



(在屏幕上)应打印三个项目

第一个代表解决方案为字符串(如152693847),第二个给出了达到解决方案所需的世代数,最后一个代表解决方案如下:



。 。 。 。 X 。 。 。 。

。 。 。 。 。 。 X 。 。

。 。 。 。 。 。 。 。 X

。 。 。 X 。 。 。 。 。

。 X 。 。 。 。 。 。 。

。 。 。 。 。 。 。 X。

。 。 。 。 。 X 。 。 。

。 。 X 。 。 。 。 。 。

X. 。 。 。 。 。 。 。





代码应在不到一秒的时间内运行。

解决方案

< blockquote>您可以参考以下链接

N Queen Problem [ ^ ]


how can i Write c# program to solve the 9-queen problem using genetic algorithm that generates a different solution each run by randomizing the random number generator used. Use 6 samples in each generation.

(on the screen) three items should be printed
The first one represents the solution as a string(like 152693847), the second gives the number of generations required to reach the solution and the last one represents the solution as follows:

. . . . X . . . .
. . . . . . X . .
. . . . . . . . X
. . . X . . . . .
. X . . . . . . .
. . . . . . . X .
. . . . . X . . .
. . X . . . . . .
X . . . . . . . .


the code should run in less than a second.

解决方案

You can refer the below link
N Queen Problem[^]


这篇关于如何编写C#程序来解决9-Queen问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆