diff options
| author | Scott Gasch <[email protected]> | 2026-10-15 13:11:22 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2026-10-15 13:11:22 -0700 |
| commit | 993b6eeb2a9ac7b659c473b6883fa53af1ad3a0b (patch) | |
| tree | c5388824dec15a7691ce9952a6eb4af66e837127 /src/main.c | |
| parent | 53b380c658f828c4c0e096be2763e6b012c23abd (diff) | |
Phase A NNUE: feature-indexing spec, annotation/training pipeline, dump nnuefeatures
Builds out the NNUE Phase A prototype per docs/NNUE.md:
- src/nnuefeatures.c: standalone HalfKAv2_hm feature-index reference
implementation (new `dump nnuefeatures` command), sourced from
Stockfish's half_ka_v2_hm.{h,cpp} (sf_16 tag), including the 0x88->64
square conversion typhoon's own board representation needs.
- annotate_pgns/: sharded TWIC/self-play annotation harness
(annotate.py), position extraction, quiet-position filtering (flat
and game-shaped, plus an upstream --prefilter-quiet option),
train/holdout game-level stratified split, WDL-sigmoid K fitting,
the Python HalfKAv2_hm reference encoder (nnue_feature_spec.py) and
its bit-for-bit cross-checker against the C side
(cross_check_features.py), and a first PyTorch training pipeline
(nnue_model.py, nnue_train.py, build_training_tensors.py) -- a
256x2-32-32-1-ish net trained locally on CPU against ~1.85M quiet
TWIC positions as a pipeline/framework validation pass.
- Finish an in-progress InitMagic/InitLMRTable/InitEval ->
InitializeBitboardMagic/InitializeLMRTable/InitializeEval rename:
chess.h's prototypes hadn't been updated to match the already-renamed
definitions/call sites, leaving 4 implicit-function-declaration
warnings.
- tests/arasan.epd: new curated EPD suite.
- docs/: add the project's design docs (previously untracked).
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 60 |
1 files changed, 28 insertions, 32 deletions
@@ -49,7 +49,7 @@ Return value: char *p; Trace("Typhoon %s (built on %s %s, commit %s):\n", VERSION, __DATE__, __TIME__, GIT_COMMIT); - Trace(" Copyright (C) 2000-2007, Scott Gasch ([email protected])\n"); + Trace(" Copyright (C) 2000-2026, Scott Gasch ([email protected])\n"); Trace(" " REVISION); Trace(" " COMPILER_STRING); Trace(" Make profile used: %s\n", PROFILE); @@ -125,7 +125,7 @@ Return value: FLAG -BeginLogging(void) +InitializeLogging(void) /** Routine description: @@ -150,19 +150,24 @@ Return value: return(FALSE); } - // If the logfile we want to write already exists, back it up. - if (TRUE == SystemDoesFileExist(g_Options.szLogfile)) { - VERIFY(BackupFile(g_Options.szLogfile)); - } - ASSERT(FALSE == SystemDoesFileExist(g_Options.szLogfile)); - - g_pfLogfile = fopen(g_Options.szLogfile, "wb+"); + // If the logfile we want to write already exists, append to it. + FLAG fReusingLogfile = SystemDoesFileExist(g_Options.szLogfile); + g_pfLogfile = fopen(g_Options.szLogfile, "ab+"); if (NULL == g_pfLogfile) { Trace("WARNING: Can't open logfile %s for write (%s); " "continuing without logging.\n", g_Options.szLogfile, strerror(errno)); return(FALSE); } + if (TRUE == fReusingLogfile) { + time_t tNow = time(NULL); + CHAR szTimestamp[64]; + strftime(szTimestamp, sizeof(szTimestamp), "%Y-%m-%d %H:%M:%S", + localtime(&tNow)); + fprintf(g_pfLogfile, + "----- New engine run re-using this logfile (%s) -----\n", + szTimestamp); + } return(TRUE); } @@ -491,21 +496,12 @@ Return value: **/ { - { - // 2026-09-16 diagnostic: allow forcing a fixed srand seed via - // TYPHOON_SEED for reproducing a specific run bit-for-bit - // (there's no --seed command-line flag) -- e.g. re-running the - // same debug_smoke_test.sh repro file to check whether a - // failure is deterministic or a genuine SMP timing race. - // TEMPORARY: revert once the split.c investigation is done, - // this isn't meant to be a permanent CLI feature. - const char *pszForcedSeed = getenv("TYPHOON_SEED"); - unsigned int uSeed = pszForcedSeed ? - (unsigned int)strtoul(pszForcedSeed, NULL, 10) : - (unsigned int)time(0); - Trace("srand seed: %u\n", uSeed); - srand(uSeed); - } + const char *pszForcedSeed = getenv("TYPHOON_SEED"); + unsigned int uSeed = pszForcedSeed ? + (UINT)strtoul(pszForcedSeed, NULL, 10) : + (UINT)time(0); + Trace("srand seed: %u\n", uSeed); + srand(uSeed); InitializeOptions(argc, argv); InitializeTreeDump(); InitializeEGTB(); @@ -520,17 +516,17 @@ Return value: InitializeKnightAttackTables(); InitializeKingAttackTables(); InitializePawnAttackOriginTable(); - InitMagic(); + InitializeBitboardMagic(); InitializeOpeningBook(); InitializeDynamicMoveOrdering(); - InitLMRTable(); + InitializeLMRTable(); InitializeHashSystem(); - InitEval(); + InitializeEval(); #ifdef MP InitializeParallelSearch(); #endif VERIFY(PreGameReset(TRUE)); - (void)BeginLogging(); + InitializeLogging(); return TRUE; } @@ -825,10 +821,10 @@ Return value: { g_uInputThreadHandle = InitInputSystemWithDedicatedThread(); } - + // Enter the main work loop code... - MainProgramLoop(); - + MainProgramLoop(); + // If we get here g_fExitProgram is set -- clean up. Trace("MAIN THREAD: thread terminating.\n"); if (FALSE == MainProgramCleanup()) @@ -836,5 +832,5 @@ Return value: Trace("main: Main program cleanup code failed, aborting.\n"); exit(-1); } - exit(0); + exit(0); } |
