zekyll / OMPEval

Fast C++ poker hand evaluator and equity calculator
ISC License
173 stars 69 forks source link

Wrong eval result in specific order of evaluations(?) #10

Open MetalToPedal opened 6 years ago

MetalToPedal commented 6 years ago

I get a wrong result returned in the following sequence of evaluations.

(i) Start up a fresh instance of EquityCalculator. (ii) Calc a 3-handed game, ranges { "AA", "QQ", "AKo" } empty board and no dead cards. Correct results are returned: Eq win ties 0.761347, 0.756022, 0.005324 0.187420, 0.186052, 0.001367 0.051233, 0.045909, 0.005324

(iii) now still with the same EquityCalculator instance Calc a 3-handed game, ranges { "AA", "QQ", "AKo" } empty board but now with dead cards (AsTs). Incorrect results are returned: 0.748711, 0.743139, 0.005572 0.198669, 0.197299, 0.001370 0.052620, 0.047048, 0.005572

I expected this result (verified using Pokerstove): Eq win ties 0.734955, 0.728980, 0.005975 0.210303, 0.208843, 0.001460 0.054743, 0.048768, 0.005975

===========================

Oddly if I perform some calculations in a different order it always seems to works eg,. range { "AA", "QQ", "AKo" } dead (AsTs) then range { "AA", "QQ", "AKo" } dead () then range { "AA", "QQ", "AKo" } dead (AsTs) All 3 calculations return the expected results.

I haven't previously ever noticed an incorrect result from this and it seems to happen only with this sequence of evaluations, weird. Perhaps it is just my set up or some slip by me. I have tried using both a 32 bit and 64 bit version.

MetalToPedal commented 6 years ago

I think the problem is happening due some optimizing code being triggered/executed incorrectly. Stopping some trips into cache results stops the problem although I don't fully understand the code in question. Changing the first two lines of the function in EquityCalculator.cpp: bool EquityCalculator::lookupResults(uint64_t preflopId, BatchResults& results)

From: if (!mDeadCards && !mBoardCards && lookupPrecalculatedResults(preflopId, results)) return true;

To:

if (mBoardCards || mDeadCards) return false; if (lookupPrecalculatedResults(preflopId, results)) return true;

This will 'fix' the problem for me but may possibly impact speed unnecessarily.

Overall, I think this project has excellent code and the author gets a 10 out of 10 from me for this work.