How to use Afind (on a mac)

For scripts to aid with computation or simulation in cellular automata.
Post Reply
EricG
Posts: 199
Joined: August 19th, 2011, 5:41 pm
Location: Chicago-area, USA

How to use Afind (on a mac)

Post by EricG » January 22nd, 2012, 1:08 am

This post is a follow-up to this discussion of how to use gfind on the mac: viewtopic.php?f=7&t=826

Download the latest version of afind here: http://plife.sourceforge.net/programs/afind.cc

As before, put it in your SearchPrograms folder.

Go to the terminal program, change your directory to SearchPrograms,
but this time, compile it using this command: g++ -o afind afind.cc

Unlike gfind, you specify searches in Afind using a separate text file.

Leave the terminal program for a moment, and make a text file called, say, "find-latest.txt".
Put the following specifications into the text file:

afind-0.5
width 12
period 2
rule b36/s23

and save the file in the SearchPrograms folder. The first line and the last line are required. The middle lines are ways to specify the search.

Return to the Terminal program and type this at the prompt: ./afind find-latest.txt

Depending on what options you put the find-latest.txt file, you might get an enormous outpouring of spaceships amazingly quickly. For periods 2 and 3 with reasonable widths, you'll often get many more spaceships much more quickly than with gfind. (But I believe gfind will be superior for higher periods, at least using the default specifications.)

The results are printed in Life 1.05 format (which readable by Golly, among others) right in the terminal program's output - copy and paste it the into Golly. You can copy-and-paste partial results - you don't need to wait for the program to terminate. Be sure to copy-and-paste the header information. Typical output looks like this:


====cut-and-paste======

#Life 1.05
#D Generated by afind-0.5.
#D Input parameters:
#D width = 14 (full_width = 28)
#D left_edge = 0
#D floating_rows = 0
#D period = 2
#D offset = 1
#D slide = 0
#D mode = even-bilateral symmetry
#D queue_size = 2^23
#D hash_size = 2^23
#R b3/s23

#D (73100) Sat Oct 1 14:44:25 2011
#P -160 -112
..................**........................**....................................**........................**..................
.....................*....................*........................................***.*...**......**...*.***...................
..................*...*.*..**......**..*.*...*.....................................**...*..............*...**...................
...................**...*..*........*..*...**......................................**.*.*...*......*...*.*.**...................
....................*.*.*.**........**.*.*.*..........................................*.*.**........**.*.*......................
.....................**.*.**........**.*.**..........................................**.*.*..........*.*.**.....................
......................*.*..............*.*.............................................**..............**.......................
.........................*............*.................................................*..............*........................
.......................*...**......**...*..............................................**..**.*..*.**..**.......................
.......................*......*..*......*...............................................****........****........................
........................*...*.****.*...*.................................................***.**..**.***.........................
.........................***..****..***...................................................*....**....*..........................

#D (73394) Sat Oct 1 14:44:25 2011
#P -160 -80
..................**.**..................**.**....................................**.**..................**.**..................
...................................................................................*.*....................*.*...................
..................*...*.....**....**.....*...*.....................................**.*.....**....**.....*.**...................
...................**.*..................*.**......................................**.*..*..*......*..*..*.**...................
....................*.*.*...*......*...*.*.*..........................................*.*..**......**..*.*......................
.....................**.*.***......***.*.**..........................................**.*.**........**.*.**.....................
......................*.*..............*.*.............................................**..............**.......................
.........................*............*.................................................*..............*........................
.......................*...**......**...*..............................................**..**.*..*.**..**.......................
.......................*......*..*......*...............................................****........****........................
........................*...*.****.*...*.................................................***.**..**.***.........................
.........................***..****..***...................................................*....**....*..........................


====cut-and-paste======

You'll find that spaceships get longer and longer for a specified width the longer you let a search go on.


Try adding another line to the search specifications file:
mode 0
or mode 1 or mode 2
to search for
asymmetrical spaceships, spaceships with odd symmetry, or spaceships with even symmetry.

The full list of parameters you can add (one per line in the text file) are:

"rule", "width", "period", "offset", "slide", "mode", "left_edge", "floating_rows", "queue_bits", and "hash_bits"

but frankly, I've only tried specifying with rule, width, period, and mode, and don't yet understand the others. You can scroll through the afind.cc source code and Eppstein's paper for hints on how to use the rest. I have noticed that afind is best for low periods, while gfind is better for higher periods.

One more tip for using the terminal program: the arrow keys allow you to scroll through your history of commands. That way, you don't have to retype the same command over and over.

Platypus5
Posts: 33
Joined: August 15th, 2011, 12:56 pm

Re: How to use Afind (on a mac)

Post by Platypus5 » January 22nd, 2012, 3:10 am

How do I know if it is working. I don't seem to be getting any results in terminal, yet it appears to be doing something.
Unsorted C/3 search output? Somewhat newish C/3 edgesparker? give it to me, and my "battleships" just may have a use for it. :)

Sokwe
Moderator
Posts: 2859
Joined: July 9th, 2009, 2:44 pm

Re: How to use Afind (on a mac)

Post by Sokwe » January 22nd, 2012, 5:23 am

One useful feature of afind is that it can search for spaceships with different displacements from gfind. The vertical displacement is defined by 'offset', while the horizontal displacement is defined by 'slide'. A period-3 search with an 'offset' of 0 and a 'slide' of 1 would find short, wide c/3 spaceships. Similarly, a period-6 search with an 'offset' of 2 and a 'slide' of 1 would look for p6 knightships.

Another useful feature of afind is that it periodically saves the state of the search (saved to [original file name].[number]). If you need to stop the search, you can simply start it again from the latest saved state by running afind with the newest file.
Platypus5 wrote:How do I know if it is working. I don't seem to be getting any results in terminal, yet it appears to be doing something.
As a test, save the following parameter specifications to a file and run it through afind. It should search for c/3 spaceships with a height of 5 (the search should not take more than a second).

Code: Select all

afind-0.5
rule b3/s23
width 5
period 3
offset 0
slide 1
mode 0
The output should look somewhat like this:

Code: Select all

#Life 1.05
#D Generated by afind-0.5.
#D Input parameters:
#D  width  = 5 (full_width = 5)
#D  left_edge = 1
#D  floating_rows = 0
#D  period = 3
#D  offset = 0
#D  slide  = 1
#D  mode   = asymmetrical
#D  queue_size = 2^23
#D  hash_size  = 2^23
#R b3/s23

#D (45770) Sun Jan 22 01:05:19 2012
#P -160 -112
....*...............................*................................*..........................
...*.*.............................*.*.............................**...........................
..**...............................*.*.............................**...........................
...*...............................*.................................*..........................
..*.*.............................**...............................*............................
..*...............................*.*.............................***...........................
.*................................................................*.............................
.*.*.............................***.............................**.............................
.*..*............................*.*...............................*............................
..................................*.*.............................*.*...........................
.***.............................**...............................*.*...........................
.**...............................................................*.............................
...*..............................*.................................*...........................
.**...............................*.*.............................**............................
..*.*.............................*.*.............................**............................
...*...............................*................................*...........................

#D (45801) Sun Jan 22 01:05:19 2012
#P -160 -80
...*...............................*................................*...........................
..*.*.............................*.*.............................**............................
.**...............................*.*.............................**............................
...*..............................*.................................*...........................
.**...............................................................*.............................
.***.............................**...............................*.*...........................
..................................*.*.............................*.*...........................
.*..*............................*.*...............................*............................
.*.*.............................***.............................**.............................
.*................................................................*.............................
..*...............................*.*.............................***...........................
..*.*.............................**...............................*............................
...*...............................*.................................*..........................
..**...............................*.*.............................**...........................
...*.*.............................*.*.............................**...........................
....*...............................*................................*..........................

#D (58064) Sun Jan 22 01:05:19 2012
#P -160 -48
..................................*..*............................*.**..........................
.*****...........................**..*............................**.*..........................
.*..**...........................*..*.............................*.............................
..*.*.............................***.............................**............................
..***..............................*...............................*.*..........................
...................................................................*.*..........................
...*................................*...........................................................
..*...............................**...............................*............................
..*.*.............................***.............................**............................
..*.*..............................................................*............................
.**..............................*..*.............................***...........................
.*...............................**..............................**.............................
.*..*.............................**............................................................
...................................**..............................**...........................
..**...............................*.*.............................**...........................
...*...............................*.................................*..........................
..*.*.............................**...............................*............................
..*...............................*.*.............................***...........................
.*................................................................*.............................
.*.*.............................***.............................**.............................
.*..*............................*.*...............................*............................
..................................*.*.............................*.*...........................
.***.............................**...............................*.*...........................
.**...............................................................*.............................
...*..............................*.................................*...........................
.**...............................*.*.............................**............................
..*.*.............................*.*.............................**............................
...*...............................*................................*...........................
-Matthias Merzenich

Platypus5
Posts: 33
Joined: August 15th, 2011, 12:56 pm

Re: How to use Afind (on a mac)

Post by Platypus5 » January 22nd, 2012, 12:41 pm

There we go! Thanks!

Hopefully, more battleships should be on their way.
Unsorted C/3 search output? Somewhat newish C/3 edgesparker? give it to me, and my "battleships" just may have a use for it. :)

Sokwe
Moderator
Posts: 2859
Joined: July 9th, 2009, 2:44 pm

Re: How to use Afind (on a mac)

Post by Sokwe » January 22nd, 2012, 7:39 pm

I moved this topic (and "How to use gfind") to the 'Scripts' forum (I left a "shadow topic" in the 'General Discussion' forum to so that it didn't seem to just disappear).
-Matthias Merzenich

User avatar
gmc_nxtman
Posts: 1150
Joined: May 26th, 2015, 7:20 pm

Re: How to use Afind (on a mac)

Post by gmc_nxtman » May 26th, 2015, 8:06 pm

Hi. I know this is an old thread, but I'm having a problem with the instructions posted. When I go to terminal, change the directory to my folder "SPafind", and run the command "g++ -o afind afind.cc" I get the following error:

Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I don't know what this means. Can somebody please help? :? I would love to start finding spaceships.

By the way, I'm using a mac (somewhat obviously) and already have xcode installed.

User avatar
Andrew
Moderator
Posts: 981
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: How to use Afind (on a mac)

Post by Andrew » May 26th, 2015, 9:38 pm

According to various answers on stackoverflow.com, on 10.9+ you need to use this command:

g++ -stdlib=libstdc++ -o afind afind.cc
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

User avatar
gmc_nxtman
Posts: 1150
Joined: May 26th, 2015, 7:20 pm

Re: How to use Afind (on a mac)

Post by gmc_nxtman » May 26th, 2015, 10:42 pm

Thanks. I really appreciate your help, but unfortunately for me that does not work. :oops: Sorry for the inconvenience.

Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
GalensSlverBook:SPAfind galenmcholbi$ g++ -stdlib=libstdc++ -o afind afind.cc
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
GalensSlverBook:SPAfind galenmcholbi$ g++ -stdlib=libstdc++ -o afind afind.cc
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
GalensSlverBook:SPAfind galenmcholbi$ cd /Users/galenmcholbi/Downloads/SPAfind
GalensSlverBook:SPAfind galenmcholbi$ g++ -stdlib=libstdc++ -o afind afind.cc
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
GalensSlverBook:SPAfind galenmcholbi$

User avatar
Andrew
Moderator
Posts: 981
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: How to use Afind (on a mac)

Post by Andrew » May 27th, 2015, 1:20 am

Ok, I managed to build afind on my 10.9 system (I assume you're using 10.9 or 10.10?), but I had to make a few minor changes to the code. My changes are flagged by "AKT" in this file:

http://www.trevorrow.com/golly/afind.cc

In case you still have problems building it, I've also uploaded the executable binary:

http://www.trevorrow.com/golly/afind

Hopefully this will run on your Mac. I didn't do much testing, but it seems to work.
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

User avatar
gmc_nxtman
Posts: 1150
Joined: May 26th, 2015, 7:20 pm

Re: How to use Afind (on a mac)

Post by gmc_nxtman » May 27th, 2015, 9:43 am

:D Thanks for the help Andrew! Really appreciate it! Now I hope I can make more novel discoveries... but thanks for putting your time into it and responding! Really helps!

Post Reply