如何在8平方拼图中随机排列方块 [英] how to arrange squares randomly in 8 square puzzle

查看:138
本文介绍了如何在8平方拼图中随机排列方块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要开发一个8平方的拼图。

我需要知道如何安排8个方格才能解决这个难题。



感谢任何帮助/提示。



问候,

I want to develop a 8-square puzzle.
I need to know how i must arrange the 8 squares in order to solve the puzzle.

Any help/hint is appreciated.

Regards,

推荐答案

这应该是足以解决这个问题:

http://msdn.microsoft.com/en-us/library/system.random%28v=vs.110%29.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/zd1bc8e5%28v= vs.110%29.aspx [ ^ ](这是你需要的唯一方法,不包括构造函数)。



现在,你应该使用som基本逻辑和对概率论产生随机排列的一些基本理解 http:// en。 wikipedia.org/wiki/Permutation [ ^ ]。



基本上,你应该考虑到某个方块的生成随机位置可能已经忙于另一个方格的先前生成的位置。但是,您不必自己发明算法。这里解释了一些算法:

http://en.wikipedia.org/wiki/Random_permutation [ ^ ]。



-SA
This should be enough to solve this problem:
http://msdn.microsoft.com/en-us/library/system.random%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/zd1bc8e5%28v=vs.110%29.aspx[^] (this is the only method you need, not counting the constructor).

Now, you should use some elementary logic and some rudimentary understanding of the probability theory to generate a random permutation: http://en.wikipedia.org/wiki/Permutation[^].

Basically, you should take into account the the generated random position of some square can be already busy by a previously generated position of another square. However, you don't have to invent the algorithm by yourself. Some of the algorithms are explained here:
http://en.wikipedia.org/wiki/Random_permutation[^].

—SA


这篇关于如何在8平方拼图中随机排列方块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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