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

UnboundLocalError: local variable 'start' referenced before assignment #16

Closed ackhh closed 1 year ago

ackhh commented 1 year ago

.. pip show endplay Name: endplay Version: 0.4.6b0

Code taken from the tutorial:

Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] on win32

... from endplay.types import Deal, Player, Denom ... from endplay.dds import calc_dd_table

... d = Deal("QJ8.AJ965.K82.AQ 43.QT87.QT64.754 AKT9..A97.J98632 7652.K432.J53.KT")

Traceback (most recent call last): File "", line 1, in File "C:\Users\xyzzy\AppData\Local\Programs\Python\Python310\lib\site-packages\endplay\types\deal.py", line 40, in init for player, hand in zip(Player.iter_from(start), hands): UnboundLocalError: local variable 'start' referenced before assignment

Adding "N:" in front of the string helps: ... d = Deal("N:QJ8.AJ965.K82.AQ 43.QT87.QT64.754 AKT9..A97.J98632 7652.K432.J53.KT")

dominicprice commented 1 year ago

Hi, Thanks for raising this; I've been on holiday, but now I will think of the best way to resolve this

Thinking out loud: this used to work and probably broke in a recent update where the Deal constructor was modified to fix some bugs in the lin/pbn parser. 'strict' PBN would require the N: prefix, but as deals are almost always described with north first I often omit this, so I'll add the behaviour back in. Looks like it should be a trivial fix, but needs a test case to make sure it doesn't break again in the future.

dominicprice commented 1 year ago

Closing as this was fixed a while ago but I forgot to follow up here.