17
2
The challenge is to find the shortest implementation of the game of life in 3D (example). These are the rules:
Cells (in this case, cubes) with only 1 or less neighbours die, as if by lonliness.
If exactly 5 cells surround an empty cell, they breed and fill it.
If a cell has 8 or more neighbours, it dies from overcrowding.
Make it at least a 10x10x10, where the layers are outputted individually like this:
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 X 0 0 X 0 0 0 0 0
0 0 X X X 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Of course, a graphic 3D simulation is also accepted
The starting position may be hardcoded but it must work if it is changed to any starting position. It must be able to calculate any amount of generations, and the user must be able to manually ask for the next generation.
Shortest code in characters wins!
I made my own implementation of this for any (cube) size: http://jensrenders.site88.net/life3D.htm You can use this to test, and you can base your code on mine, although I didn't comment it.
I'd like to see a popcon version of this challenge. – ATaco – 2017-10-01T22:07:32.363
1Implied the code-golf tag from your statement find the shortest implementation. Please check if it is what you want. You should also give some details about how to input, how many cycles, animated yes/no, ... because it is essential for code-golf to have a robust specification. – Howard – 2014-02-28T16:22:20.390
@Howard I added some more specifications, and yes, forgot the code-golf tag ;) thanks for that. – Jens Renders – 2014-02-28T16:30:52.323
@PeterTaylor Yes exactly 5, i'll edit it. – Jens Renders – 2014-02-28T16:55:59.140
I would add specifics about the output format (e.g. each cell must be separated by a space as in your example, one newline between each grid layer of the output, living and dead cells must be represented by different characters, and those must be visible characters.) Also, bear in mind that if framed as code-golf, you are unlikely to get graphic simulations. – Jonathan Van Matre – 2014-02-28T17:35:42.920
Did you really mean to forbid all loopholes discussed in that meta thread, or only those meeting the (dis)approval criteria (+5 score, at least twice as many upvotes as downvotes)? Because I'm sure I could totally think of some pretty interesting "loopholes" to discuss... ;-) – Ilmari Karonen – 2014-02-28T18:53:07.973
Can we get a test case please? Maybe using a smaller size, like 4x4x4, if you don't want to post 2kB of data inline. – Tobia – 2014-02-28T19:53:22.620
I appreciate the online implementation, but I can't get it to work :-( – Tobia – 2014-02-28T22:56:52.567
@Tobia I should say I only tested in google chrome... And you have to change the 0's by X's (capital X) – Jens Renders – 2014-02-28T23:00:19.927
Link is down... :/ – Kroltan – 2014-11-02T20:35:29.940