mirror of
https://github.com/Cubitect/cubiomes.git
synced 2025-09-09 04:05:08 -04:00
Made constellation lists zero terminated
This commit is contained in:
parent
1afa0325b6
commit
ae58fc4983
@ -217,11 +217,8 @@ int main()
|
|||||||
printf("Preparing seed bases...\n");
|
printf("Preparing seed bases...\n");
|
||||||
// Get all 48-bit quad-witch-hut bases, but consider only the best 20-bit
|
// Get all 48-bit quad-witch-hut bases, but consider only the best 20-bit
|
||||||
// constellations where the structures are the closest together.
|
// constellations where the structures are the closest together.
|
||||||
int err = searchAll48(
|
int err = searchAll48(&bases, &basecnt, NULL, threads,
|
||||||
&bases, &basecnt, NULL, threads,
|
low20QuadIdeal, 20, check, &sconf);
|
||||||
low20QuadIdeal, sizeof(low20QuadIdeal) / sizeof(uint64_t), 20,
|
|
||||||
check, &sconf
|
|
||||||
);
|
|
||||||
|
|
||||||
if (err || !bases)
|
if (err || !bases)
|
||||||
{
|
{
|
||||||
|
33
quadbase.c
33
quadbase.c
@ -41,6 +41,24 @@ typedef pthread_t thread_id_t;
|
|||||||
// Multi-Structure Checks
|
// Multi-Structure Checks
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
|
int getQuadHutCst(uint64_t low20)
|
||||||
|
{
|
||||||
|
const uint64_t *cst;
|
||||||
|
for (cst = low20QuadIdeal; *cst; cst++)
|
||||||
|
if (*cst == low20)
|
||||||
|
return CST_IDEAL;
|
||||||
|
for (cst = low20QuadClassic; *cst; cst++)
|
||||||
|
if (*cst == low20)
|
||||||
|
return CST_CLASSIC;
|
||||||
|
for (cst = low20QuadHutNormal; *cst; cst++)
|
||||||
|
if (*cst == low20)
|
||||||
|
return CST_NORMAL;
|
||||||
|
for (cst = low20QuadHutBarely; *cst; cst++)
|
||||||
|
if (*cst == low20)
|
||||||
|
return CST_BARELY;
|
||||||
|
return CST_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: accurate seed testers for two or three structures in range
|
// TODO: accurate seed testers for two or three structures in range
|
||||||
|
|
||||||
|
|
||||||
@ -219,7 +237,6 @@ STRUCT(threadinfo_t)
|
|||||||
// seed range
|
// seed range
|
||||||
uint64_t start, end;
|
uint64_t start, end;
|
||||||
const uint64_t *lowBits;
|
const uint64_t *lowBits;
|
||||||
int lowBitCnt;
|
|
||||||
int lowBitN;
|
int lowBitN;
|
||||||
char skipStart;
|
char skipStart;
|
||||||
|
|
||||||
@ -258,7 +275,7 @@ static int mkdirp(char *path)
|
|||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(path, &st) == -1)
|
if (stat(path, &st) == -1)
|
||||||
err = mkdir(path, 0773);
|
err = mkdir(path, 0755);
|
||||||
else if (!S_ISDIR(st.st_mode))
|
else if (!S_ISDIR(st.st_mode))
|
||||||
err = 1;
|
err = 1;
|
||||||
|
|
||||||
@ -291,7 +308,9 @@ static DWORD WINAPI searchAll48Thread(LPVOID data)
|
|||||||
uint64_t hstep = 1ULL << info->lowBitN;
|
uint64_t hstep = 1ULL << info->lowBitN;
|
||||||
uint64_t hmask = ~(hstep - 1);
|
uint64_t hmask = ~(hstep - 1);
|
||||||
uint64_t mid;
|
uint64_t mid;
|
||||||
int idx;
|
int idx, cnt;
|
||||||
|
|
||||||
|
for (cnt = 0; info->lowBits[cnt]; cnt++);
|
||||||
|
|
||||||
mid = info->start & hmask;
|
mid = info->start & hmask;
|
||||||
for (idx = 0; (seed = mid | info->lowBits[idx]) < info->start; idx++);
|
for (idx = 0; (seed = mid | info->lowBits[idx]) < info->start; idx++);
|
||||||
@ -325,7 +344,7 @@ static DWORD WINAPI searchAll48Thread(LPVOID data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
idx++;
|
idx++;
|
||||||
if (idx >= info->lowBitCnt)
|
if (idx >= cnt)
|
||||||
{
|
{
|
||||||
idx = 0;
|
idx = 0;
|
||||||
mid += hstep;
|
mid += hstep;
|
||||||
@ -384,7 +403,6 @@ int searchAll48(
|
|||||||
const char * path,
|
const char * path,
|
||||||
int threads,
|
int threads,
|
||||||
const uint64_t * lowBits,
|
const uint64_t * lowBits,
|
||||||
int lowBitCnt,
|
|
||||||
int lowBitN,
|
int lowBitN,
|
||||||
int (*check)(uint64_t s48, void *data),
|
int (*check)(uint64_t s48, void *data),
|
||||||
void * data,
|
void * data,
|
||||||
@ -429,7 +447,6 @@ int searchAll48(
|
|||||||
info[t].start = (t * (MASK48+1) / threads);
|
info[t].start = (t * (MASK48+1) / threads);
|
||||||
info[t].end = ((t+1) * (MASK48+1) / threads - 1);
|
info[t].end = ((t+1) * (MASK48+1) / threads - 1);
|
||||||
info[t].lowBits = lowBits;
|
info[t].lowBits = lowBits;
|
||||||
info[t].lowBitCnt = lowBitCnt;
|
|
||||||
info[t].lowBitN = lowBitN;
|
info[t].lowBitN = lowBitN;
|
||||||
info[t].skipStart = 0;
|
info[t].skipStart = 0;
|
||||||
info[t].check = check;
|
info[t].check = check;
|
||||||
@ -631,7 +648,7 @@ int scanForQuadBits(const StructureConfig sconf, int radius, uint64_t s48,
|
|||||||
|
|
||||||
int scanForQuads(
|
int scanForQuads(
|
||||||
const StructureConfig sconf, int radius, uint64_t s48,
|
const StructureConfig sconf, int radius, uint64_t s48,
|
||||||
const uint64_t *lowBits, int lowBitCnt, int lowBitN, uint64_t salt,
|
const uint64_t *lowBits, int lowBitN, uint64_t salt,
|
||||||
int x, int z, int w, int h, Pos *qplist, int n)
|
int x, int z, int w, int h, Pos *qplist, int n)
|
||||||
{
|
{
|
||||||
int i, cnt = 0;
|
int i, cnt = 0;
|
||||||
@ -643,7 +660,7 @@ int scanForQuads(
|
|||||||
else
|
else
|
||||||
invB = mulInv(132897987541ULL, (1ULL << lowBitN));
|
invB = mulInv(132897987541ULL, (1ULL << lowBitN));
|
||||||
|
|
||||||
for (i = 0; i < lowBitCnt; i++)
|
for (i = 0; lowBits[i]; i++)
|
||||||
{
|
{
|
||||||
cnt += scanForQuadBits(sconf, radius, s48, lowBits[i]-salt, lowBitN, invB,
|
cnt += scanForQuadBits(sconf, radius, s48, lowBits[i]-salt, lowBitN, invB,
|
||||||
x, z, w, h, qplist+cnt, n-cnt);
|
x, z, w, h, qplist+cnt, n-cnt);
|
||||||
|
17
quadbase.h
17
quadbase.h
@ -34,13 +34,13 @@ extern "C"
|
|||||||
// (the structure salt has to be subtracted before use)
|
// (the structure salt has to be subtracted before use)
|
||||||
static const uint64_t low20QuadIdeal[] =
|
static const uint64_t low20QuadIdeal[] =
|
||||||
{
|
{
|
||||||
0x43f18,0xc751a,0xf520a,
|
0x43f18,0xc751a,0xf520a, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
// lower 20 bits, the classic quad-structure constellations
|
// lower 20 bits, the classic quad-structure constellations
|
||||||
static const uint64_t low20QuadClassic[] =
|
static const uint64_t low20QuadClassic[] =
|
||||||
{
|
{
|
||||||
0x43f18,0x79a0a,0xc751a,0xf520a,
|
0x43f18,0x79a0a,0xc751a,0xf520a, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
// for any valid quad-structure constellation with a structure size:
|
// for any valid quad-structure constellation with a structure size:
|
||||||
@ -49,7 +49,7 @@ static const uint64_t low20QuadClassic[] =
|
|||||||
static const uint64_t low20QuadHutNormal[] =
|
static const uint64_t low20QuadHutNormal[] =
|
||||||
{
|
{
|
||||||
0x43f18,0x65118,0x75618,0x79a0a, 0x89718,0x9371a,0xa5a08,0xb5e18,
|
0x43f18,0x65118,0x75618,0x79a0a, 0x89718,0x9371a,0xa5a08,0xb5e18,
|
||||||
0xc751a,0xf520a,
|
0xc751a,0xf520a, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
// for any valid quad-structure constellation with a structure size:
|
// for any valid quad-structure constellation with a structure size:
|
||||||
@ -59,10 +59,14 @@ static const uint64_t low20QuadHutBarely[] =
|
|||||||
0x1272d,0x17908,0x367b9,0x43f18, 0x487c9,0x487ce,0x50aa7,0x647b5,
|
0x1272d,0x17908,0x367b9,0x43f18, 0x487c9,0x487ce,0x50aa7,0x647b5,
|
||||||
0x65118,0x75618,0x79a0a,0x89718, 0x9371a,0x967ec,0xa3d0a,0xa5918,
|
0x65118,0x75618,0x79a0a,0x89718, 0x9371a,0x967ec,0xa3d0a,0xa5918,
|
||||||
0xa591d,0xa5a08,0xb5e18,0xc6749, 0xc6d9a,0xc751a,0xd7108,0xd717a,
|
0xa591d,0xa5a08,0xb5e18,0xc6749, 0xc6d9a,0xc751a,0xd7108,0xd717a,
|
||||||
0xe2739,0xe9918,0xee1c4,0xf520a,
|
0xe2739,0xe9918,0xee1c4,0xf520a, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// categorize a constellation
|
||||||
|
enum { CST_NONE, CST_IDEAL, CST_CLASSIC, CST_NORMAL, CST_BARELY };
|
||||||
|
int getQuadHutCst(uint64_t low20);
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// Multi-Structure-Base Checks
|
// Multi-Structure-Base Checks
|
||||||
@ -145,7 +149,6 @@ float isQuadBaseLarge (const StructureConfig sconf, uint64_t seed,
|
|||||||
* @path output file path (nullable, also toggles temporary files)
|
* @path output file path (nullable, also toggles temporary files)
|
||||||
* @threads number of threads to use
|
* @threads number of threads to use
|
||||||
* @lowBits lower bit subset (nullable)
|
* @lowBits lower bit subset (nullable)
|
||||||
* @lowBitCnt length of lower bit subset
|
|
||||||
* @lowBitN number of bits in the subset values
|
* @lowBitN number of bits in the subset values
|
||||||
* @check the testing function, should return non-zero for desired seeds
|
* @check the testing function, should return non-zero for desired seeds
|
||||||
* @data custom data argument passed to 'check'
|
* @data custom data argument passed to 'check'
|
||||||
@ -159,7 +162,6 @@ int searchAll48(
|
|||||||
const char * path,
|
const char * path,
|
||||||
int threads,
|
int threads,
|
||||||
const uint64_t * lowBits,
|
const uint64_t * lowBits,
|
||||||
int lowBitCnt,
|
|
||||||
int lowBitN,
|
int lowBitN,
|
||||||
int (*check)(uint64_t s48, void *data),
|
int (*check)(uint64_t s48, void *data),
|
||||||
void * data,
|
void * data,
|
||||||
@ -192,7 +194,6 @@ Pos getOptimalAfk(Pos p[4], int ax, int ay, int az, int *spcnt);
|
|||||||
* @radius : radius for isQuadBase (use 128 for quad-huts)
|
* @radius : radius for isQuadBase (use 128 for quad-huts)
|
||||||
* @s48 : 48-bit seed to scan
|
* @s48 : 48-bit seed to scan
|
||||||
* @lowBits : consider transformations that yield one of these lower bits
|
* @lowBits : consider transformations that yield one of these lower bits
|
||||||
* @lowBitCnt : length of lower bit subset
|
|
||||||
* @lowBitN : number of bits in the subset values (0 < lowBitN <= 48)
|
* @lowBitN : number of bits in the subset values (0 < lowBitN <= 48)
|
||||||
* @salt : salt subtracted from subset values (useful for protobases)
|
* @salt : salt subtracted from subset values (useful for protobases)
|
||||||
* @x,z,w,h : area to scan in region coordinates (inclusive)
|
* @x,z,w,h : area to scan in region coordinates (inclusive)
|
||||||
@ -203,7 +204,7 @@ Pos getOptimalAfk(Pos p[4], int ax, int ay, int az, int *spcnt);
|
|||||||
*/
|
*/
|
||||||
int scanForQuads(
|
int scanForQuads(
|
||||||
const StructureConfig sconf, int radius, uint64_t s48,
|
const StructureConfig sconf, int radius, uint64_t s48,
|
||||||
const uint64_t *lowBits, int lowBitCnt, int lowBitN, uint64_t salt,
|
const uint64_t *lowBits, int lowBitN, uint64_t salt,
|
||||||
int x, int z, int w, int h, Pos *qplist, int n);
|
int x, int z, int w, int h, Pos *qplist, int n);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user