How to resolve the algorithm One-dimensional cellular automata step by step in the AutoHotkey programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm One-dimensional cellular automata step by step in the AutoHotkey 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 AutoHotkey programming language
Source code in the autohotkey programming language
n := 22, n1 := n+1, v0 := v%n1% := 0 ; set grid dimensions, and fixed cells
Loop % n { ; draw a line of checkboxes
v%A_Index% := 0
Gui Add, CheckBox, % "y10 w17 h17 gCheck x" A_Index*17-5 " vv" A_Index
}
Gui Add, Button, x+5 y6, step ; button to step to next generation
Gui Show
Return
Check:
GuiControlGet %A_GuiControl% ; set cells by the mouse
Return
ButtonStep: ; move to next generation
Loop % n
i := A_Index-1, j := i+2, w%A_Index% := v%i%+v%A_Index%+v%j% = 2
Loop % n
GuiControl,,v%A_Index%, % v%A_Index% := w%A_Index%
Return
GuiClose: ; exit when GUI is closed
ExitApp
You may also check:How to resolve the algorithm Day of the week step by step in the SenseTalk programming language
You may also check:How to resolve the algorithm Lucas-Lehmer test step by step in the AWK programming language
You may also check:How to resolve the algorithm MD5 step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Superpermutation minimisation step by step in the zkl programming language
You may also check:How to resolve the algorithm Attractive numbers step by step in the VBA programming language