4

Take the redstone from Minecraft as an example - it's basically a 15 state cellular automata with the following base rule:

Redstone -> Redstone, powered of level Max(neighbours)-1

and additional rules for various connected elements

Repeater, inactive -> Repeater, active, level 2 if its input is powered
Repeater, active, level 2 -> Repeater, active, level 1
Repeater, active, level 1 -> Repeater, inactive
Redstone, unpowered -> Redstone, powered if there is a neighbouring Repeater, level 1 or another source

(I've written more about how Minecraft stuff can be implemented using CAs: http://madflame991.blogspot.com/2011/10/cellular-automata-in-minecraft.html)

Now, my questions are: How would the game manage to update HUGE redstone contraptions? What data structure does it use? Is it really implemented as a cellular automata? If not, then what's your best guess?

P.S. I'm not asking anyone to take a peek at the actual source code, but just to speculate on how this technical thingie is achieved. ...and I'm posting this here, on SO, and not on gamedev because it's a CA question and not a gamedev related question.

Dan D.
  • 73,243
  • 15
  • 104
  • 123
adrianton3
  • 2,258
  • 3
  • 20
  • 33
  • 1
    That's a cool blog post of yours. I especially like playing with the light level simulator and seeing the changes propagate through the matrix. – Li-aung Yip Apr 27 '12 at 04:48

3 Answers3

2

Another possible approach to simulate mind-boggingly massive cellular automata (e.g. Game of Life in Game of Life) is to detect patterns (glider, glider generator, etc.) and to predict their future evolution and only compute the parts that are unknown (glider evolution).

OB1
  • 377
  • 1
  • 13
  • Hashlife basically does this, but in a way that applies to any rule, basically auto-detecting the repeating patterns. – masterxilo May 08 '22 at 13:45
1

Hashlife (1) can be what you are looking for by accelerating computations over really huge spaces.

Jean-Baptiste Yunès
  • 34,548
  • 4
  • 48
  • 69
  • http://golly.sourceforge.net/ implements hashlife, there is also an app for it https://play.google.com/store/apps/details?id=net.sf.golly – masterxilo May 08 '22 at 13:44
0

The obvious way to do this is to divide the world into chunks (hey, Minecraft does that already!) and assign each chunk to a server. Each server is responsible for processing updates to that chunk, and for communicating with the servers responsible for neighboring chunks, propagating state to them.

In the case of a cellular automata like this, each chunk would have to communicate the current state of its edge cells to all neighboring chunks, and vice-versa, before it can increment the time step. Note that the communication overhead decreases with larger chunks, since the chunk area grows with O(n^2), while the perimeter only grows with O(n).

In reality, I suspect you'll find that it's not nearly that synchronous, and each chunk simulates the redstone inside it asynchronously, transmitting updates to neighboring chunks only when an event happens, and without trying to stay in sync with everyone else.

Nick Johnson
  • 100,655
  • 16
  • 128
  • 198
  • I would be more inclined to believe that Minecraft just propagates changes to immediate neighbours when any element of the redstone circuit changes state, without regard to chunk boundaries. – Li-aung Yip Apr 27 '12 at 04:50
  • @Li-aungYip You're right, of course - I got tied up thinking about this fictional distributed minecraft client. I suspect I'm still right about it being asynchronous, though. – Nick Johnson Apr 27 '12 at 04:58
  • Actually (vanilla) redstone is effectively "chunked" because of the propagation distance of 15 blocks before you need a repeater. This limits the amount of work that needs to be done in any tick. – Li-aung Yip Apr 27 '12 at 05:05