我怎样才能生成所有Tetrominos的名单? [英] How can I generate a list of all Tetrominos?

查看:196
本文介绍了我怎样才能生成所有Tetrominos的名单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能生成所有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. 在一个矩形是1 omino。
  2. 对于任何正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.

这篇关于我怎样才能生成所有Tetrominos的名单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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