research: preserve solver experiments and reproducible benchmarks
This commit is contained in:
parent
12e4266950
commit
e93bc20b0a
85 changed files with 518443 additions and 0 deletions
51
research/experiments/normal_search/cpu_verify.cpp
Normal file
51
research/experiments/normal_search/cpu_verify.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#include "grouped.hpp"
|
||||
#include <random>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
namespace sr=slime_research;
|
||||
namespace ns=normal_search;
|
||||
int main(){
|
||||
std::mt19937_64 rng(2026101103);
|
||||
uint64_t qchecks=0,groups=0,partialSurvivors=0;
|
||||
for(int test=0;test<200000;++test){
|
||||
sr::CellTerm cells[25];
|
||||
int32_t x=int32_t(rng()%3750000)-1875000,z=int32_t(rng()%3750000)-1875000;
|
||||
const uint64_t anchor=sr::coordinateTerm(x,z);
|
||||
for(int i=0;i<25;++i)cells[i]={(sr::coordinateTerm(x+i%5,z+i/5)-anchor)&sr::kMask48,sr::kSlime};
|
||||
uint32_t root=rng()&((1U<<18)-1);
|
||||
// Full-width random middle values also test carry and modulo behavior.
|
||||
uint32_t m=rng()&((1U<<17)-1);
|
||||
ns::Prepared p;ns::prepare(root,cells,p);
|
||||
for(int i=0;i<25;++i){
|
||||
uint32_t expected=sr::nextStateFromTerm(root+(uint64_t(m)<<18),cells[i].term)>>17;
|
||||
if(ns::preparedQ(p,i,m)!=expected)throw std::runtime_error("q mismatch");
|
||||
++qchecks;
|
||||
}
|
||||
// groupMask matches the difference filter even on odd roots; final
|
||||
// solver parity checks remain responsible for discarding those roots.
|
||||
int count=1+test%25;
|
||||
uint32_t base=m&~240U,expected=0;
|
||||
for(uint32_t j=0;j<16;++j)
|
||||
if(full_search_experiment::differenceFilter(root+(uint64_t(base+16*j)<<18),cells,count))expected|=1U<<j;
|
||||
partialSurvivors+=__builtin_popcount(expected);
|
||||
if(ns::groupMask(p,base,count)!=expected)throw std::runtime_error("group mask mismatch");
|
||||
++groups;
|
||||
}
|
||||
// Positive low18 roots and all middle values: check complete filter masks.
|
||||
sr::CellTerm cells[25];const uint64_t anchor=sr::coordinateTerm(51069,419124);
|
||||
for(int i=0;i<25;++i)cells[i]={(sr::coordinateTerm(51069+i%5,419124+i/5)-anchor)&sr::kMask48,sr::kSlime};
|
||||
uint64_t accepted=0;
|
||||
for(uint32_t root=0;root<(1U<<18);++root){
|
||||
if(!sr::partialPatternPossible(root,18,cells,25))continue;
|
||||
ns::Prepared p;ns::prepare(root,cells,p);
|
||||
for(uint32_t g=0;g<8192;++g){
|
||||
uint32_t base=((g>>4)<<8)+(g&15),expected=0;
|
||||
for(uint32_t j=0;j<16;++j)if(full_search_experiment::differenceFilter(root+(uint64_t(base+16*j)<<18),cells,25))expected|=1U<<j;
|
||||
const uint32_t actual=ns::groupMask(p,base);
|
||||
if(actual!=expected)throw std::runtime_error("positive group mask mismatch");
|
||||
accepted+=__builtin_popcount(actual);++groups;
|
||||
}
|
||||
}
|
||||
if(!accepted)throw std::runtime_error("no positive candidates tested");
|
||||
std::cout<<"{\"q_checks\":"<<qchecks<<",\"group_masks\":"<<groups<<",\"partial_filter_survivors\":"<<partialSurvivors<<",\"known_filter_survivors\":"<<accepted<<",\"passed\":true}\n";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue