extern char * OutputEquityScale(const float r, const cubeinfo * pci, const cubeinfo * pciBase, const int f) { static char sz[9]; if (!pci->nMatchTo) { if (f) sprintf(sz, "%+*.*f", fOutputDigits + 4, fOutputDigits, pci->nCube / pciBase->nCube * r); else sprintf(sz, "%*.*f", fOutputDigits + 4, fOutputDigits, pci->nCube / pciBase->nCube * r); } else { if (fOutputMWC) { if (fOutputMatchPC) { sprintf(sz, "%*.*f%%", fOutputDigits + 3, fOutputDigits > 1 ? fOutputDigits - 1 : 0, 100.0f * (f ? eq2mwc(r, pci) : se_eq2mwc(r, pci))); } else { sprintf(sz, "%*.*f", fOutputDigits + 3, fOutputDigits + 1, f ? eq2mwc(r, pci) : se_eq2mwc(r, pci)); } } else { if (f) sprintf(sz, "%+*.*f", fOutputDigits + 4, fOutputDigits, mwc2eq(eq2mwc(r, pci), pciBase)); else sprintf(sz, "%*.*f", fOutputDigits + 4, fOutputDigits, se_mwc2eq(se_eq2mwc(r, pci), pciBase)); } } return sz; }
extern char * OutputEquityDiff(const float r1, const float r2, const cubeinfo * pci) { static char sz[9]; if (!pci->nMatchTo || (pci->nMatchTo && !fOutputMWC)) { sprintf(sz, "%+*.*f", fOutputDigits + 4, fOutputDigits, r1 - r2); } else { if (fOutputMatchPC) { sprintf(sz, "%*.*f%%", fOutputDigits + 3, fOutputDigits > 1 ? fOutputDigits - 1 : 0, 100.0f * eq2mwc(r1, pci) - 100.0f * eq2mwc(r2, pci)); } else { sprintf(sz, "%*.*f", fOutputDigits + 3, fOutputDigits + 1, eq2mwc(r1, pci) - eq2mwc(r2, pci)); } } return sz; }
static char * ExtEvaluation(scancontext * pec) { ProcessedFIBSBoard processedBoard; float arOutput[NUM_ROLLOUT_OUTPUTS]; cubeinfo ci; int anScore[2]; char *szResponse; float r; evalcontext ec; if (ProcessFIBSBoardInfo(&pec->bi, &processedBoard)) { szResponse = g_strdup_printf("Error: badly formed board\n"); } else { anScore[0] = processedBoard.nScoreOpp; anScore[1] = processedBoard.nScore; /* If the session isn't using Crawford rule, set crawford flag to false */ processedBoard.fCrawford = pec->fCrawfordRule ? processedBoard.fCrawford : FALSE; /* Set the Jacoby flag appropriately from the external interface settings */ processedBoard.fJacoby = pec->fJacobyRule; /* printf ("Jacoby Setting: %d\n", fJacoby); */ /* printf ("Crawford Setting: %d\n", fCrawford); */ SetCubeInfo(&ci, processedBoard.nCube, processedBoard.fCubeOwner, 1, processedBoard.nMatchTo, anScore, processedBoard.fCrawford, processedBoard.fJacoby, nBeavers, bgvDefault); ec.fCubeful = pec->fCubeful; ec.nPlies = pec->nPlies; ec.fUsePrune = pec->fUsePrune; ec.fDeterministic = pec->fDeterministic; ec.rNoise = pec->rNoise; if (GeneralEvaluationE(arOutput, (ConstTanBoard) processedBoard.anBoard, &ci, &ec)) return NULL; if (processedBoard.nMatchTo) { if (ec.fCubeful) r = arOutput[OUTPUT_CUBEFUL_EQUITY]; else r = eq2mwc(arOutput[OUTPUT_EQUITY], &ci); } else r = ec.fCubeful ? arOutput[6] : arOutput[5]; szResponse = g_strdup_printf("%f %f %f %f %f %f\n", arOutput[0], arOutput[1], arOutput[2], arOutput[3], arOutput[4], r); } return szResponse; }
extern char * OutputEquity(const float r, const cubeinfo * pci, const int f) { static char sz[9]; if (!pci->nMatchTo || (pci->nMatchTo && !fOutputMWC)) { if (f) sprintf(sz, "%+*.*f", fOutputDigits + 4, fOutputDigits, r); else sprintf(sz, "%*.*f", fOutputDigits + 4, fOutputDigits, r); } else { if (fOutputMatchPC) { sprintf(sz, "%*.*f%%", fOutputDigits + 3, fOutputDigits > 1 ? fOutputDigits - 1 : 0, 100.0f * (f ? eq2mwc(r, pci) : se_eq2mwc(r, pci))); } else { sprintf(sz, "%*.*f", fOutputDigits + 3, fOutputDigits + 1, f ? eq2mwc(r, pci) : se_eq2mwc(r, pci)); } } return sz; }
static void TextPrintMoveAnalysis(GString * gsz, const matchstate * pms, moverecord * pmr) { char szBuf[1024]; char sz[64]; unsigned int i; cubeinfo ci; GetMatchStateCubeInfo(&ci, pms); /* check if move should be printed */ if (!exsExport.afMovesDisplay[pmr->n.stMove]) return; /* print alerts */ if (badSkill(pmr->n.stMove)) { /* blunder or error */ g_string_append_printf(gsz, _("Alert: %s move"), gettext(aszSkillType[pmr->n.stMove])); if (!pms->nMatchTo || (pms->nMatchTo && !fOutputMWC)) g_string_append_printf(gsz, " (%+7.3f)\n", pmr->ml.amMoves[pmr->n.iMove].rScore - pmr->ml.amMoves[0].rScore); else g_string_append_printf(gsz, " (%+6.3f%%)\n", 100.0f * eq2mwc(pmr->ml.amMoves[pmr->n.iMove].rScore, &ci) - 100.0f * eq2mwc(pmr->ml.amMoves[0].rScore, &ci)); } if (pmr->lt != LUCK_NONE) { /* joker */ g_string_append_printf(gsz, _("Alert: %s roll!"), gettext(aszLuckType[pmr->lt])); if (!pms->nMatchTo || (pms->nMatchTo && !fOutputMWC)) g_string_append_printf(gsz, " (%+7.3f)\n", pmr->rLuck); else g_string_append_printf(gsz, " (%+6.3f%%)\n", 100.0f * eq2mwc(pmr->rLuck, &ci) - 100.0f * eq2mwc(0.0f, &ci)); } g_string_append(gsz, "\n"); g_string_append_printf(gsz, _("Rolled %d%d"), pmr->anDice[0], pmr->anDice[1]); if (pmr->rLuck != ERR_VAL) g_string_append_printf(gsz, " (%s):\n", GetLuckAnalysis(pms, pmr->rLuck)); else g_string_append_printf(gsz, ":\n"); if (pmr->ml.cMoves) { for (i = 0; i < pmr->ml.cMoves; i++) { if (i >= exsExport.nMoves && i != pmr->n.iMove) continue; g_string_append(gsz, i == pmr->n.iMove ? "*" : " "); g_string_append(gsz, FormatMoveHint(szBuf, pms, &pmr->ml, i, i != pmr->n.iMove || i != pmr->ml.cMoves - 1 || pmr->ml.cMoves == 1 || i < exsExport.nMoves, exsExport.fMovesDetailProb, exsExport.afMovesParameters[pmr->ml.amMoves[i].esMove.et - 1])); } } else { if (pmr->n.anMove[0] >= 0) /* no movelist saved */ g_string_append_printf(gsz, "* %s\n", FormatMove(sz, pms->anBoard, pmr->n.anMove)); else /* no legal moves */ /* FIXME: output equity?? */ g_string_append_printf(gsz, "* %s\n", _("Cannot move")); } g_string_append(gsz, "\n\n"); return; }
static char * ExtEvaluation( extcmd *pec ) { char szName[ MAX_NAME_LEN ], szOpp[ MAX_NAME_LEN ]; int nMatchTo, anScore[ 2 ], anDice[ 2 ], nCube, fCubeOwner, fDoubled, fCrawford, fJacoby; TanBoard anBoard; float arOutput[ NUM_ROLLOUT_OUTPUTS ]; cubeinfo ci; int nScore, nScoreOpponent; char *szResponse; float r; evalcontext ec; if( ParseFIBSBoard( pec->szFIBSBoard, anBoard, szName, szOpp, &nMatchTo, &nScore, &nScoreOpponent, anDice, &nCube, &fCubeOwner, &fDoubled, &fCrawford ) ) { outputl( _("Warning: badly formed board from external controller.") ); szResponse = g_strdup_printf( "Error: badly formed board ('%s')\n", pec->szFIBSBoard ); } else { anScore[ 0 ] = nScoreOpponent; anScore[ 1 ] = nScore; /* If the session isn't using Crawford rule, set crawford flag to false */ fCrawford = pec->fCrawfordRule ? fCrawford : FALSE; /* Set the Jacoby flag appropriately from the external interface settings */ fJacoby = pec->fJacobyRule; /* printf ("Jacoby Setting: %d\n", fJacoby);*/ /* printf ("Crawford Setting: %d\n", fCrawford); */ SetCubeInfo ( &ci, nCube, fCubeOwner, 1, nMatchTo, anScore, fCrawford, fJacoby, nBeavers, bgvDefault ); ec.fCubeful = pec->fCubeful; ec.nPlies = pec->nPlies; ec.fUsePrune = pec->fUsePrune; ec.fDeterministic = pec->fDeterministic; ec.rNoise = pec->rNoise; if ( GeneralEvaluationE( arOutput, (ConstTanBoard)anBoard, &ci, &ec ) ) return NULL; if ( nMatchTo ) { if ( ec.fCubeful ) r = arOutput[ OUTPUT_CUBEFUL_EQUITY ]; else r = eq2mwc( arOutput[ OUTPUT_EQUITY ], &ci ); } else r = ec.fCubeful ? arOutput[ 6 ] : arOutput[ 5 ]; szResponse = g_strdup_printf( "%f %f %f %f %f %f\n", arOutput[ 0 ], arOutput[ 1 ], arOutput[ 2 ], arOutput[ 3 ], arOutput[ 4 ], r ); } return szResponse; }