Commit 14d1431b authored by Adam P. Goucher's avatar Adam P. Goucher

Python bindings for hashsoup()

parent d3124a2c
Pipeline #40541708 passed with stage
in 3 minutes and 34 seconds
#ifndef LIFELIB_VERSION /*
__version__=[x.replace('"', '') for x in '''
*/
#define LIFELIB_VERSION "ll2.0.24"
#define LIFELIB_VERSION "ll2.0.25"
// '''.split() if ('ll' in x)][0][2:]
#endif
#include "pattern2.h"
#include "streamlife.h"
#include "soup/hashsoup.h"
#include "ssplit.h"
#include <new>
......@@ -124,6 +125,13 @@ extern "C"
return new(std::nothrow) apg::pattern(lab, std::string(rle), std::string(rule));
}
void* Hashsoup(void* lt, const char *rule, const char *symmetry, const char *seed) {
auto lab = reinterpret_cast<apg::lifetree_abstract<uint32_t>*>(lt);
std::vector<apg::bitworld> vbw;
vbw.push_back(apg::hashsoup(std::string(seed), std::string(symmetry)));
return new(std::nothrow) apg::pattern(lab, vbw, std::string(rule));
}
void* AdvancePattern(void* pat, int numgens, uint64_t exponent) {
auto ppat = reinterpret_cast<apg::pattern*>(pat);
return new(std::nothrow) apg::pattern(ppat->advance2(numgens, exponent));
......
......@@ -75,7 +75,7 @@ restypes = {'DeletePattern': None, 'GetBeszelIndex': c_uint64, 'GetUlqomaIndex':
'PatternNonempty': c_bool, 'MatchLive': c_void_p, 'MatchLiveAndDead': c_void_p, 'GetRuleOfPattern': None,
'GetSolidForPattern': c_void_p, 'GetOriginState': c_uint64, 'GetCells': None, 'SetCells': None,
'CreatePatternFromFile': c_void_p, 'MakeSpaceshipStream': c_void_p, 'GetCompiledVersion': None,
'GetCoords': None, 'GetPatternBound': c_uint64, 'GetSubpops': None}
'GetCoords': None, 'GetPatternBound': c_uint64, 'GetSubpops': None, 'Hashsoup': c_void_p}
def call_underlying(lifelib, fname_and_args):
......
......@@ -44,12 +44,10 @@ class Lifetree(object):
return Pattern(self.session, pptr, self)
def viewer(self, filename=None, width=480, height=480,
lv_config='#C [[ THEME 6 GRID GRIDMAJOR 0 ]]'):
if filename is None:
filename = self.session.newfloat('viewer') + '.html'
def hashsoup(self, rule, symmetry, seed):
pptr = self.lifelib('Hashsoup', self.ptr, rule, symmetry, seed)
return Pattern(self.session, pptr, self)
def pattern(self, rle="", rule=None, tempfile='tempfile', verify_apgcode=True):
......
This diff is collapsed.
......@@ -14,6 +14,12 @@ class TestGoL(unittest.TestCase):
self.sess = lifelib.load_rules('b3s23')
self.lt = self.sess.lifetree(memory=1000, n_layers=4)
def test_hashsoup(self):
x = self.lt.hashsoup("b3s23", "C1", "n_GcpqZ62YqD3310086454")
ac = x[1000].apgcode
self.assertEqual(ac, 'xp46_033y133zzzckgsxsgkczydciczy4ccy0222')
def test_lhistory(self):
scorbie = self.lt.pattern('''x = 50, y = 72, rule = LifeHistory
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment