How to resolve the algorithm One-dimensional cellular automata step by step in the Déjà Vu programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm One-dimensional cellular automata step by step in the Déjà Vu programming language

Table of Contents

Problem Statement

Assume an array of cells with an initial distribution of live and dead cells, and imaginary cells off the end of the array having fixed values. Cells in the next generation of the array are calculated based on the value of the cell and its left and right nearest neighbours in the current generation. If, in the following table, a live cell is represented by 1 and a dead cell by 0 then to generate the value of the cell at a particular index in the array of cellular values you use the following table:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm One-dimensional cellular automata step by step in the Déjà Vu programming language

Source code in the déjà programming language

new-state size:
	0 ]
	repeat size:
		random-range 0 2
	[ 0

update s1 s2:
	for i range 1 - len s1 2:
		s1! -- i
		s1!    i
		s1! ++ i
		+ +
		set-to s2 i = 2
	s2 s1

print-state s:
	for i range 1 - len s 2:
		!print\ s! i
	!print ""

same-state s1 s2:
	for i range 1 - len s1 2:
		if /= s1! i s2! i:
			return false
	true

run size:
	new-state size
	new-state size
	while true:
		update
		print-state over
		if same-state over over:
			return print-state drop

run 60

  

You may also check:How to resolve the algorithm Zig-zag matrix step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Loops/Nested step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Bell numbers step by step in the jq programming language
You may also check:How to resolve the algorithm Terminal control/Hiding the cursor step by step in the Go programming language
You may also check:How to resolve the algorithm Long year step by step in the ALGOL 68 programming language