ofind

For scripts to aid with computation or simulation in cellular automata.
Post Reply
User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

ofind

Post by Scorbie » September 26th, 2018, 3:38 am

Okay, this has been sitting dormant in my computer for a while, and it's certainly not polished, but reading this made me open my ofind tools:

1. Mods to ofind.c
- Reports last partial every deeping iteration (Yeah, I know it isn't much)
- Have to compile with -m32 on Windows (AFAIK also present in the vanilla ofind.c)
I forgot the details, but line 91 can be adjusted to use more memory.
Edit: Moved below; Direct link
2. golly frontend, ofind.lua
- Select one or two *working* partial rows from a partial oscillator in Golly.
e.g. An example selection would be the State 3,4 cells in this pattern:

Code: Select all

x = 18, y = 27, rule = LifeHistory
8.2A$4.2A.4B.2A$3.A.8B.A$3.A.A6BA.A$.3A.A.ABDCDCD3CD$A4.2ABACD2C4DC$.
3A.A6BA.3A$3.A4B2A4BA$3.BA3B2A3BAB$4.BA6BAB$5.B6AB$3.A.B6AB.A$.3A.B2A
2B2AB.3A$A4.B2A2B2AB4.A$.3A.B2A2B2AB.3A$3.A.B6AB.A$5.B6AB$4.BA6BAB$3.
BA3B2A3BAB$3.A4B2A4BA$.3A.A6BA.3A$A4.2AB2AB2A4.A$.3A.A.A2BA.A.3A$3.A.
A6BA.A$3.A.8B.A$4.2A.4B.2A$8.2A!
[[ THUMBNAIL ]]
- Run the script.
- Enter the period as 7 (or whatever period of which the oscillator you are searching for)
- The script copies the necessary rows to the clipboard.
- paste this to make an input file like this: (p7hw2.txt)
- And run ofind < p7hw2.txt (and optionally > p7hw2.log.txt to redirect the logs into a file)

Code: Select all

b3s23
7
even
n  # symmetric completions
7
2
y

2
.o.o.ooo.
oo.o.ooo.
...o.ooo.
oo.o.ooo.
...o.ooo.
o..o.ooo.
o..o.ooo.
o.oo....o
oo.o....o
...o....o
..oo....o
oo.o....o
.o.o....o
o..o....o
Demo on how ofind interprets these files: (this file itself would not run)

Code: Select all

ofind 0.9, D. Eppstein, 14 August 2000
Type ? at any prompt for help, or ^ to return to a previous prompt.
Rule: b3s23
Period: 7
Symmetry type (even, odd, none): even
Allow symmetric completion of patterns (yes, no): y
Rotor width: 5
Stator width: 5
Allow final stator rows to exceed width limit (yes, no): y
Maximum deepening amount: 
Number of initially specified rows: 2
Specify initial phase of each row; '.'=dead, 'o'=live.
Phase 0: o
Phase 1: .
Phase 2: .
Phase 3: .
Phase 4: .
Phase 5: .
Phase 6: .
Phase 0: ...oo
Phase 1: ....o
Phase 2: ....o
Phase 3: ....o
Phase 4: o...o
Phase 5: o...o
Phase 6: oo.oo
Last edited by Scorbie on December 27th, 2020, 5:53 am, edited 2 times in total.

User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

Re: ofind

Post by Scorbie » December 7th, 2018, 6:19 am

Whoops, sorry, here's ofind.lua

Code: Select all

local g = golly()

local x, y, w, h = table.unpack(g.getselrect())
if h ~= 1 and h ~= 2 then
  g.exit("ofind needs one or two rows to be specified...")
end

local period = tonumber(g.getstring("Enter the period of the osc to find."))

if h == 1 then
  local firstrows = {}
  for gen = 1,period do
    local firstrow = {}
    for i = x, x+w-1 do
      -- g.note(g.getcell(i,y))
      table.insert(firstrow, g.getcell(i, y)==1 and "o" or ".")
    end
    table.insert(firstrows, table.concat(firstrow))
    g.run(1)
  end
  g.setclipstr(table.concat(firstrows, "\n") .. "\n")
elseif h == 2 then
  local firstrows, secondrows = {}, {}
  for gen = 1,period do
    local firstrow, secondrow = {}, {}
    for i = x, x+w-1 do
      table.insert(firstrow, g.getcell(i, y)==1 and "o" or ".")
      table.insert(secondrow, g.getcell(i, y+1)==1 and "o" or ".")
    end
    table.insert(firstrows, table.concat(firstrow))
    table.insert(secondrows, table.concat(secondrow))
    g.run(1)
  end
  g.setclipstr(table.concat(firstrows, '\n') .. '\n' .. table.concat(secondrows, '\n') .. "\n")
end

Dannyu NDos
Posts: 7
Joined: January 6th, 2019, 3:27 am

Re: ofind

Post by Dannyu NDos » September 12th, 2019, 11:34 pm

I can't build ofind.c:

Code: Select all

ndos@ndos-desktop:~/Documents$ gcc -o ofind ofind.c
ofind.c: In function ‘printApprox’:
ofind.c:1147:26: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
  if (n <= 9999) printf("%d",n);
                         ~^  ~
                         %ld
ofind.c:1154:27: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
   if (n > 99999) printf("%d%c", n/1000, unit);
                          ~^     ~~~~~~
                          %ld
ofind.c:1155:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
   else printf("%d.%c%c", n/1000, (n%1000)/100+'0', unit);
                ~^        ~~~~~~
                %ld
ofind.c:1155:20: warning: format ‘%c’ expects argument of type ‘int’, but argument 3 has type ‘long int’ [-Wformat=]
   else printf("%d.%c%c", n/1000, (n%1000)/100+'0', unit);
                   ~^             ~~~~~~~~~~~~~~~~
                   %ld
ofind.c: In function ‘readString’:
ofind.c:1296:2: warning: format not a string literal and no format arguments [-Wformat-security]
  fprintf(stderr, prompt);
  ^~~~~~~
/tmp/cctYLl0O.o: in function `listRows':
ofind.c:(.text+0xb52): relocation truncated to fit: R_X86_64_PC32 against symbol `firstRow' defined in COMMON section in /tmp/cctYLl0O.o
ofind.c:(.text+0xbb6): relocation truncated to fit: R_X86_64_PC32 against symbol `firstRow' defined in COMMON section in /tmp/cctYLl0O.o
/tmp/cctYLl0O.o: in function `testCompatible':
ofind.c:(.text+0xcd5): relocation truncated to fit: R_X86_64_PC32 against symbol `firstRow' defined in COMMON section in /tmp/cctYLl0O.o
ofind.c:(.text+0xe4c): relocation truncated to fit: R_X86_64_PC32 against symbol `firstRow' defined in COMMON section in /tmp/cctYLl0O.o
ofind.c:(.text+0xe88): relocation truncated to fit: R_X86_64_PC32 against symbol `firstRow' defined in COMMON section in /tmp/cctYLl0O.o
ofind.c:(.text+0xfec): relocation truncated to fit: R_X86_64_PC32 against symbol `firstRow' defined in COMMON section in /tmp/cctYLl0O.o
/tmp/cctYLl0O.o: in function `compatible':
ofind.c:(.text+0x10b7): relocation truncated to fit: R_X86_64_PC32 against symbol `firstRow' defined in COMMON section in /tmp/cctYLl0O.o
ofind.c:(.text+0x10f3): relocation truncated to fit: R_X86_64_PC32 against symbol `firstRow' defined in COMMON section in /tmp/cctYLl0O.o
/tmp/cctYLl0O.o: in function `testReachable':
ofind.c:(.text+0x1231): relocation truncated to fit: R_X86_64_PC32 against symbol `firstRow' defined in COMMON section in /tmp/cctYLl0O.o
ofind.c:(.text+0x1250): relocation truncated to fit: R_X86_64_PC32 against symbol `firstRow' defined in COMMON section in /tmp/cctYLl0O.o
ofind.c:(.text+0x147d): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
The former account 'David' is lost and unused. My real name is "Park Shinhwan".

wildmyron
Posts: 1544
Joined: August 9th, 2013, 12:45 am
Location: Western Australia

Re: ofind

Post by wildmyron » September 12th, 2019, 11:49 pm

Dannyu NDos wrote:I can't build ofind.c:

Code: Select all

<snip>
As mentioned in the OP, you need to build with "-mcmodel=medium". I presume that's because Scorbie's modifications allocate some large arrays statically rather than dynamically.
The 5S project (Smallest Spaceships Supporting Specific Speeds) is now maintained by AforAmpere. The latest collection is hosted on GitHub and contains well over 1,000,000 spaceships.

Semi-active here - recovering from a severe case of LWTDS.

User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

Re: ofind

Post by Scorbie » October 26th, 2019, 7:11 am

wildmyron wrote:
September 12th, 2019, 11:49 pm
Dannyu NDos wrote:I can't build ofind.c:

Code: Select all

<snip>
As mentioned in the OP, you need to build with "-mcmodel=medium". I presume that's because Scorbie's modifications allocate some large arrays statically rather than dynamically.
Yes, that was my intent. Unfortunately building with `-mcmodel=medium` doesn't seem to be good practice so I changed the code to allocate the big chuck dynamically:
ofind.c
(48.61 KiB) Downloaded 292 times
Seems to work, but this was done hastily so don't set up your hopes too high...

User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

Re: ofind

Post by Scorbie » November 17th, 2019, 11:00 am

Currently was able to use that program with no big problems.
There seems to be a bug in ofind, as the smallest p5 fountain it reported was:

Code: Select all

x = 26, y = 31, rule = B3/S23
12bo$10bo3bo3$11bobo$3b2o2b4obob4o2b2o$3bo2bo3b5o3bo2bo$2obob2o11b2obo
b2o$bobo3b3o2bo2b3o3bobo$bob2o2b2obobobob2o2b2obo$2obo2bo3bobobo3bo2bo
b2o$3bobo5bobo5bobo$3bo5bobobobo5bo$2b2obobo2b2ob2o2bobob2o$o2bob2o11b
2obo2bo$2obo17bob2o$3bo2bo11bo2bo$3bobo3bo2bo2bo3bobo$4b2ob2ob5ob2ob2o
$bo4b2o2bobobo2b2o4bo$b4obo5bo5bob4o$4bobo2b2o3b2o2bobo$ob2o2bobo2bobo
2bobo2b2obo$2obob2obo3bo3bob2obob2o$3bo2bobo2b3o2bobo2bo$4obo2b9o2bob
4o$o3bob2o9b2obo3bo$bo2bo3b2o5b2o3bob2o$2bobo3bo4b3o2b2obobobo$3bo5bo
2bo4b2o2bo2b2o$8b2o2b2o6b2o!
Although I was able to find a smaller solution.

Code: Select all

x = 25, y = 26, rule = B3/S23
12bo$10bo3bo3$11bobo$3b2o2b4obob4o2b2o$3bo2bo3b5o3bo2bo$2obob2o11b2obo
b2o$bobo3b3o2bo2b3o3bobo$bob2o2b2obobobob2o2b2obo$2obo2bo3bobobo3bo2bo
b2o$3bobo5bobo5bobo$3bo5bobobobo5bo$bobobobo2b2ob2o2bobobobo$ob2ob2o
11b2ob2obo$o5bo11bo5bo$b2ob3o3b2ob2o3b3ob2o$2bobo2bo3bobo3bo2bobo$2bob
o3bobo3bobo3bobo$b2obo6b3o6bob2o$o2b2ob2o9b2ob2o2bo$bo3bo3b7o3bo3bo$2b
2o2b4o2bo2b4o2b2o$4b2o13b2o$4bo2bo9bo2bo$6b2o9b2o!

User avatar
LaundryPizza03
Posts: 2323
Joined: December 15th, 2017, 12:05 am
Location: Unidentified location "https://en.wikipedia.org/wiki/Texas"

Re: ofind

Post by LaundryPizza03 » February 15th, 2020, 4:20 am

It looks like the lua version could probably be applied to a non-totalistic rule, but I am too busy running a 5s search to determine if this is indeed the case.

The one I want to complete is this p13 partial from LeapLife, due to wildmyron:

Code: Select all

x = 22, y = 7, rule = B2n3/S23-q
20bo$10b2o5b2obo$3b2o4bo2bo4b4o$2ob3o2bo5b2o5bo$3b2o4bo2bo4b4o$10b2o5b
2obo$20bo!
EDIT: It works, but ofind.lua in general is near-useless. Maybe an NT version of ofind.c could be of help here.
EDIT2: Looks like I didn't read the instructions...

Code: Select all

x = 4, y = 3, rule = B3-q4z5y/S234k5j
2b2o$b2o$2o!
LaundryPizza03 at Wikipedia

User avatar
LaundryPizza03
Posts: 2323
Joined: December 15th, 2017, 12:05 am
Location: Unidentified location "https://en.wikipedia.org/wiki/Texas"

Re: ofind

Post by LaundryPizza03 » September 17th, 2020, 4:36 pm

I'm having trouble compiling ofind with gcc, despite generating no errors like when I tried to compile gfind. It fails to make an executable file.

Code: Select all

> gcc ofind.c                
ofind.c:1136:29: warning: format specifies type 'int' but the argument has type
      'long' [-Wformat]
        if (n <= 9999) printf("%d",n);
                               ~~  ^
                               %ld
ofind.c:1143:33: warning: format specifies type 'int' but the argument has type
      'long' [-Wformat]
                if (n > 99999) printf("%d%c", n/1000, unit);
                                       ~~     ^~~~~~
                                       %ld
ofind.c:1144:26: warning: format specifies type 'int' but the argument has type
      'long' [-Wformat]
                else printf("%d.%c%c", n/1000, (n%1000)/100+'0', unit);
                             ~~        ^~~~~~
                             %ld
ofind.c:1144:34: warning: format specifies type 'int' but the argument has type
      'long' [-Wformat]
                else printf("%d.%c%c", n/1000, (n%1000)/100+'0', unit);
                                ~~             ^~~~~~~~~~~~~~~~
                                %ld
ofind.c:1284:18: warning: format string is not a string literal
      (potentially insecure) [-Wformat-security]
        fprintf(stderr, prompt);
                        ^~~~~~
ofind.c:1284:18: note: treat the string as an argument to avoid this
        fprintf(stderr, prompt);
                        ^
                        "%s", 
5 warnings generated.

Code: Select all

x = 4, y = 3, rule = B3-q4z5y/S234k5j
2b2o$b2o$2o!
LaundryPizza03 at Wikipedia

wildmyron
Posts: 1544
Joined: August 9th, 2013, 12:45 am
Location: Western Australia

Re: ofind

Post by wildmyron » September 17th, 2020, 9:30 pm

LaundryPizza03 wrote:
September 17th, 2020, 4:36 pm
I'm having trouble compiling ofind with gcc, despite generating no errors like when I tried to compile gfind. It fails to make an executable file.

Code: Select all

<snip warnings>
If you don't supply a name for the binary to gcc, e.g. with "-o ofind", then the output filename will be a.out
I'm not sure if clang's behaviour is the same but that's probably what has happened.
The 5S project (Smallest Spaceships Supporting Specific Speeds) is now maintained by AforAmpere. The latest collection is hosted on GitHub and contains well over 1,000,000 spaceships.

Semi-active here - recovering from a severe case of LWTDS.

User avatar
LaundryPizza03
Posts: 2323
Joined: December 15th, 2017, 12:05 am
Location: Unidentified location "https://en.wikipedia.org/wiki/Texas"

Re: ofind

Post by LaundryPizza03 » September 17th, 2020, 11:29 pm

Ofind could use some more improvement. This was an attempt to find a p5:

Code: Select all

x = 12, y = 63, rule = B3/S2
5b2o$4bo2bo$4bo2bo$5b2o$bo8bo$obo6bobo$bo8bo2$3b2o2b2o$4bo2bo$2bo6bo$b
ob6obo$bo8bo$2b8o2$4b4o$3bo4bo$4bo2bo$2bobo2bobo$bobo4bobo$bo8bo$2bo6b
o$3bo4bo$4bo2bo$2bobo2bobo$bobo4bobo$bo8bo$2bo6bo$3bo4bo$4bo2bo$b3o4b
3o$o10bo$bo8bo$2bo6bo$3bo4bo$4bo2bo$b3o4b3o$o10bo$b3o4b3o$4bo2bo$b3o4b
3o$o10bo$bo8bo$2bo6bo$3bo4bo$4bo2bo$b3o4b3o$o10bo$b3o4b3o$4bo2bo$b3o4b
3o$o10bo$ob2o4b2obo$bo2bo2bo2bo$3bo4bo$4b4o2$2b8o$bo8bo$bob6obo$2bo6bo
$4bo2bo$3b2o2b2o!
Compare this, which is the largest partial I found with JLS:

Code: Select all

x = 16, y = 22, rule = B3/S2
4bo6bo$b2o3b4o3b2o$2b3obo2bob3o$2bo4b2o4bo$2bobo6bobo$3b2o6b2o$3b2o6b
2o$3bo2b4o2bo$5bo4bo$5b2o2b2o$o4b2o2b2o4bo$o4b2o2b2o4bo$5b2o2b2o$5bo4b
o$3bo2b4o2bo$3b2o6b2o$3b2o6b2o$2bobo6bobo$2bo4b2o4bo$2b3obo2bob3o$b2o
3b4o3b2o$4bo6bo!

Code: Select all

x = 4, y = 3, rule = B3-q4z5y/S234k5j
2b2o$b2o$2o!
LaundryPizza03 at Wikipedia

User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

Re: ofind

Post by Scorbie » September 18th, 2020, 10:11 am

Note: You have to compile ofind for 32bit architecture. (`-m32` in gcc AFAIK)
LaundryPizza03 wrote:
September 17th, 2020, 11:29 pm
Ofind could use some more improvement. This was an attempt to find a p5:

Code: Select all

Some ofind partial
Compare this, which is the largest partial I found with JLS:

Code: Select all

Some JLS partial
What were you trying to search? And what were your input params for ofind?
ofind is most useful for extending partials with minimal width.

Post Reply