填写完整的二维阵列(俄罗斯方块板)与俄罗斯方块件,不能有空格遗留(JAVA)俄罗斯方块、阵列、空格、完整

由网友(失恋的饥荒鬼)分享简介:让我们说我有一个二维int数组。Let's say I have a 2D int array..int[][] board = new int[10][20];public void initBoard(){for(int r = 0; r < 10; r++)for(int c = 0; c < 20; c+...

让我们说我有一个二维int数组。

Let's say I have a 2D int array..

int[][] board = new int[10][20];

public void initBoard()
{
    for(int r = 0; r < 10; r++)
        for(int c = 0; c < 20; c++)
            board[r][c] = 0;
}

0表示没有部分 这些作品重新由1-7 psented $ P $;

0 means no piece The pieces are represented by 1-7;

1 - Z形

2 - S形

3 - 线形状

4 - T形

5 - 箱形

6 - L型

7 - 向后L型

什么是填补了整个阵列随机的形状,并没有空格遗留下来的最好方式。

What is the best way to fill the entire array with random shapes and no spaces left over.

注:我有比赛的工作,我只是想同时仍使用俄罗斯方块游戏,以使其适应不同的东西。

Note: I have the game working, I'm just trying to adapt it to something different while still using the Tetris gameplay

推荐答案

这不是那么容易,因为它看起来。这是 NP问题的。 Packing矩形类似,您可以与一点点简单的问题开始。

It's not so easy as it seems. It's NP-hard problem in fact. Packing rectangles is similar, you can start with that a little bit simpler problem.

阅读全文

相关推荐

最新文章