ofind

For scripts to aid with computation or simulation in cellular automata.
Post Reply
User avatar
Scorbie
Posts: 1445
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)
- Adjustable memory usage depending on RAM. (Compile with -mcmodel=medium)
- May 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.
ofind.c
Slightly modified ofind.c
I edited line 91 (#define STATE_SPACE_SIZE) for memory usage
(48.5 KiB) Downloaded 263 times
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
Best wishes to you, Scorbie

User avatar
Scorbie
Posts: 1445
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
Best wishes to you, Scorbie

Dannyu NDos
Posts: 6
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: 1345
Joined: August 9th, 2013, 12:45 am

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 latest version of the 5S Project contains over 226,000 spaceships. There is also a GitHub mirror of the collection. Tabulated pages up to period 160 (out of date) are available on the LifeWiki.

User avatar
Scorbie
Posts: 1445
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 15 times
Seems to work, but this was done hastily so don't set up your hopes too high...
Best wishes to you, Scorbie

User avatar
Scorbie
Posts: 1445
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!
Best wishes to you, Scorbie

User avatar
LaundryPizza03
Posts: 530
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

Post Reply