我怎样才能生成所有Tetrominos的名单?名单、Tetrominos

由网友(梦想如花般盛开)分享简介:我怎么能生成所有Tetrominos的名单?或者,更一般地,如何可以生成限制到多个小区How can I generate a list of all Tetrominos?Or, more generally, how can I generate a subset of the polyominoes res...

我怎么能生成所有Tetrominos的名单? 或者,更一般地,如何可以生成限制到多个小区

How can I generate a list of all Tetrominos? Or, more generally, how can I generate a subset of the polyominoes restricted to a number of cells?

推荐答案

有很多方法可以做到这一点。我发现一个选项可以很好的考虑一下递归和更普遍。特别是:

There are many ways to do this. One option that I've found works well is to think about it recursively and more generally. In particular:

在一个矩形是1 omino。 对于任何正omino,你可以通过把块邻近任何从正omino块的创建(N + 1)-omino。

这给你列出所有可能的正ominos的递归方法。你必须要小心,虽然,因为这将产生多次旋转和相同的正ominos的翻译。你可以挑选一些参考坐标系统,然后翻译正omino,使其始终与该系统的轴平齐解决这个问题。一旦你的工作,你可以通过只旋转所产生的正omino绕轴,则其转换回典型位置生成所有转。

This gives you a recursive way of listing all possible n-ominos. You need to be careful, though, since this will generate multiple rotations and translations of the same n-ominos. You can fix this by picking some reference coordinate system and then translating the n-omino so that it is always flush with the axes of that system. Once you've got that working, you can generate all rotations by just rotating the resulting n-omino around the axes, then translating it back to the canonical position.

阅读全文

相关推荐

最新文章