anntzer / redeal

A reimplementation of Thomas Andrews' Deal in Python.
Other
63 stars 41 forks source link

Shape definition not working #12

Closed chebfarid closed 6 years ago

chebfarid commented 6 years ago

First of all, big kodos for a great job! I found your Python version of Deal by chance and implemented it into small didactic project to train on various bidding problems. In order to do so I added some SHAPE definitions to the ones already present in redeal.py and all of them are working perfectly fine except this one: twominors = Shape("xx(55)") + Shape("xx(65)") Using it from my python script I receive the following error message:

>>> 
 RESTART: C:\Users\MezaberF.PICCOLOTEATRO\Dropbox\Programmazione\Python\Python Bridge\Redeal\RD_multipleDeals.py 
Traceback (most recent call last):
  File "C:\Users\MezaberF.PICCOLOTEATRO\Dropbox\Programmazione\Python\Python Bridge\Redeal\RD_multipleDeals.py", line 118, in <module>
    d = newDeal(twominors)
  File "C:\Users\MezaberF.PICCOLOTEATRO\AppData\Local\Programs\Python\Python36\lib\site-packages\redeal\redeal.py", line 307, in __new__
    if accept_func is None or accept_func(self):
  File "C:\Users\MezaberF.PICCOLOTEATRO\AppData\Local\Programs\Python\Python36\lib\site-packages\redeal\redeal.py", line 160, in __call__
    return hand.shape in self
AttributeError: 'Deal' object has no attribute 'shape'
>>> 

Which seems kind of absurd to me as I use other customized SHAPE definitions which work all perfectly fine, for example:

landy = Shape("(54)xx") + Shape("(55)xx")
muider = Shape("(5)x(4)x") + Shape("(5)xx(4)") + Shape("x(5)(4)x") + Shape("x(5)x(4)")
...

What could I be missing?

I'm not sure if you are still following the redeal project, in case you do thank you for your attention and regards from Milan/Italy

anntzer commented 6 years ago

Please provide the entire script that fails, thanks.

chebfarid commented 6 years ago

Please find attached

  1. the customized redeal.py - I added code on lines 28 and 195-205
  2. my project file: on line 118 you choose one of the functions to create special deals/problems (result is an output file in html format). All SHAPE definitions and linked functions in the project file work except: d = newDeal(twoMinOver1NT) which is based on the shape "twominors".

Thanks a lot Farid

RD_files.zip

chebfarid commented 6 years ago

Sorry I forgot to include the HTML-template file which is used for the html output of my script.

RD_template.zip

anntzer commented 6 years ago

I cannot reproduce the bug you are observing. You may need to use a bigger number of tries because the hand type you're looking for is quite rare, e.g., new_deal = d(twoMinOver1NT, 100000) but other than that I get the hands being generated.

chebfarid commented 6 years ago

Great, I hadn't thought about that! Thanks again & ciao