I have been thinking about making a script for a statistical question I came up with. However, as I know pretty much no Python (I have mainly been working in Lua, and I am currently only set up for Python scripts), I am putting this request out there.
What I am looking for:
- Check to see if there is room for a new layer
- Clear the current layer
- Prompt for number of samples
- Change to a particular rule that I have already created
- Make a 50% dense, 201x201 random soup of state 1 in that layer
- Set the central cell to state 3
- Run the pattern until stabilization (there is no chance of oscillation in this particular rule), or until a cutoff of 1000 generations (at which point it displays an error)
- Change to another particular rule that I have already created
- Run the pattern for one step
- Record the pattern population
- Increment the (population)th entry in a table by one
- Repeat from step 3 until the number of samples is reached
- Create a new layer
- Plot the results cell-by-cell in the other (currently unused) layer (in which the pattern is free to extend beyond the edge of the screen)
Code: Select all
-- Step 1:
if num_layers=10 then
print(error_message)
end
-- Step 2:
new_pattern()
-- Step 3:
prompt(number_of_samples)
-- Some variable declarations:
data={}
var pop=0
var max_pop=0
var prevmax_pop=0
-- To be repeated:
for i=1,number_of_samples do
-- Step 4:
set_rule_to(WFLanalyze-1)
-- Step 5:
random_soup({0,0},{200,200},1,{50,50}) -- corner, opposite corner, maximum state number, percentage table
-- Step 6:
set_cell({100,100},3) -- location, state
-- Step 7:
step()
if population(time) != population(time-1) then
if time>1000 then
print(error_message)
else
step()
end
end
-- Step 8:
set_rule_to(WFLanalyze-2)
-- Step 9:
step()
-- Step 10:
set pop=current_population
-- Autofills used section of table with zeroes (to prevent an error)
if pop>max_pop+1 then
set prevmax_pop=max_pop
set max_pop=pop
for j=prevmax_pop+1,max_pop do
data[j]=0
end
end
-- Step 11:
data[pop]=data[pop]+1
-- Resets back to time 0:
reset()
end
-- Step 13:
create_new_layer()
-- Step 14:
for k=0,num_entries(data) do
set_cell({k,data[k]},1)
end
#1 (to floodfill):
Code: Select all
n_states:4
neighborhood:vonNeumann
symmetries:permute
var a={2,3}
var b={0,1,2,3}
var c={b}
var d={b}
0,a,b,c,d,2
Code: Select all
n_states:4
neighborhood:vonNeumann
symmetries:permute
var a={0,1}
var b={a}
var c={a}
var d={a}
1,a,b,c,d,0