You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I have tried applying rules of “Convay’s game of life” and i followed everything like in this video epic conway's game of life - YouTube 0:30 - 0:59
if 3 neighbouring cells state is alive then my cell stays
if 2 neighbouring cells state is alive and mine is dead then put it in table for the next generation
and etc…
Instead of creating cells in somewhat order it creates something random and that’s bad beacuse that isn’t what i want to achvieve
function GenerateStep (cells)
local NewMap = {}
for x = 1,Xs do
for z = 1,Zs do
local myName = x.."."..z
local myCell = cells:FindFirstChild(myName)
if myCell then
local count = 0
for xM = -maping,maping do
for zM = -maping,maping do
local name = (x+xM).."."..(z+zM)
local cell = cells:FindFirstChild(name)
if cell then
local color = cell.BrickColor
if color == BrickColor.Black() then
count += 1
end
end
end
end
if count <= die_MIN or count >= die_MAX then
NewMap[myName] = false
elseif count >= Rep_MIN then
NewMap[myName] = true
elseif count == Survive then
NewMap[myName] = true
end
end
end
end
for name,v in pairs(NewMap) do
local div = string.split(name,".")
local x,z = div[1],div[2]
local cell = cells:FindFirstChild(name)
if cell then
if v == true then
cell.BrickColor = BrickColor.Black()
else
cell.BrickColor = BrickColor.White()
end
end
end
return true
end
i have tried to add if statment in surviving to check my_cell color but it had same result
mapping is in what range I should look for cells
die_MIN is number of cells it dies and same with die max
And survive is just number of neighbouring cell needed to survive
Also sorry if my response wasn’t clear but it’s very late (0 am) when I was answering on that question
Me–a lazy person–has decided reading this code is too hard for my brain right now.
Here is my own code that you can look at though. This code is based off a love2d implementation I wrote; I just copied my code into roblox.
local matrix = {}
local parts = {}
local width = 100
local height = 100
local function load()
for i = 1, width do
matrix[i] = {}
parts[i] = {}
for j = 1, height do
local y = 0
local part = Instance.new("Part")
part.Size = Vector3.new(1, 1, 1)
part.CFrame = CFrame.new(i, j, 0)
part.Anchored = true
part.Parent = workspace
part.Color = Color3.fromHSV(0, 0, y)
matrix[i][j] = y
parts[i][j] = part
end
end
local a, b, c = math.floor(width / 2), math.floor(height / 2), 2
for i = -c, c do
for j = -c, c do
matrix[a + i][b + j] = 1
end
end
end
local function update()
local new = {}
for i = 0, width + 1 do
new[i] = {}
for j = 0, height + 1 do
new[i][j] = 0
end
end
for i = 1, width do
for j = 1, height do
if (i == 1) or (i == width) or (j == 1) or (j == height) then
new[i][j] = 0
else
local sum = -matrix[i][j]
for x = -1, 1 do
for y = -1, 1 do
sum = sum + matrix[i + x][j + y]
end
end
if matrix[i][j] == 1 then
if (sum == 2) or (sum == 3) then
new[i][j] = 1
else
new[i][j] = 0
end
else
if (sum == 3) then
new[i][j] = 1
else
new[i][j] = 0
end
end
end
end
end
matrix = new
end
local function draw()
for i = 1, width do
for j = 1, height do
local part = parts[i][j]
local color = matrix[i][j]
part.Color = Color3.new(color, color, color)
end
end
end
load()
while true do
wait(1 / 10)
update()
draw()
end