static void TextRolloutProgress(float aarOutput[][NUM_ROLLOUT_OUTPUTS], float aarStdDev[][NUM_ROLLOUT_OUTPUTS], const rolloutcontext * prc, const cubeinfo aci[], unsigned int initial_game_count, const int iGame, const int iAlternative, const int nRank, const float rJsd, const int fStopped, const int fShowRanks, int fCubeRollout, rolloutprogress * prp) { char *pch, *pc; time_t t; static unsigned int n_games_todo = 0; static unsigned int n_games_done = 0; static int min_games_done = 0; /* write progress 1/10th trial or just when called if mt */ if (!iAlternative) outputl(""); pch = OutputRolloutResult(NULL, (char (*)[1024])prp->ppch[iAlternative], (float (*)[NUM_ROLLOUT_OUTPUTS]) aarOutput[iAlternative], (float (*)[NUM_ROLLOUT_OUTPUTS]) aarStdDev[iAlternative], &aci[0], iAlternative, 1, prc->fCubeful); if (fShowRanks && iGame > 1) { pc = strrchr(pch, '\n'); *pc = 0; if (fCubeRollout) sprintf(pc, " %c", fStopped ? 's' : 'r'); else sprintf(pc, " %d%c", nRank, fStopped ? 's' : 'r'); if (nRank != 1 || fCubeRollout) sprintf(strchr(pc, 0), " %5.3f\n", rJsd); else strcat(pc, "\n"); } prp->iNextAlternative++; prp->iNextAlternative = (prp->iNextAlternative) % prp->n; if (iAlternative == (prp->n - 1)) prp->iNextGame += prc->nTrials / 10; output(pch); output(OutputRolloutContext(NULL, prc)); if (iAlternative == 0) { n_games_todo = 0; n_games_done = 0; min_games_done = prc->nTrials; } n_games_done += iGame + 1; if (!fStopped) { n_games_todo += prc->nTrials - (iGame + 1); if (iGame < min_games_done) min_games_done = iGame + 1; } if (iAlternative != (prp->n - 1)) return; /* time elapsed and time left */ t = time_left(n_games_todo, n_games_done, initial_game_count, prp->tStart); outputf(_("Time elapsed %s"), formatDelta(time(NULL) - prp->tStart)); outputf(_(" Estimated time left %s\n"), formatDelta(t)); /* estimated SE */ /* calculate estimated SE */ if (iGame <= 10) return; if (prc->fCubeful) pc = OutputMWC(estimatedSE (aarStdDev[0][OUTPUT_CUBEFUL_EQUITY], iGame, prc->nTrials), &aci[0], FALSE); else pc = OutputEquityScale(estimatedSE (aarStdDev[0][OUTPUT_EQUITY], iGame, prc->nTrials), &aci[0], &aci[0], FALSE); if (prp->ppch && prp->ppch[0] && *prp->ppch[0]) outputf(_("Estimated SE for \"%s\" after %d trials %s\n"), prp->ppch[0], prc->nTrials, pc); else outputf(_("Estimated SE after %d trials %s\n"), prc->nTrials, pc); }
extern char * OutputCubeAnalysis(float aarOutput[2][NUM_ROLLOUT_OUTPUTS], float aarStdDev[2][NUM_ROLLOUT_OUTPUTS], const evalsetup * pes, const cubeinfo * pci) { static char sz[4096]; int i; float arDouble[4]; const char *aszCube[] = { NULL, N_("No double"), N_("Double, take"), N_("Double, pass") }; int ai[3]; cubedecision cd; float r; FindCubeDecision(arDouble, aarOutput, pci); /* header */ sprintf(sz, "\n%s\n", _("Cube analysis")); /* ply & cubeless equity */ switch (pes->et) { case EVAL_NONE: strcat(sz, _("n/a")); break; case EVAL_EVAL: sprintf(strchr(sz, 0), "%u-%s", pes->ec.nPlies, _("ply")); break; case EVAL_ROLLOUT: strcat(sz, _("Rollout")); break; } if (pci->nMatchTo) sprintf(strchr(sz, 0), " %s %s (%s: %s)\n", (!pci->nMatchTo || (pci->nMatchTo && !fOutputMWC)) ? _("cubeless equity") : _("cubeless MWC"), OutputEquity(aarOutput[0][OUTPUT_EQUITY], pci, TRUE), _("Money"), OutputMoneyEquity(aarOutput[0], TRUE)); else sprintf(strchr(sz, 0), " %s %s\n", _("cubeless equity"), OutputMoneyEquity(aarOutput[0], TRUE)); /* Output percentags for evaluations */ if (exsExport.fCubeDetailProb && pes->et == EVAL_EVAL) { strcat(sz, " "); strcat(sz, OutputPercents(aarOutput[0], TRUE)); } strcat(sz, "\n"); /* equities */ strcat(sz, _("Cubeful equities")); strcat(sz, ":\n"); if (pes->et == EVAL_EVAL && exsExport.afCubeParameters[0]) { strcat(sz, " "); strcat(sz, OutputEvalContext(&pes->ec, FALSE)); strcat(sz, "\n"); } getCubeDecisionOrdering(ai, arDouble, aarOutput, pci); for (i = 0; i < 3; i++) { sprintf(strchr(sz, 0), "%d. %-20s", i + 1, gettext(aszCube[ai[i]])); strcat(sz, OutputEquity(arDouble[ai[i]], pci, TRUE)); if (i) sprintf(strchr(sz, 0), " (%s)", OutputEquityDiff(arDouble[ai[i]], arDouble[OUTPUT_OPTIMAL], pci)); strcat(sz, "\n"); } /* cube decision */ cd = FindBestCubeDecision(arDouble, aarOutput, pci); sprintf(strchr(sz, 0), "%s: %s", _("Proper cube action"), GetCubeRecommendation(cd)); if ((r = getPercent(cd, arDouble)) >= 0.0) sprintf(strchr(sz, 0), " (%.1f%%)", 100.0f * r); strcat(sz, "\n"); /* dump rollout */ if (pes->et == EVAL_ROLLOUT && exsExport.fCubeDetailProb) { char asz[2][1024]; cubeinfo aci[2]; for (i = 0; i < 2; i++) { memcpy(&aci[i], pci, sizeof(cubeinfo)); if (i) { aci[i].fCubeOwner = !pci->fMove; aci[i].nCube *= 2; } FormatCubePosition(asz[i], &aci[i]); } sprintf(strchr(sz, 0), "\n%s:\n", _("Rollout details")); strcat(strchr(sz, 0), OutputRolloutResult(NULL, asz, aarOutput, aarStdDev, aci, 0, 2, pes->rc.fCubeful)); } if (pes->et == EVAL_ROLLOUT && exsExport.afCubeParameters[1]) strcat(strchr(sz, 0), OutputRolloutContext(NULL, &pes->rc)); return sz; }