Share to EffectHub.com

You can earn money or coins from your share:)

Tips: you can use Sparticle for uploading away3D effects.

Tips: you can download Sparticle for uploading effects.

Tips: The ActionScript editor is supporting Away3D, Starling, Dragonbones and Flex frameworks.

Tips: paste the web page URL then click button:)

关于宝石迷阵的生成算法?



宝石迷阵图片

这个游戏大家应该玩过吧?

有几个不同形状的元素
如果一行出现连续的三个,四个,五个元素
或者交叉出现三个,四个,五个元素组成的T,L形状
都可以消除这些元素。
当元素被消除以后,元素上方的元素下落,并生成新的元素填充空白。

问题:

如果是你,如何根据难度,生成相应的元素
要求
初始化的时候,不可以有元素被消除
当元素被消除以后,总是会出现可被消除的组合,不能出现死局


Tags

1496 views    1 answers


1


如果颜色个数是四 那么0 1 2 3三个数字
rand4()生成0-4的随机数
填入一个二维的矩阵 (矩阵初始值可以设置为-1)
然后写个方法验证下 填写这个元素在矩阵这个位置可不可以 
如果不可以就从新生成随机数 填入矩阵 
至于判断矩阵某个位置可以填入元素么 因为下 右都是-1 所以不用判断
只要判断下左边和上面 
如果左边是相同数字 那么 再看左边的左边 是不是也是相同颜色
如果是的话 就可以说明这个颜色不能填入 然后回去重新生成随机数字 当然可以直接排出那个上次失败的随机数字
然后直到充满二维数组就可以了

A PHP Error was encountered

Severity: Notice

Message: Undefined index: HTTP_ACCEPT_LANGUAGE

Filename: helpers/time_helper.php

Line Number: 22

2014-07-08     0 Comments

forward

A PHP Error was encountered

Severity: Notice

Message: Undefined index: HTTP_ACCEPT_LANGUAGE

Filename: helpers/time_helper.php

Line Number: 22

2014-07-08

Public Question, everyone could view answers and download attachments.

Finish this task then you can earn 20

>>Back to Task List


Want to work on this task?

Post My Answer


Sponsor


You may interest with



Share

Join Effecthub.com


Or Login with Your Email Address:

Or Sign Up with Your Email Address:
This field must contain a valid email
Password should be at least 1 character

A PHP Error was encountered

Severity: Notice

Message: Undefined index: HTTP_ACCEPT_LANGUAGE

Filename: views/footer.php

Line Number: 6

A PHP Error was encountered

Severity: Notice

Message: Undefined index: HTTP_ACCEPT_LANGUAGE

Filename: controllers/task.php

Line Number: 19

A PHP Error was encountered

Severity: Notice

Message: Undefined index: HTTP_ACCEPT_LANGUAGE

Filename: controllers/task.php

Line Number: 84