Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Adam P. Goucher
slmake
Commits
f5a1288a
Commit
f5a1288a
authored
Nov 24, 2018
by
Adam P. Goucher
Browse files
Allow LifeHistory input files
parent
e5bb0f76
Pipeline
#37733461
passed with stages
in 5 minutes and 37 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
24 deletions
+54
-24
headers/slsparse.h
headers/slsparse.h
+36
-14
infile.mc
infile.mc
+12
-5
lifelib
lifelib
+1
-1
slsparse.cpp
slsparse.cpp
+5
-4
No files found.
headers/slsparse.h
View file @
f5a1288a
...
...
@@ -20,12 +20,13 @@ namespace apg {
cghq
cg
;
elbowlab
el
;
classifier
cfier
;
lifetree_abstract
<
uint32_t
>*
lab
;
std
::
string
corderpush
;
std
::
string
normalpush
;
lifetree_abstract
<
uint32_t
>*
lt2state
;
sparselab
(
lifetree_abstract
<
uint32_t
>*
lt
)
:
cfier
(
lt
,
"b3s23"
)
{
lab
=
lt
;
lt2state
=
lt
;
std
::
cerr
<<
"Loading elbow recipes..."
<<
std
::
endl
;
...
...
@@ -46,6 +47,8 @@ namespace apg {
pattern
get_exclusions
(
pattern
inpat
)
{
auto
lab
=
inpat
.
getlab
();
pattern
excl
(
lab
,
""
,
"b3s23"
);
bitworld
live
=
inpat
.
flatlayer
(
0
);
...
...
@@ -66,6 +69,7 @@ namespace apg {
pattern
get_lowerright
(
pattern
inpat
,
uint64_t
minpop
,
int
radius
)
{
// Get a lower-right chunk of an input pattern.
auto
lab
=
inpat
.
getlab
();
pattern
convrect
(
lab
,
lab
->
rectangle
(
-
radius
,
-
radius
,
2
*
radius
+
1
,
2
*
radius
+
1
),
"b3s23"
);
pattern
rempat
=
inpat
;
pattern
diag
=
diagonalise
(
inpat
);
...
...
@@ -101,7 +105,10 @@ namespace apg {
return
chunk
;
}
bool
is_narrow
(
pattern
inf
,
pattern
m
)
{
bool
is_narrow
(
pattern
infi
,
pattern
m
)
{
pattern
inf
(
lt2state
,
""
,
"b3s23"
);
inf
+=
infi
;
auto
lab
=
inf
.
getlab
();
pattern
findme
(
lab
,
"4$2bo$bobob2o$o2bob2o$obo$bo!"
,
"b3s23"
);
pattern
tri
(
lab
,
"5o$4o$3o$2o$o!"
,
"b3s23"
);
...
...
@@ -117,14 +124,16 @@ namespace apg {
x
=
x
>>
1
;
}
tri
=
m
.
convolve
(
tri
);
tri
=
m
.
convolve
(
tri
.
bror
()
);
pattern
infx
=
inf
-
m
.
convolve
(
findme
);
pattern
infx
=
inf
-
m
.
convolve
(
findme
)
.
bror
()
;
return
((
infx
&
tri
(
45
,
45
))
-
tri
(
-
45
,
-
45
)
==
infx
);
}
std
::
pair
<
pattern
,
pattern
>
diagsplit
(
pattern
inf
,
pattern
m
,
bool
duplicate
)
{
auto
lab
=
inf
.
getlab
();
pattern
findme
(
lab
,
"4$2bo$bobob2o$o2bob2o$obo$bo!"
,
"b3s23"
);
pattern
tri
(
lab
,
"5o$4o$3o$2o$o!"
,
"b3s23"
);
tri
=
tri
(
-
2
,
-
2
);
...
...
@@ -139,11 +148,12 @@ namespace apg {
x
=
x
>>
1
;
}
tri
=
m
.
convolve
(
tri
);
tri
=
m
.
convolve
(
tri
.
bror
()
);
pattern
infx
=
inf
-
m
.
convolve
(
findme
);
pattern
infx
=
inf
-
m
.
convolve
(
findme
)
.
bror
()
;
pattern
middle
=
(
infx
&
tri
(
30
,
30
))
-
tri
(
-
30
,
-
30
);
pattern
middle
(
lt2state
,
""
,
"b3s23"
);
middle
+=
((
infx
&
tri
(
30
,
30
))
-
tri
(
-
30
,
-
30
));
if
(
middle
.
nonempty
())
{
if
(
duplicate
)
{
...
...
@@ -162,11 +172,14 @@ namespace apg {
/*
* More scalable version of cg.preiterate.
*/
// Coerce to a 2-state pattern:
pattern
inf
(
lt2state
,
""
,
"b3s23"
);
inf
+=
infx
;
std
::
cout
<<
"
\033
[36;1mCalling sparsebuild on initial pattern comprising "
;
std
::
cout
<<
(
inf
x
.
popcount
((
1
<<
30
)
+
3
))
<<
" cells
\033
[0m"
<<
std
::
endl
;
std
::
cout
<<
(
inf
.
popcount
((
1
<<
30
)
+
3
))
<<
" cells
\033
[0m"
<<
std
::
endl
;
cgsalvo
<
int64_t
>
cs
;
pattern
inf
=
infx
;
do
{
// Capture any existing gliders:
pattern
spat
=
inf
&
inf
[
2
]
&
inf
[
4
]
&
inf
[
6
]
&
inf
[
8
];
...
...
@@ -227,6 +240,8 @@ namespace apg {
std
::
cerr
<<
"Trying ne_constell()"
<<
std
::
endl
;
auto
lab
=
infx
.
getlab
();
pattern
origin_block
(
lab
,
"oo$oo!"
,
"b3s23"
);
origin_block
=
origin_block
(
bbox2
[
0
],
bbox2
[
1
]);
...
...
@@ -290,10 +305,12 @@ namespace apg {
int64_t
bbox3
[
4
]
=
{
bbox2
[
0
]
-
47
,
bbox2
[
1
]
-
42
,
bbox2
[
2
],
bbox2
[
3
]};
auto
lab
=
infx
.
getlab
();
pattern
findme2
(
lab
,
"3b2o$2bo2bo$bob2obo$obo2bobo$obo2bobo$bob2obo$2bo2bo$3b2o!"
,
"b3s23"
);
pattern
findme3
(
lab
,
"3$3b2H$3b2H!"
,
"b3s23"
);
pattern
replaceme2
(
lab
,
"3$3b2o$3b2o!"
,
"b3s23"
);
pattern
existing_hands
=
infx
.
match
(
findme2
);
pattern
existing_hands
=
infx
.
match
(
findme2
)
+
infx
.
match
(
findme3
)
;
bool
existing_hand
=
existing_hands
.
nonempty
();
...
...
@@ -348,11 +365,13 @@ namespace apg {
pattern
target_to_glider
(
pattern
inf
)
{
auto
lab
=
inf
.
getlab
();
pattern
resultant
(
lab
,
""
,
"b3s23"
);
pattern
findme
(
lab
,
"6$4bo$3bobob2o$2bo2bob2o$2bobo$3bo!"
,
"b3s23"
);
pattern
replaceme
(
lab
,
"7$7b2o$7b2o2$3o$2bo$bo!"
,
"b3s23"
);
pattern
findme2
(
lab
,
"3b2o$2bo2bo$bob2obo$obo2bobo$obo2bobo$bob2obo$2bo2bo$3b2o!"
,
"b3s23"
);
pattern
replaceme2
(
lab
,
"3$3b2o$3b2o!"
,
"b3s23"
);
pattern
findme3
(
lab
,
"3$3b2H$3b2H!"
,
"b3s23"
);
for
(
int
orient
=
0
;
orient
<
8
;
orient
++
)
{
...
...
@@ -375,7 +394,9 @@ namespace apg {
pattern
m
=
inft
.
match
(
findme
);
if
(
m
.
empty
())
{
continue
;
}
pattern
infx
=
m
.
convolve
(
replaceme
)
+
inft
.
match
(
findme2
).
convolve
(
replaceme2
);
pattern
infx
=
m
.
convolve
(
replaceme
);
infx
+=
inft
.
match
(
findme2
).
convolve
(
replaceme2
);
infx
+=
inft
.
match
(
findme3
).
convolve
(
replaceme2
);
resultant
=
infx
(
reverse
,
0
,
0
);
...
...
@@ -387,6 +408,7 @@ namespace apg {
void
resolve_metacluster
(
pattern
infx
,
pattern
m
,
scstream
&
scs
,
bool
new_elbow
)
{
auto
lab
=
infx
.
getlab
();
pattern
findme
(
lab
,
"4$2bo$bobob2o$o2bob2o$obo$bo!"
,
"b3s23"
);
pattern
findme2
(
lab
,
"$2b2o$2b2o2$2b2o$bo2bo$o2bo$b2o!"
,
"b3s23"
);
...
...
@@ -459,7 +481,7 @@ namespace apg {
while
(
infx
.
nonempty
())
{
pattern
metacluster
=
cell_lowerright
(
infx
);
pattern
mc_old
(
lab
,
""
,
"b3s23"
);
pattern
mc_old
(
infx
.
get
lab
()
,
""
,
"b3s23"
);
int64_t
bbox
[
4
]
=
{
0
};
while
(
metacluster
!=
mc_old
)
{
...
...
@@ -480,7 +502,7 @@ namespace apg {
bool
try_orientation
(
pattern
inf
,
scstream
&
scs
)
{
pattern
findme
(
lab
,
"4$2bo$bobob2o$o2bob2o$obo$bo!"
,
"b3s23"
);
pattern
findme
(
inf
.
get
lab
()
,
"4$2bo$bobob2o$o2bob2o$obo$bo!"
,
"b3s23"
);
pattern
m
=
inf
.
match
(
findme
);
if
(
m
.
empty
())
{
return
false
;
}
...
...
infile.mc
View file @
f5a1288a
x = 47, y = 75, rule = B3/S23
44bo$42b3o$41bo$41b2o5$20b2o$19bobo$19bo$18b2o3$23b2o$22bobo$22bo$21b
2o6$32b2o$32b2o$40b2o$40bo$41b3o$43bo2$42bo$41bobo$41bobo$40b2ob3o$46b
o$40b2ob3o$40b2obo2$32b2o$23b2o7b2o$24bo$24bobo$25b2o4$45b2o$45b2o5$
30bo$29bobo$29bobo$30bo$27b3o$27bo11$2b2o$2b2o2$2b2o$bo2bo$o2bo$b2o!
x = 114, y = 122, rule = LifeHistory
26.4B$25.4B$24.4B$23.4B$22.4B$21.4B$20.4B$19.4B$18.4B$17.4B$16.4B$15.
4B$14.4B$9.3B.4B$8.8B10.A$8.7B.B7.3A$8.10B5.A$6.12B5.2A$5.14B.5B$5.
18B$4.22B$4.23B$2.2AB.22B$.A.AB.23B$.A4.22B$2A5.20B$8.19B$7.21B$5.2AB
.15B.4B$4.A.AB3.10B5.4B$4.A6.10B6.4B$3.2A5.13B5.4B$9.15B5.4B$8.16B6.
4B$7.17B7.4B$8.16B8.4B$9.13B11.4B$9.5B2A2B.3B12.4B$11.3B2A2B2.4B11.4B
$11.8B3.2A12.4B$10.8B4.A14.4B$10.8B5.3A12.4B$10.7B8.A13.4B$10.7B23.3B
$11.6B7.A16.2B$11.6B6.A.A16.B$12.5B6.A.A$12.6B4.2A.3A$11.6B6.B4.A$11.
7B3.B2AB3A$12.8B.B2A.A$12.10B$11.3B2C6B$5.2A5.2B2C6B$6.A5.10B$6.A.AB
2.11B$7.2AB.12B$9.15B$9.16B$9.16B.2B$10.17B2A$12.13B.B2A$13.8B.4B.B$
14.7B$14.6B$14.4B$12.A3B$11.A.AB$11.A.A$12.A$9.3A$9.A44$111.2A$111.2A
2$111.2A$110.A2.A$109.A2.A$110.2A!
lifelib
@
896bf39b
Compare
86bdc7e5
...
896bf39b
Subproject commit 86b
dc7e5b5d7bf3a5b0d51
210c
88e48016024cb7
Subproject commit 8
9
6b
f39b90891e3a595a768325a
210
0
c
51ca2a80
slsparse.cpp
View file @
f5a1288a
...
...
@@ -4,7 +4,7 @@
///bin/cat /dev/null; echo 'Compiling...'
///bin/cat /dev/null; sourcename="$0"
///bin/cat /dev/null; exename="$( readlink -f "${sourcename%.*}" )"
///bin/cat /dev/null; g++ -std=c++11 -O3 -march=native -Wall -Wextra "$sourcename" -o "$exename"
///bin/cat /dev/null; g++ -std=c++11 -O3 -march=native
-pedantic
-Wall -Wextra "$sourcename" -o "$exename"
///bin/cat /dev/null; echo '...compiled.'
///bin/cat /dev/null; date
///bin/cat /dev/null; "$exename" "$@"; status=$?
...
...
@@ -14,11 +14,11 @@
int
main
()
{
apg
::
lifetree
<
uint32_t
,
1
>
lt
(
1000
);
apg
::
pattern
inf
(
&
lt
,
"infile.mc"
);
apg
::
lifetree
<
uint32_t
,
4
>
lt4
(
100
);
apg
::
pattern
inf
(
&
lt4
,
"infile.mc"
);
apg
::
sparselab
spl
(
&
lt
);
apg
::
scstream
scs
;
// spl.el.desirate(scs, 357);
bool
success
=
spl
.
arbitrary_build
(
inf
,
scs
);
...
...
@@ -30,7 +30,8 @@ int main() {
std
::
ofstream
f
(
"outfile.txt"
);
scs
.
exportgliders
(
f
);
apg
::
pattern
x
=
spl
.
target_to_glider
(
inf
);
apg
::
pattern
x
(
&
lt
,
""
,
"b3s23"
);
x
+=
spl
.
target_to_glider
(
inf
);
apg
::
pattern
y
=
x
&
x
[
2
]
&
x
[
4
]
&
x
[
6
]
&
x
[
8
];
apg
::
pattern
g
=
x
-
y
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment