蟾蜍模式在生活的游戏中 [英] Toad pattern in game of life

查看:162
本文介绍了蟾蜍模式在生活的游戏中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试图解决生活中的游戏问题,以进行测试。该游戏的规则是:



任何不到两个活的邻居的活细胞死亡,好像是由于人口不足造成的。
任何带有两个或三个活着的邻居的活细胞生活在下一代。
有三个以上活着的邻居的活细胞死亡,好像过度拥挤。
任何有三个活邻居的死牢,都会成为一个活细胞,仿佛通过繁殖。



我测试了各种模式,如Block,Boat,Blinker和Toad模式如下所示。
但是我的代码没有给出所示的toad模式的预期输出,尽管它对每个其他模式都工作正常。



我得到这个输出TOAD:

  X  -  X 
X ---
--X-

我查看了各种网站,他们也显示了与以下相同的输出,但是如果我们应用规则,第二行和最后一列不能存活。


任何人都可以告诉我哪个是正确的输出?我必须是
确定,因为它是我的测试...


谢谢..

  **预期产出** 

1.块模式
输入
XX
XX
输出
XX
XX

2.船型
输入
XX -
X - X
- X -
输出
XX -
X - X
- X -

3.闪烁模式
输入
- X -
- X -
- X -
输出
- - -
XXX
- - -

4。 Toad Pattern
输入
- XXX
XXX -
- - X -
输出
X - - X
X - - X
- X - -


解决方案

TOAD的输入符合您所说明的规则。说明的预期输出与规则不一致。



如veridesmarald所指出,您的程序中有一个问题,但是您对TOAD的解释不清楚。 / p>

我还会注意到,您定义了TOAD的输入/预期输出,如下所示:

 输入
- XXX
XXX -
- - X -
输出
X - - X
X - - X
- X - -

如果我将行Output上移一行结果符合TOAD输入/输出的标准/预期定义:

 输入
- XXX
XXX -
输出//换行下面
- - X -
X - - X
X - - X
- X - -

似乎有些东西在翻译中遗失了,而您的程序可能会很好。


I was trying to solve the Game of life problem for a test. Rules of that game are:

Any live cell with fewer than two live neighbors dies, as if caused by under-population. Any live cell with two or three live neighbors’ lives on to the next generation. Any live cell with more than three live neighbors dies, as if by overcrowding. Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.

I tested my work on various patterns like Block, Boat, Blinker and Toad pattern shown below. But my code is not giving expected output for toad pattern as shown...although its working fine for every other pattern.

I am getting this output for TOAD:

X--X
X---
--X-

I checked various websites and they also showing the same output as below, but if we apply the rule, the cell in the 2nd row and last column cannot be alive.

So can anyone please tell me which is the right output? I have to be sure as it is for my test...

Thanks..

**Expected Output**

1.  Block Pattern
Input
X X
X X 
Output
X X
X X

2.  Boat Pattern
Input 
X X -
X - X
- X -
Output 
X X -
X - X
- X -

3.  Blinker Pattern
Input
- X -
- X -
- X - 
Output 
- - -
X X X
- - -

4. Toad Pattern
Input
- X X X
X X X -
- - X -
Output
X - - X
X - - X
- X - -

解决方案

Your output from your described input for TOAD matches the rules you've stated. The stated expected output doesn't match the rules.

It's not clear you have a problem in your program, but in your interpretation of TOAD, as noted by veredesmarald.

I'll also note that you defined input/expected-output for TOAD as follows:

Input
- X X X
X X X -
- - X -
Output
X - - X
X - - X
- X - -

And that if I move the line "Output" up one line the result matches the standard/expected definition of TOAD input/output:

Input
- X X X
X X X -
Output  // swapped with line below
- - X -
X - - X
X - - X
- X - -

It appears something simply got lost in translation, and your program may be fine.

这篇关于蟾蜍模式在生活的游戏中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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