dominicprice / endplay

A suite of tools for generation and analysis of bridge deals. Read the documentation at https://endplay.readthedocs.io
MIT License
21 stars 5 forks source link

solve_board() returns negative trick values #18

Closed markgonzalez2 closed 1 year ago

markgonzalez2 commented 1 year ago
d = Deal("N:987... K45... AQ2... T63...", first = Player.west, trump = Denom.spades)
d.play("S6")
for card, tricks in solve_board(d):
    print(card, tricks)

This code outputs:

♠7 -2 ♠8 -2 ♠9 -2

Change the 9 to a J and you get the correct output:

♠7 3 ♠8 3 ♠J 2

markgonzalez2 commented 1 year ago

It seems that -2 denotes that all playable cards are equal (e.g., a singleton). Can this behavior be toggled?

dominicprice commented 1 year ago

Ah, I hadn’t noticed that…thanks for letting me know - yes I think you’re right, it’s probably one of the flags passed to the dds library. I’ll have a look this afternoon when i get back from work.

dominicprice commented 1 year ago

Yep was using the wrong mode flag..fix pushed to master branch, CI is running now and assuming it passes I'll tag and push to PyPI in the morning.

dominicprice commented 1 year ago

fixed in 0.4.10, you should be able to update via pypi now :).

markgonzalez2 commented 1 year ago
d = Deal("N:987... K45... AQ2... T63...", first = Player.west, trump = Denom.spades)
d.play("S6")
for solution in solve_all_boards([d]):
    try:
        for card, tricks in solution:
            print(card, tricks)
    except TypeError:
        break

This slightly modified code still outputs the negative values.

dominicprice commented 1 year ago

Mea culpa, I don't get to play around with this as much nowadays so I forget how it works.

CI running now with same fix as before, and also fixed the iteration of SolvedBoardList so you don't have to catch the TypeError (I was returning not raising an IndexError....)

dominicprice commented 1 year ago

ok hopefully the version now on pypi fixes this issue for good now XD