Thread for your script-related questions

For scripts to aid with computation or simulation in cellular automata.
User avatar
b-engine
Posts: 3762
Joined: October 26th, 2023, 4:11 am
Location: Somewhere on where Earth At
Contact:

Re: Thread for your script-related questions

Post by b-engine »

hotdogPi wrote: November 6th, 2024, 10:44 am There's also CatForce and its relatives, if you want high periods. There's still stuff to find; there are several periods where we don't have any good sparkers, such as 17, and sparkers of certain types of periods 13 (for 39 and possibly 26), 14, 18, and 35 would find guns of missing periods.
Speaking of CatForce, how to install and use it? All of my attempts failed before.
WhiteHawk
Posts: 1369
Joined: July 10th, 2024, 5:34 pm

Re: Thread for your script-related questions

Post by WhiteHawk »

b-engine wrote: November 6th, 2024, 10:39 am If you're using Windows, WinLifeSearch would be a great option. It's easy to download and use, and in fact the first search program I ever used.
Thanks.

It seems i need C to run the program. How should I go about getting that?
Currently working to improve Life's guns and work on updating SKOPs and Isotropic rules most similar to B3/S23 to Life standards. Will get software to begin searches eventually.

Pseudastur albicollis
User avatar
dvgrn
Moderator
Posts: 12023
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Thread for your script-related questions

Post by dvgrn »

WhiteHawk wrote: November 6th, 2024, 11:39 am
b-engine wrote: November 6th, 2024, 10:39 am If you're using Windows, WinLifeSearch would be a great option. It's easy to download and use, and in fact the first search program I ever used.
Thanks.

It seems i need C to run the program. How should I go about getting that?
You might consider trying JavaLifeSearch instead, since that just requires installing Java. (Ask Google about that.) The "binary" in the link is actually a .jar (Java archive) file, which is more of a ZIP file than what I'd ordinarily think of as a "binary".

As the name suggests, JavaLifeSearch has functionality very similar to WinLifeSearch (and to the original lifesrc -- both versions add a GUI to the original command-line search program).
User avatar
b-engine
Posts: 3762
Joined: October 26th, 2023, 4:11 am
Location: Somewhere on where Earth At
Contact:

Re: Thread for your script-related questions

Post by b-engine »

WhiteHawk wrote: November 6th, 2024, 11:39 am Thanks.

It seems i need C to run the program. How should I go about getting that?
I don't think so. It's avaliable as Windows executable file.
User avatar
CARuler
Posts: 1347
Joined: July 30th, 2024, 5:38 pm
Location: A rule-verse in floor rule-verse of the CGOL skyscraper

Re: Thread for your script-related questions

Post by CARuler »

how do golly scripts in python work? how do i tell golly to turn certain cells on or off?
likes interesting rules
vist my rules here
also likes weird growth patterns in CA
hyperbolic CA!!!
ADHD user
mostly inactive
User avatar
dvgrn
Moderator
Posts: 12023
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Thread for your script-related questions

Post by dvgrn »

CARuler wrote: November 14th, 2024, 12:38 am how do golly scripts in python work? how do i tell golly to turn certain cells on or off?
golly.setcell(x,y,color) -- see the documentation.

You might want to consider using Lua instead, though, since the Lua language comes packaged with Golly and doesn't need any separate installation or configuration.

Examples of programs that use setcell() include draw-lines.lua, flood-fill.lua, and move-object.lua (and their Python equivalents).
User avatar
islptng
Posts: 495
Joined: May 24th, 2024, 6:17 am
Location: 种花家

Re: Thread for your script-related questions

Post by islptng »

1. How to apgsearch with spaceinvaders?
2. How to use LLS to search for reflectors?
My sandbox | All my engineered replicators | BsKngt | TNT
Asperger, ISTP, using a Dvorak keyboard.

I love my new school life.
User avatar
TigerCub414
Posts: 167
Joined: March 25th, 2024, 9:51 pm

Re: Thread for your script-related questions

Post by TigerCub414 »

I have encountered a problem with lifelib. It can't open a LifeViewer widget. When I run x.viewer() in a Jupyter notebook, it opens an empty black window and it doesn't throw any errors.
When I do the same thing in a python shell, it opens an empty command prompt window and nothing happens. Here is the output:

Code: Select all

x.viewer()
<IPython.core.display.HTML object>
<IPython.lib.display.IFrame object at 0x000001682C413E00>
I checked that I have IPython installed but it doesn't work anyway. Is there some other package that I have to install for the lifelib viewer to work correctly?
Attachments
The screenshot of the broken LifeViewer
The screenshot of the broken LifeViewer
Снимок экрана (1).png (139.79 KiB) Viewed 11765 times

Code: Select all

x = 32, y = 32, rule = B3aijkr5j/S2aek3-acy4iz6c
8b3o$7bo2bo$7bo2bo$7b3o4$28b3o$28bo2bo$28bo2bo$29b3o11$3o$o2bo$o2bo$b
3o4$22b3o$21bo2bo$21bo2bo$21b3o!
LWSSONHWSSONLWSS
Posts: 409
Joined: July 20th, 2024, 9:51 am

Re: Thread for your script-related questions

Post by LWSSONHWSSONLWSS »

Sokwe wrote: December 14th, 2024, 11:48 pm
LWSSONHWSSONLWSS wrote: December 14th, 2024, 11:18 pm Okay, going back to page 2, how to finish these partials again?
You would need to use a program with the ability to extend partial results, such as LLSSS, ikpx2, qfind, or JLS. See the scripts forum for discussion of these programs.
But how can I download the scripts? I don’t know where to download it!
Please click this okay?
Image
Sokwe
Moderator
Posts: 3375
Joined: July 9th, 2009, 2:44 pm

Re: Thread for your script-related questions

Post by Sokwe »

LWSSONHWSSONLWSS wrote: December 14th, 2024, 11:54 pm But how can I download the scripts? I don’t know where to download it!
Go to those programs' respective threads in the scripts forum. In each case, the first post contains a link to the download location. Each thread has been recently bumped, so they should be easy to find. Only LLSSS is confusing, since the title of the thread is amling search program principles discussion / brain dump.

Also, I moved your post the the script-related questions thread.
-Matthias Merzenich
LWSSONHWSSONLWSS
Posts: 409
Joined: July 20th, 2024, 9:51 am

Re: Thread for your script-related questions

Post by LWSSONHWSSONLWSS »

LWSSONHWSSONLWSS wrote: December 17th, 2024, 11:16 pm We need a suitable obo! sparker now.
Can you use a search program to search up any of these sparkers?
Please click this okay?
Image
User avatar
H. H. P. M. P. Cole
Posts: 481
Joined: July 15th, 2023, 9:36 pm

Re: Thread for your script-related questions

Post by H. H. P. M. P. Cole »

LWSSONHWSSONLWSS wrote: December 17th, 2024, 11:19 pm
LWSSONHWSSONLWSS wrote: December 17th, 2024, 11:16 pm We need a suitable obo! sparker now.
Can you use a search program to search up any of these sparkers?
@LWSSONHWSSONLWSS, unproductive one-liners like these do not seem to warrant a post. See three of your other posts below which are also unproductive one-liners:

viewtopic.php?f=2&t=3552&p=197333#p197333
viewtopic.php?f=2&t=3552&p=197497#p197497
viewtopic.php?f=2&t=3552&p=199533#p199533

About the quoted post: you can look up the list of already-known sparkers and see which one works. If there isn't, you can ask specifically for the period and clearance of the sparker - "obo! sparker" isn't that precise, but something like a "p13 obo! sparker with at least medium clearance" is more specific.

In future, if you have a question of whether a certain type of object exists, please look up already-compiled collections, like jslife or Dieter and Peter's gun collection.
User avatar
breaker's glider gun
Posts: 730
Joined: May 23rd, 2021, 10:26 am
Location: the inside of a stuffed anaconda or maybe [click to not expand]

Re: Thread for your script-related questions

Post by breaker's glider gun »

Alright, my brother wanted a script for generating any pascal's triangle mod, so I asked, "can it be a script that makes a rule?"
So here it is, or at least... hopefully.

Code: Select all

#!/usr/bin/perl
(my $mod = <STDIN>) =~ s/[^0-9]//g;
my $statenum = $mod + 1;

print "\@RULE PascalMod$mod\n\n\@TABLE\nn_states:$statenum\nneighborhood:vonNeumann\nsymmetries:permute\n";

for (my $i = 1; $i<$mod; $i++) {
    print "0, $i,0,0,0, $i\n";
    for (my $j = 1; $j<$mod; $j++) {
        my $k = ($i + $j) % $mod;
        print "0, $i,$j,0,0, $k\n";
    }
}
print "0, $mod,0,0,0, $mod\n";
print "0, $mod,$mod,0,0, $mod\n";
Here is output using 3, but it doesn't seem to work in golly. what am I missing?

Code: Select all

@RULE PascalMod3

@TABLE n_states:4
neighborhood:vonNeumann
symmetries:permute
0, 1,0,0,0, 1
0, 1,1,0,0, 2
0, 1,2,0,0, 0
0, 2,0,0,0, 2
0, 2,1,0,0, 0
0, 2,2,0,0, 1
0, 3,0,0,0, 3
0, 3,3,0,0, 3
:?: :?: . . . :!:
Give me a suggestion of something interesting to draw here!
User avatar
confocaloid
Posts: 6697
Joined: February 8th, 2022, 3:15 pm
Location: learn to protect yourself against stray gliders and sparks and self-destruct mechanisms

Re: Thread for your script-related questions

Post by confocaloid »

breaker's glider gun wrote: January 11th, 2025, 11:53 pm [...] Here is output using 3, but it doesn't seem to work in golly. what am I missing? [...]
I see a missing newline after the "@TABLE" section header, and other than that no obvious problems.

Code: Select all

x = 1, y = 1, rule = PascalMod3
o!

@RULE PascalMod3

@TABLE
n_states:4
neighborhood:vonNeumann
symmetries:permute
0, 1,0,0,0, 1
0, 1,1,0,0, 2
0, 1,2,0,0, 0
0, 2,0,0,0, 2
0, 2,1,0,0, 0
0, 2,2,0,0, 1
0, 3,0,0,0, 3
0, 3,3,0,0, 3
127:1 B3/S234c User:Confocal/R (isotropic CA, incomplete)
Unlikely events happen.
My silence does not imply agreement, nor indifference. If I disagreed with something in the past, then please do not construe my silence as something that could change that.
User avatar
breaker's glider gun
Posts: 730
Joined: May 23rd, 2021, 10:26 am
Location: the inside of a stuffed anaconda or maybe [click to not expand]

Re: Thread for your script-related questions

Post by breaker's glider gun »

confocaloid wrote: I see a missing newline after the "@TABLE" section header, and other than that no obvious problems.
TY! It works now and I feel a bit silly.
revised:

Code: Select all

#!/usr/bin/perl
(my $mod = <STDIN>) =~ s/[^0-9]//g;

my $states = $mod + 2;
my $fill = $mod + 1;

print "\@RULE PascalMod$mod\n\n\@TABLE\nn_states:$states\nneighborhood:vonNeumann\nsymmetries:permute\n";

for (my $i = 1; $i<$mod; $i++) {
    print "0, $i,0,0,0, $i\n";
    print "0, $i,$mod,0,0, $i\n";
    for (my $j = 1; $j<$mod; $j++) {
        (my $k = ($i + $j) % $mod) =~ s/0/$mod/;
        
        print "0, $i,$j,0,0, $k\n";
    }
}
print "0, $fill,0,0,0, $fill\n";
print "0, $fill,$fill,0,0, $fill\n";
print "0, $mod,$mod,0,0, $mod\n";
print "\@COLORS\n0 0 0 0\n$mod 0 0 0\n$fill 0 0 0\n"
:?: :?: . . . :!:
Give me a suggestion of something interesting to draw here!
NooneAtAll3
Posts: 54
Joined: January 29th, 2023, 3:38 am

Re: Thread for your script-related questions

Post by NooneAtAll3 »

what program can I use to check if pattern is GoE, from within script?

JLS seems gui-only?
Naszvadi
Posts: 1465
Joined: May 7th, 2016, 8:53 am
Contact:

Re: Thread for your script-related questions

Post by Naszvadi »

NooneAtAll3 wrote: January 17th, 2025, 6:56 am what program can I use to check if pattern is GoE, from within script?

JLS seems gui-only?
There are (linear pure) integer programming models that could test a GoE arrangement. See mine at viewtopic.php?f=9&t=2563.

An example usage is under de**an/u****u:

Code: Select all

# sudo apt-get install -y glpk-utils |&:
# apt-file search life_goe.mod
glpk-utils: /usr/share/doc/glpk-utils/examples/life_goe.mod
# glpsol --cuts --dual --last -m /usr/share/doc/glpk-utils/examples/life_goe.mod 
GLPSOL--GLPK LP/MIP Solver 5.0
Parameter(s) specified in the command line:
 --cuts --dual --last -m /usr/share/doc/glpk-utils/examples/life_goe.mod
Reading model section from /usr/share/doc/glpk-utils/examples/life_goe.mod...
Reading data section from /usr/share/doc/glpk-utils/examples/life_goe.mod...
165 lines were read
Generating maincons...
Generating posbound...
Generating negbound...
Generating mutex...
Generating alive...
Generating dead...
Model has been successfully generated
GLPK Integer Optimizer 5.0
350 rows, 388 columns, 1330 non-zeros
248 integer variables, all of which are binary
Preprocessing...
82 constraint coefficient(s) were reduced
350 rows, 388 columns, 1330 non-zeros
248 integer variables, all of which are binary
Scaling...
 A: min|aij| =  1.000e+00  max|aij| =  1.100e+01  ratio =  1.100e+01
GM: min|aij| =  6.810e-01  max|aij| =  1.468e+00  ratio =  2.156e+00
EQ: min|aij| =  4.721e-01  max|aij| =  1.000e+00  ratio =  2.118e+00
2N: min|aij| =  5.000e-01  max|aij| =  1.500e+00  ratio =  3.000e+00
Constructing initial basis...
Size of triangular part is 350
Solving LP relaxation...
GLPK Simplex Optimizer 5.0
350 rows, 388 columns, 1330 non-zeros
      0: obj =   0.000000000e+00 inf =   6.150e+02 (123)
     92: obj =   0.000000000e+00 inf =   1.465e-14 (0)
OPTIMAL LP SOLUTION FOUND
Integer optimization begins...
Long-step dual simplex will be used
Gomory's cuts enabled
MIR cuts enabled
Cover cuts enabled
Number of 0-1 knapsack inequalities = 140
Clique cuts enabled
Constructing conflict graph...
Conflict graph has 140 + 140 = 280 vertices
+    92: mip =     not found yet >=              -inf        (1; 0)
Cuts on level 0: gmi = 29; mir = 92; cov = 2;
Cuts on level 31: gmi = 40; mir = 120; cov = 9;
+ 15905: >>>>>   0.000000000e+00 >=   0.000000000e+00   0.0% (47; 285)
+ 15905: mip =   0.000000000e+00 >=     tree is empty   0.0% (0; 417)
INTEGER OPTIMAL SOLUTION FOUND
Time used:   1.7 secs
Memory used: 3.8 Mb (3960637 bytes)

Found a father pattern:

0 1 0 1 1 1 0 0 0 1 0 1
1 0 1 0 0 0 1 1 0 1 0 1
1 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 1 1 0 1 0 1 0 0
0 1 0 0 1 0 0 0 1 0 1 0
0 0 1 1 0 0 0 1 0 0 1 1
0 0 1 1 0 0 0 1 0 0 0 0
1 0 0 0 0 1 1 0 0 0 1 0
1 0 0 0 1 0 0 0 1 0 1 0

The father pattern in rle format:

bobooobbbobo$obobbboobobo$obobbbbbbbbb$bbbboobobobb$bobbobbbobob$bboobbbobboo$bboobbbobbbb$obbbboobbbob$obbbobbbobob$!

Model has been successfully processed
#
Note that SAT-solver based GoE checker tools are much more efficient thatn generic ILP model based software, like the above. Feel free to ask about this GoE checker model!
User avatar
b-engine
Posts: 3762
Joined: October 26th, 2023, 4:11 am
Location: Somewhere on where Earth At
Contact:

Re: Thread for your script-related questions

Post by b-engine »

Is there any ikpx2 variant that could work with 3-state rules?
Sokwe
Moderator
Posts: 3375
Joined: July 9th, 2009, 2:44 pm

Re: Thread for your script-related questions

Post by Sokwe »

b-engine wrote: January 30th, 2025, 1:47 am Is there any ikpx2 variant that could work with 3-state rules?
I believe the programs closest to this description are cfind and rlifesrc. From experience, most spaceship search programs seem to heavily utilize the simplifying assumption that the searched rule is 2-state, so I would think that making ikpx2 work for 3-state rules would require a substantial rewrite.
-Matthias Merzenich
User avatar
b-engine
Posts: 3762
Joined: October 26th, 2023, 4:11 am
Location: Somewhere on where Earth At
Contact:

Re: Thread for your script-related questions

Post by b-engine »

I'm trying to compile APGsearch in WSL on Windows 11, but due to an error I couldn't do so:

Code: Select all

Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
   just raised the bar for easy, resilient and secure K8s cluster deployment.

   https://ubuntu.com/engage/secure-kubernetes-at-the-edge

This message is shown once a day. To disable it please create the
/home/t6970/.hushlogin file.
t6970@User:~$ git clone https://gitlab.com/apgoucher/apgmera.git
Cloning into 'apgmera'...
remote: Enumerating objects: 2133, done.
remote: Counting objects: 100% (313/313), done.
remote: Compressing objects: 100% (110/110), done.
remote: Total 2133 (delta 203), reused 308 (delta 202), pack-reused 1820 (from 1)
Receiving objects: 100% (2133/2133), 744.15 KiB | 5.28 MiB/s, done.
Resolving deltas: 100% (1466/1466), done.
t6970@User:~$ cd apgmera
t6970@User:~/apgmera$ ./recompile.sh
./recompile.sh: line 9: make: command not found
What's wrong with recompile.sh?
Sokwe
Moderator
Posts: 3375
Joined: July 9th, 2009, 2:44 pm

Re: Thread for your script-related questions

Post by Sokwe »

b-engine wrote: February 3rd, 2025, 9:50 am I'm trying to compile APGsearch in WSL on Windows 11, but due to an error I couldn't do so:

Code: Select all

...
./recompile.sh: line 9: make: command not found
What's wrong with recompile.sh?
It seems that you don't have make installed. In a WSL terminal, run the following commands in order:

Code: Select all

sudo apt update

sudo apt upgrade

sudo apt-get install build-essential

sudo apt-get install python3
This is taken from step 6 of the WSL2 section of the compiling tutorial. After that, try running the recompile script again.
-Matthias Merzenich
User avatar
b-engine
Posts: 3762
Joined: October 26th, 2023, 4:11 am
Location: Somewhere on where Earth At
Contact:

Re: Thread for your script-related questions

Post by b-engine »

Sokwe wrote: February 3rd, 2025, 7:54 pm
I finally resolved the issues and could run APGsearch for 2-state isotropic rules.

How to configure APGsearch to run for ruletable rules?
User avatar
confocaloid
Posts: 6697
Joined: February 8th, 2022, 3:15 pm
Location: learn to protect yourself against stray gliders and sparks and self-destruct mechanisms

Re: Thread for your script-related questions

Post by confocaloid »

b-engine wrote: February 3rd, 2025, 10:41 pm How to configure APGsearch to run for ruletable rules?
One reasonably straightforward way is
(1) Copy the ".rule" file into the same directory/folder where you have "recompile.sh". Note that the filename needs to follow the naming conventions (begin with an uppercase letter, no characters other than alphanumeric/underscore/hyphen).
(2) Instead of a rulestring, pass the filename into recompile.sh for example:

Code: Select all

./recompile.sh --rule ./MyNewCA.rule --symmetry D8_4
I think that should work (at least for isotropic CA on the square tiling - I think the assumption of isotropic would be hard to eliminate from the codebase and the exchange formats, and even for the hexagonal tiling there may be some issues due to the same object appearing in different orientations).

For more information, see README.md in https://gitlab.com/apgoucher/apgmera
(e.g. you can test locally by running apgluxe with "-t 1 -L 1", which disables uploading to Catagolue and saves a local log of each haul)
127:1 B3/S234c User:Confocal/R (isotropic CA, incomplete)
Unlikely events happen.
My silence does not imply agreement, nor indifference. If I disagreed with something in the past, then please do not construe my silence as something that could change that.
User avatar
Katrina
Posts: 161
Joined: September 26th, 2024, 3:23 am

Re: Thread for your script-related questions

Post by Katrina »

Is this code able to be fixed? It is meant to be a search program that has the same function as lifesrc. I am doing this so that people have an easy way to search for spaceships without having too much knowledge in programming.
There are 3 main problems I have that need to be solved.
1: Searching doesn't work perfectly. It does look like it is doing something in the code, but it never calls the backup function and the consistency function may be incorrect.
2: If you set the period above 1, it stops the script immediately after starting.
3: There is no implication function or anything because I don't know how to calculate the rules for it.

The reason why everything is calculated in numpy arrays is because there is no unknown state in Golly.

I've been working on this for days, I really need help with this.

Code: Select all

import math
import random
import golly as g
import numpy as np
from collections import deque
velx = 0
vely = 0

period = 1
width = 8
height = 8

neighbor = [(-1, -1), (-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1)]

def tocells(n, x, y, z=0, w=0):
    c = []
    for q in np.argwhere(n>0.5):
        c.extend([q[0]+z,q[1]+w])
    return c

def toarray(c, x, y, z=0, w=0):
    n = np.zeros((x, y), dtype=np.int32)
    for i in range(0, len(c), 2):
        if 0 <= c[i]+z < x and 0 <= c[i+1]+w < y:
            n[c[i]+z, c[i+1]+w] = 1
    return n

def evolve(x, p, width=width, height=height):
    return toarray(g.evolve(tocells(x, width, height, 0, 0), p), width, height, 0, 0)

def display(r, x=0, y=0):
    if len(g.getrect()) != 0:
        g.select(g.getrect())
        g.clear(0)
        g.select([])
    g.putcells(g.transform(tocells(r, 0, 0), x, y))
    g.update()

cells = np.full((width, height, period), -1)
free = np.ones((width, height, period))
q = deque()
nextset = 0

def setcell(x, y, t, s, f):
    if cells[x, y, t] == s:
        return 1

    if cells[x, y, t] != -1:
        return 0

    cells[x, y, t] = s
    free[x, y, t] = f
    q.append([x, y, t, s, f])
    return 1

def consistify(x, y, t):
    t %= period
    prevcell = cells[x, y, t-1]
    nextprevcell = evolve(cells[:, :, t-1], 1)[x, y]
    if nextprevcell != cells[x, y, t]:
        if prevcell == 1:
            if cells[x, y, t] == 0:
                return 0
            cells[x, y, t] = 0
            free[x, y, t] = 0
            q.append([x, y, t, 1, 0])
        if prevcell == 0:
            if cells[x, y, t] == 1:
                return 0
            cells[x, y, t] = 1
            free[x, y, t] = 0
            q.append([x, y, t, 0, 0])
    if nextprevcell == 0 and cells[x, y, t] == 0 and setcell(x, y, t-1, 0, 0) != 1:
        return 0
    if nextprevcell == 1 and cells[x, y, t] == 1 and setcell(x, y, t-1, 1, 0) != 1:
        return 0
    s = -1
    if nextprevcell == 1 and cells[x, y, t] == -1:
        s = 0
    if nextprevcell == 0 and cells[x, y, t] == -1:
        s = 1
    if s == -1:
        return 1
    for i, j in neighbor:
        if 0 < x+i < width and 0 < y+j < height:
            if cells[x+i, y+j, t-1] == -1 and setcell(x+i, y+j, t-1, s, 0) != 1:
                return 0
    return 1

def consistify10(x, y, t):
    g.show(str(q))
    display(cells[:, :, 0])
    if consistify(x, y, t) != 1:
        return 0
    for i, j in neighbor:
        if 0 < x+i < width and 0 < y+j < height:
            if consistify(x+i, y+j, t+1) != 1:
                return 0
    return 1

def examinenext():
    if nextset == len(q):
        return 2
    cell = q.popleft()
    return consistify10(cell[0], cell[1], cell[2])

def proceed(x, y, t, s, f):
    if setcell(x, y, t, s, f) != 1:
        return 0
    while True:
        status = examinenext()
        if status == 0:
            return 0
        if status == 2:
            return 1

def backup():
    while len(q) != 0:
        cell = q.popleft()
        if cell[4] == 0:
            cells[cell[0], cell[1], cell[2]] = -1
            free[cell[0], cell[1], cell[2]] = 1
        else:
            nextset = len(q)
            return cell
    nextset = 0
    return "NULL"

def go(x, y, t, s, f):
    while True:
        status = proceed(x, y, t, s, f)
        if status == 1:
            return 1
        cell = backup()
        if cell == "NULL":
            return 0
        f = 0
        s = 1 - cells[x, y, t]
        cells[x, y, t] = -1

def getunknown():
    if len(np.argwhere(cells == -1)) != 0:
        return np.argwhere(cells == -1)[-1].tolist()
    return "NULL"

def search():
    cell = getunknown()
    if cell == "NULL":
        cell = backup()
        if cell == "NULL":
            return 0
        f = 0
        s = 1 - cell[3]
        cells[cell[0], cell[1], cell[2]] = -1
    else:
        f = 1
        s = 1
    while True:
        if go(cell[0], cell[1], cell[2], f, s) != 1:
            return 0

        cell = getunknown()
        if cell == "NULL":
            return 1
        f = 1
        s = 1

search()
User avatar
confocaloid
Posts: 6697
Joined: February 8th, 2022, 3:15 pm
Location: learn to protect yourself against stray gliders and sparks and self-destruct mechanisms

Re: Thread for your script-related questions

Post by confocaloid »

Sylvani wrote: February 5th, 2025, 10:21 pm Is this code able to be fixed? [...]
Not an answer, but it looks like the same or closely related code was posted in another thread: viewtopic.php?p=203219#p203219 (although without a direct link or mention). Is that post now redundant to this post? Maybe there should be just a link instead of duplicating the code.
Last edited by confocaloid on February 6th, 2025, 12:35 am, edited 3 times in total.
127:1 B3/S234c User:Confocal/R (isotropic CA, incomplete)
Unlikely events happen.
My silence does not imply agreement, nor indifference. If I disagreed with something in the past, then please do not construe my silence as something that could change that.
Post Reply