anntzer / redeal

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

Relative imports / DLLs #4

Open LyonsDo opened 8 years ago

LyonsDo commented 8 years ago

Script fails for me due to SystemError: Parent module '' not loaded, cannot perform relative import.

I had probably worked around that, but then started to get "is not a valid Win32 application" due to dll_path issues. Probably some mix of Python55 and a Windows 64-bit machine but too time intensive to try and resolve.

anntzer commented 8 years ago

Can you let me know what you did exactly, so that I can at least try to reproduce this issue? Thanks for the report.

LyonsDo commented 8 years ago

Hi Antony,

Thanks for the reply - I appreciate it!

I used "deal" successfully about a year ago but when I tried to reuse it I had problems with Tcl versions and don't love Tcl in any case so I was very pleased to see your code. I've used Python occasionally but am far from being an expert.

I uninstalled my old Python version and downloaded Python35 for Windows 7 64-bit (python-3.5.0-amd64.exe). Then downloaded your code and ran setup.py install as suggested. That didn't generate an exe as I expected but I do now have a redeal-master\redeal folder containing redeal.py and with redeal-master\dist folder with redeal-0.2.0-py3.5.egg.

Initially I didn't have colorama, but I managed to get that installed OK (I think).

I added the redeal-master\redeal to %PATH% and then tried to run as follows:

C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal>redeal.py Traceback (most recent call last): File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\redeal.py", line 22, in from . import global_defs, dds, util SystemError: Parent module '' not loaded, cannot perform relative import

I read various posts about relative vs absolute imports and it wasn't clear to me how to resolve the issue, so I just pasted defs, dds, util into redeal.py and removed those import statements (I needed to change sys to _sys when doing that - have no idea if that breaks anything).

That got me to the point of generating the DDL errror which typically seems to indicate trying to run a 32-program on a 64-bit machine and probably has nothing to do with your code.

Best,

Donal.

On 21 September 2015 at 17:30, Antony Lee notifications@github.com wrote:

Can you let me know what you did exactly, so that I can at least try to reproduce this issue? Thanks for the report.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-142016035.

LyonsDo commented 8 years ago

P.S. Same issue arose when trying to run from IDLE

Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information.

RESTART: C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\redeal.py Traceback (most recent call last): File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\redeal.py", line 22, in from . import global_defs, dds, util SystemError: Parent module '' not loaded, cannot perform relative import

LyonsDo commented 8 years ago

I'm currently playing in Montpellier and have just joined the FFB

Donal.

anntzer commented 8 years ago

You need to be in the folder that contains the README, not the folder that contains redeal.py. If you downloaded a zip of the sources, this means the (inner) folder named redeal-master. From there, run python -mredeal instead of redeal.py. That will fix your first issue.

For the 32 vs. 64-bit part, indeed DDS only releases a 32-bit build on Windows (and I have no way to build a 64-bit DLL for Windows), so you need a 32-bit Python to use this. Note that you can perfectly install a 32-bit Python on 64-bit Windows, everything will work fine.

I will update the docs accordingly.

LyonsDo commented 8 years ago

Or similarly

C:\Users\DLyons\Downloads\redeal-master\redeal-master>python -m redeal examples/ deal1.py Traceback (most recent call last): File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\runpy.py", line 170, in _run_module_as_main "main", mod_spec) File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 178, in console_entry() File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 167, in console_entry main.run() File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 161, in run self.generate(simulation) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 131, in generate simulation.do(deal) File "", line 2, in do File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\encodings\ cp850.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u2660' in position 0: character maps to

LyonsDo commented 8 years ago

Many thanks Antony,

That fixes the two issues I was having. I do get a new error, but that's another day's work :-)

C:\Users\DLyons\Downloads\redeal-master\redeal-master>python -m redeal Traceback (most recent call last): File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\runpy.py", line 170, in _run_module_as_main "main", mod_spec) File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 178, in console_entry() File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 167, in console_entry main.run() File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 161, in run self.generate(simulation) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 131, in generate simulation.do(deal) File "", line 2, in do File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\encodings\ cp850.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-1: cha racter maps to

Best,

Donal.

On 21 September 2015 at 23:59, Antony Lee notifications@github.com wrote:

You need to be in the folder that contains the README, not the folder that contains redeal.py. If you downloaded a zip of the sources, this means the (inner) folder named redeal-master. From there, run python -mredeal instead of redeal.py. That will fix your first issue.

For the 32 vs. 64-bit part, indeed DDS only releases a 32-bit build on Windows (and I have no way to build a 64-bit DLL for Windows), so you need a 32-bit Python to use this. Note that you can perfectly install a 32-bit Python on 64-bit Windows, everything will work fine.

I will update the docs accordingly.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-142122289.

LyonsDo commented 8 years ago

Just as a quick fix I've changed global_defs to

class Suit(_Enum): S = 0, " S", "S" H = 1, " H", "H" D = 2, " D", "D" C = 3, " C", "C"

and the script is now working.

Many thanks,

Donal.

On 22 September 2015 at 00:37, Donal Lyons donallyons00@gmail.com wrote:

Or similarly

C:\Users\DLyons\Downloads\redeal-master\redeal-master>python -m redeal examples/ deal1.py Traceback (most recent call last): File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\runpy.py", line 170, in _run_module_as_main "main", mod_spec) File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 178, in console_entry() File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 167, in console_entry main.run() File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 161, in run self.generate(simulation) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 131, in generate simulation.do(deal) File "", line 2, in do File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\encodings\ cp850.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u2660' in position 0: character maps to

anntzer commented 8 years ago

Yup, but Linux consoles can display suit symbols properly. I was checking for this capability incorrectly, should be fixed now. Also included a better error message on Windows 64-bit. Please give it a try. Suggestions for the README are also welcome.

LyonsDo commented 8 years ago

Antony,

I think I'm misinterpreting something here, It looks to me like, of the 40 deals, 6 have a 6-card spade suit, 6 have a 5-card spade suit. 5 have a 4-card spade suit, 7 have a 3-card spade suit, 11 have a 2-card spade suit, 3 have a 1-card spade suit and 2 have spade voids.

I was expecting that all 40 would have had a 5-card spade suit out of 120 hands generated i.e. a success rate of 33.3% (which seems high - wouldn't one expect it to be about 11%?

Best,

Donal.

anntzer commented 8 years ago

How did you generate the hands? By default, python -mredeal just generates 10 random deals (N/E/S/W). To generate 10 1S openers (for North), run python -mredeal examples/onespade.py (actually this just checks that North has 12HCP and at least 5S, nothing more). This is the output I get:

♠KQJ64♡AT2♢84♣AK9 ♠85♡763♢A9♣JT8752 ♠T92♡854♢K6532♣Q4 ♠A73♡KQJ9♢QJT7♣63
♠AKQ74♡86♢842♣AJ5 ♠86532♡K543♢K5♣Q9 ♠T♡QJT9♢J9763♣KT3 ♠J9♡A72♢AQT♣87642
♠QT987♡AKT3♢A♣KQ2 ♠J642♡J5♢T962♣JT4 ♠A5♡Q9876♢J87♣A75 ♠K3♡42♢KQ543♣9863
♠Q8752♡AQJT4♢73♣K ♠AKJ3♡6♢AT52♣QT82 ♠96♡98532♢QJ94♣A7 ♠T4♡K7♢K86♣J96543
♠AJ963♡K85♢A4♣KT2 ♠84♡AJ♢KQ652♣9873 ♠T5♡T97642♢T8♣QJ6 ♠KQ72♡Q3♢J973♣A54
♠KQJT7♡K43♢Q6♣JT8 ♠43♡JT9♢AT984♣AK7 ♠A9♡Q85♢KJ73♣9653 ♠8652♡A762♢52♣Q42
♠QJ743♡K5♢AQ96♣86 ♠AK65♡JT632♢52♣J2 ♠T♡A9874♢J8♣AKT43 ♠982♡Q♢KT743♣Q975
♠AKJ86♡AQ82♢85♣J6 ♠T42♡K3♢AT3♣AQT53 ♠973♡T65♢KQJ2♣K72 ♠Q5♡J974♢9764♣984
♠AQ8632♡K32♢K♣K97 ♠J5♡AT♢AJ8♣AJT532 ♠KT♡J6♢T95432♣864 ♠974♡Q98754♢Q76♣Q
♠KT843♡KT♢AK87♣Q5 ♠97♡Q642♢Q943♣A42 ♠AQ62♡J9873♢♣T986 ♠J5♡A5♢JT652♣KJ73

Each of the North hands has 12+HCP and 5S.

Again, if you have any suggestions on how to clarify the README, please let me know.

LyonsDo commented 8 years ago

OK - I see how I was misreading it now. It's 10 sets of 4 deals, not 40 N hands!!!

I'll get back to you re possible clarification.

Donal.

On 23 September 2015 at 01:08, Antony Lee notifications@github.com wrote:

How did you generate the hands? By default, python -mredeal just generates 10 random deals (N/E/S/W). To generate 10 1S openers (for North), run python -mredeal examples/onespade.py (actually this just checks that North has 12HCP and at least 5S, nothing more). This is the output I get:

♠KQJ64♡AT2♢84♣AK9 ♠85♡763♢A9♣JT8752 ♠T92♡854♢K6532♣Q4 ♠A73♡KQJ9♢QJT7♣63 ♠AKQ74♡86♢842♣AJ5 ♠86532♡K543♢K5♣Q9 ♠T♡QJT9♢J9763♣KT3 ♠J9♡A72♢AQT♣87642 ♠QT987♡AKT3♢A♣KQ2 ♠J642♡J5♢T962♣JT4 ♠A5♡Q9876♢J87♣A75 ♠K3♡42♢KQ543♣9863 ♠Q8752♡AQJT4♢73♣K ♠AKJ3♡6♢AT52♣QT82 ♠96♡98532♢QJ94♣A7 ♠T4♡K7♢K86♣J96543 ♠AJ963♡K85♢A4♣KT2 ♠84♡AJ♢KQ652♣9873 ♠T5♡T97642♢T8♣QJ6 ♠KQ72♡Q3♢J973♣A54 ♠KQJT7♡K43♢Q6♣JT8 ♠43♡JT9♢AT984♣AK7 ♠A9♡Q85♢KJ73♣9653 ♠8652♡A762♢52♣Q42 ♠QJ743♡K5♢AQ96♣86 ♠AK65♡JT632♢52♣J2 ♠T♡A9874♢J8♣AKT43 ♠982♡Q♢KT743♣Q975 ♠AKJ86♡AQ82♢85♣J6 ♠T42♡K3♢AT3♣AQT53 ♠973♡T65♢KQJ2♣K72 ♠Q5♡J974♢9764♣984 ♠AQ8632♡K32♢K♣K97 ♠J5♡AT♢AJ8♣AJT532 ♠KT♡J6♢T95432♣864 ♠974♡Q98754♢Q76♣Q ♠KT843♡KT♢AK87♣Q5 ♠97♡Q642♢Q943♣A42 ♠AQ62♡J9873♢♣T986 ♠J5♡A5♢JT652♣KJ73

Each of the North hands has 12+HCP and 5S.

Again, if you have any suggestions on how to clarify the README, please let me know.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-142446926.

anntzer commented 8 years ago

Try python -mredeal -l examples/onespade.py for a more intuitive output.

LyonsDo commented 8 years ago

I took the data from your example at https://github.com/anntzer/redeal

The first col is the N hand and seems to contain 4 hands with a six card suit - so might you have generated "at least a 5-card spade suit"?

On 23 September 2015 at 02:51, Antony Lee notifications@github.com wrote:

Try python -mredeal -l examples/onespade.py for a more intuitive output.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-142464092.

anntzer commented 8 years ago

The acceptance condition is len(deal.north.spades) >= 5 and deal.north.hcp >= 12, so it's indeed "at least 5 spades".

LyonsDo commented 8 years ago

Line 75 I think needs to be changed to

"for seat in global_defs.Seat:"

LyonsDo commented 8 years ago

And in two other places?

The gui then throws an error Exception in thread Thread-2: Traceback (most recent call last): File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\threading.py", line 923, in _bootstrap_inner self.run() File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\threading.py", line 871, in run self._target(_self._args, *_self._kwargs) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\gui.py", line 151, in target self.main.generate(simulation) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py", line 120, in generate dealer = redeal.Deal.prepare(self.predeal) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\redeal.py", line 265, in prepare raise Exception("Unused predeal entries: {}".format(predeal)) Exception: Unused predeal entries: {<Seat.N: 0>: (Holding(), Holding(), Holding(), Holding()), <Seat.W: 3>: (Holding(), Holding(), Holding(), Holding()), <Seat.S: 2>: (Holding(), Holding(), Holding(), Holding()), <Seat.E: 1>: (Holding(), Holding(), Holding(), Holding())}

On 23 September 2015 at 11:16, Donal Lyons donallyons00@gmail.com wrote:

Line 75 I think needs to be changed to

"for seat in global_defs.Seat:"

anntzer commented 8 years ago

I don't actually use the GUI so the code tends to fall behind; thanks for noticing the bugs. Should be working now.

LyonsDo commented 8 years ago

Thanks for that Antony. Not sure how often I'll use the GUI myself, but I was having some problem getting any output from a script I was writing - so I tried the GUI which now works fine. I was looking at "8753 QJT5 AT6 84" opposite a 15-17 NT and first tried that string (including quotes) in the GUI which didn't like it (no reason why it should really).

It worked as expected once I removed the quotes!

Donal.

On 23 September 2015 at 19:15, Antony Lee notifications@github.com wrote:

I don't actually use the GUI so the code tends to fall behind; thanks for noticing the bugs. Should be working now.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-142668781.

LyonsDo commented 8 years ago

Antony,

Finally, a more in-depth question. Your _solve_board is a wrapper for SolveBoard and I get the error below that the latter takes 5 arguments. But my understanding of SolveBoard is that it does actually take 6 arguments, namely struct deal dl, int target, int solutions, int mode, struct futureTricks *futp, int threadIndex

Anyway, the error I'm getting is: "futp = _solve_board(deal, Strain[strain], leader, -1, 1, 1) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\dds.py", line 101, in _solve_board status = dll.SolveBoard(c_deal, target, sol, mode, byref(futp), 0) TypeError: this function takes 5 arguments (6 given)"

Best,

Donal.

On 23 September 2015 at 20:10, Donal Lyons donallyons00@gmail.com wrote:

Thanks for that Antony. Not sure how often I'll use the GUI myself, but I was having some problem getting any output from a script I was writing - so I tried the GUI which now works fine. I was looking at "8753 QJT5 AT6 84" opposite a 15-17 NT and first tried that string (including quotes) in the GUI which didn't like it (no reason why it should really).

It worked as expected once I removed the quotes!

Donal.

On 23 September 2015 at 19:15, Antony Lee notifications@github.com wrote:

I don't actually use the GUI so the code tends to fall behind; thanks for noticing the bugs. Should be working now.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-142668781.

LyonsDo commented 8 years ago

Maybe this is related to 32-bit dll on 64-bit machine? Googling threw up the following "the double dummy solver is called by. calldll = SolveBoard(dealStr, target, solutions, mode, futureStr) With a 32-bits machine this code is functioning correct, but with a 64-bit machine the code generates next error code."

Donal.

On 24 September 2015 at 11:04, Donal Lyons donallyons00@gmail.com wrote: Antony,

Finally, a more in-depth question. Your _solve_board is a wrapper for SolveBoard and I get the error below that the latter takes 5 arguments. But my understanding of SolveBoard is that it does actually take 6 arguments, namely struct deal dl, int target, int solutions, int mode, struct futureTricks *futp, int threadIndex

Anyway, the error I'm getting is: "futp = _solve_board(deal, Strain[strain], leader, -1, 1, 1) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\dds.py", line 101, in _solve_board status = dll.SolveBoard(c_deal, target, sol, mode, byref(futp), 0) TypeError: this function takes 5 arguments (6 given)"

LyonsDo commented 8 years ago

Antony,

I thought the problems I was having might be due to a mix of 32 and 64 bit, so I rebuilt a 64-bit version and ran it under 64-bit Python 3.5.

Mostly it seems OK on the examples (it's years since I've worked with dlls and I was mildly surprised it wasn't a complete fiasco).

But there are still three examples which throw similar errors bbo_you_have_no_clue.py, bridgewinners_matchpoint_odds.py and opening_lead.py

C:\Users\DLyons\Downloads\redeal-master\redeal-master>python -m redeal examples/ bbo_you_have_no_clue.py Traceback (most recent call last): File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-64\Lib\runpy.py", line 170, in _run_module_as_main "main", mod_spec) File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-64\Lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 179, in console_entry() File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 168, in console_entry main.run() File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 162, in run self.generate(simulation) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 132, in generate simulation.do(deal) File "examples\bbo_you_have_no_clue.py", line 21, in do pass1N = deal.dd_score("1NN", vul=True) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\redeal.py", line 363, in dd_score self.dd_tricks(contract_declarer)) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\redeal.py", line 356, in dd_tricks self._dd_cache[strain, declarer] = dds.solve(self, strain, declarer) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\dds.py", li ne 113, in solve futp = _solve_board(deal, Strain[strain], leader, -1, 1, 1) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\dds.py", li ne 101, in _solve_board status = dll.SolveBoard(c_deal, target, sol, mode, byref(futp), 0) TypeError: this function takes 5 arguments (6 given)

LyonsDo commented 8 years ago

Antony,

The documentation is looking good.

I see you've put in some 64-bit checks into the sources - also good.

I have no idea what the following really means but might it be related to the 5 vs 6 parameter issue? "The DLL using cdecl calling convention instead of stdcall, so use CDLL not WinDLL"

I note that WinDLL occasionally appears in the sources.

Best,

Donal.

On 25 September 2015 at 19:42, Donal Lyons donallyons00@gmail.com wrote:

Antony,

I thought the problems I was having might be due to a mix of 32 and 64 bit, so I rebuilt a 64-bit version and ran it under 64-bit Python 3.5.

Mostly it seems OK on the examples (it's years since I've worked with dlls and I was mildly surprised it wasn't a complete fiasco).

But there are still three examples which throw similar errors bbo_you_have_no_clue.py, bridgewinners_matchpoint_odds.py and opening_lead.py

C:\Users\DLyons\Downloads\redeal-master\redeal-master>python -m redeal examples/ bbo_you_have_no_clue.py Traceback (most recent call last): File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-64\Lib\runpy.py", line 170, in _run_module_as_main "main", mod_spec) File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-64\Lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 179, in console_entry() File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 168, in console_entry main.run() File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 162, in run self.generate(simulation) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 132, in generate simulation.do(deal) File "examples\bbo_you_have_no_clue.py", line 21, in do pass1N = deal.dd_score("1NN", vul=True) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\redeal.py", line 363, in dd_score self.dd_tricks(contract_declarer)) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\redeal.py", line 356, in dd_tricks self._dd_cache[strain, declarer] = dds.solve(self, strain, declarer) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\dds.py", li ne 113, in solve futp = _solve_board(deal, Strain[strain], leader, -1, 1, 1) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\dds.py", li ne 101, in _solve_board status = dll.SolveBoard(c_deal, target, sol, mode, byref(futp), 0) TypeError: this function takes 5 arguments (6 given)

LyonsDo commented 8 years ago

https://www.google.ie/search?num=100&lr=&safe=images&as_qdr=all&q= "__cdecl"+"WINDLL"+arguments+calling+convention

On 25 September 2015 at 22:40, Donal Lyons donallyons00@gmail.com wrote:

Antony,

The documentation is looking good.

I see you've put in some 64-bit checks into the sources - also good.

I have no idea what the following really means but might it be related to the 5 vs 6 parameter issue? "The DLL using cdecl calling convention instead of stdcall, so use CDLL not WinDLL"

I note that WinDLL occasionally appears in the sources.

Best,

Donal.

On 25 September 2015 at 19:42, Donal Lyons donallyons00@gmail.com wrote:

Antony,

I thought the problems I was having might be due to a mix of 32 and 64 bit, so I rebuilt a 64-bit version and ran it under 64-bit Python 3.5.

Mostly it seems OK on the examples (it's years since I've worked with dlls and I was mildly surprised it wasn't a complete fiasco).

But there are still three examples which throw similar errors bbo_you_have_no_clue.py, bridgewinners_matchpoint_odds.py and opening_lead.py

C:\Users\DLyons\Downloads\redeal-master\redeal-master>python -m redeal examples/ bbo_you_have_no_clue.py Traceback (most recent call last): File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-64\Lib\runpy.py", line 170, in _run_module_as_main "main", mod_spec) File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-64\Lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 179, in console_entry() File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 168, in console_entry main.run() File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 162, in run self.generate(simulation) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redealmain.py ", line 132, in generate simulation.do(deal) File "examples\bbo_you_have_no_clue.py", line 21, in do pass1N = deal.dd_score("1NN", vul=True) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\redeal.py", line 363, in dd_score self.dd_tricks(contract_declarer)) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\redeal.py", line 356, in dd_tricks self._dd_cache[strain, declarer] = dds.solve(self, strain, declarer) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\dds.py", li ne 113, in solve futp = _solve_board(deal, Strain[strain], leader, -1, 1, 1) File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal\dds.py", li ne 101, in _solve_board status = dll.SolveBoard(c_deal, target, sol, mode, byref(futp), 0) TypeError: this function takes 5 arguments (6 given)

anntzer commented 8 years ago

Sorry, I'm a bit busy right now and will get back to the issues later. I notice that you mentioned having built a 64-bit DLL; do you mind sharing it with me? I may include it in the distribution, if eveything works well.

LyonsDo commented 8 years ago

There's no urgency on any of this.

You should have the 64-bit dll attached to one of the mails. If not let me know and I'll resend.

On 25 September 2015 at 22:45, Antony Lee notifications@github.com wrote:

Sorry, I'm a bit busy right now and will get back to the issues later. I notice that you mentioned having built a 64-bit DLL; do you mind sharing it with me? I may include it in the distribution, if eveything works well.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-143349064.

anntzer commented 8 years ago

I did not receive the DLL.

LyonsDo commented 8 years ago

Should be attached now.

On 25 September 2015 at 23:28, Antony Lee notifications@github.com wrote:

I did not receive the DLL.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-143358709.

anntzer commented 8 years ago

Attachments are lost when you email them via github. Can you put it on Dropbox or a similar service, and post a public link?

LyonsDo commented 8 years ago

Can you get it from https://www.dropbox.com/s/ujeluzyjrts8g6z/DDS.dll?dl=0

On 26 September 2015 at 01:17, Antony Lee notifications@github.com wrote:

Attachments are lost when you email them via github. Can you put it on Dropbox or a similar service, and post a public link?

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-143374082.

anntzer commented 8 years ago

Got it, thanks.

anntzer commented 8 years ago

I tried again the 32bit DLL with 32bit Python on Windows(64bit) and _solve_board works perfectly fine for me. Your 64bit DLL only works for Python3.5 for me; on Python 3.4, Windows complains that it is missing VCRUNTIME140.DLL.

LyonsDo commented 8 years ago

That's odd - I'll try the 32 bit again and see.

I installed 35 35 and haven't tested under 34..

On 26 September 2015 at 02:09, Antony Lee notifications@github.com wrote:

I tried again the 32bit DLL with 32bit Python on Windows(64bit) and _solve_board works perfectly fine for me. Your 64bit DLL only works for Python3.5 for me; on Python 3.4, Windows complains that it is missing VCRUNTIME140.DLL.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-143380672.

LyonsDo commented 8 years ago

OK - I found that my PATH was totally corrupt (nothing to do with Python) and even some Excel functions had stopped working. So that's the likely cause of any errors I was finding.

I tried dropping down to Python 2.7 to see if my issues were resolved, but it seems like you are working in Python 3 as I get C:\Users\DLyons\Downloads\redeal-master\redeal-master>setup.py build Traceback (most recent call last): File "C:\Users\DLyons\Downloads\redeal-master\redeal-master\setup.py", line 54 , in long_description=open("README.md", encoding="utf-8").read(), TypeError: 'encoding' is an invalid keyword argument for this function

So I'll move back up to 3.5 32-bit and work from there.

Re documentation I discovered that I don't understand the following - it's really hard to idiot-proof documentation :-) "cd to the directory where you downloaded the code and run ./setup.py install" Download is to the initial .zip file directory or where it was unpacked to??? And "./" gives error "." is not recognized as an internal ...

On 26 September 2015 at 04:53, Donal Lyons donallyons00@gmail.com wrote:

That's odd - I'll try the 32 bit again and see.

I installed 35 35 and haven't tested under 34..

On 26 September 2015 at 02:09, Antony Lee notifications@github.com wrote:

I tried again the 32bit DLL with 32bit Python on Windows(64bit) and _solve_board works perfectly fine for me. Your 64bit DLL only works for Python3.5 for me; on Python 3.4, Windows complains that it is missing VCRUNTIME140.DLL.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-143380672.

LyonsDo commented 8 years ago

Anthony,

Seems to have been the corrupt PATH issue.

Many thanks for all the help.

Donal.

LyonsDo commented 8 years ago

I've rebuilt under 3.5 with an explicit linker path to VCRUNTIME140.DLL . The new version is on Dropbox but I haven't tested it!

On 26 September 2015 at 02:09, Antony Lee notifications@github.com wrote:

I tried again the 32bit DLL with 32bit Python on Windows(64bit) and _solve_board works perfectly fine for me. Your 64bit DLL only works for Python3.5 for me; on Python 3.4, Windows complains that it is missing VCRUNTIME140.DLL.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-143380672.

LyonsDo commented 8 years ago

Hi Antony,

Redeal has been working fine for me thanks. I've generated some Soutien mineur inversé files and would like to pass them on to my partner in PBN format.

As far as I can see, SHORT is the closest to that and it's no big deal for me to do the conversion myself, but maybe PBN can be specified from the command line and I'm just missing something.

FYI, you're now listed on http://www.lajollabridge.com/Software/FreeSoftware.htm

Best,

Donal.

anntzer commented 8 years ago

Sorry for the lack of reply, I've been (and am still) pretty busy with other stuff recently. I will include the DLL in the next release. PBN output should be relatively easy to implement, do you want to give it a try? You basically need to add a third entry to the DealPrintStyle enum as well as in Deal.set_str_style, and implement Deal._pbn_str. On the CLI side you need to add a [-p|--pbn] flag (mutually exclusive with [-l|--long]) and handle it in Main.run. On the GUI side, best would probably be to replace the long checkbox with a tkinter.ttk.Combobox with the three possibilities.

LyonsDo commented 8 years ago

Thanks Antony,

I'll give that another go. I did part of what you suggest but something still threw errors.

Best,

Donal.

On 12 October 2015 at 08:05, Antony Lee notifications@github.com wrote:

Sorry for the lack of reply, I've been (and am still) pretty busy with other stuff recently. I will include the DLL in the next release. PBN output should be relatively easy to implement, do you want to give it a try? You basically need to add a third entry to the DealPrintStyle enum as well as in Deal.set_str_style, and implement Deal._pbn_str. On the CLI side you need to add a [-p|--pbn] flag ([image: mutually exclusive] https://camo.githubusercontent.com/6f7be070f442954c94e025f0d5674ad1b2120b32/68747470733a2f2f646f63732e707974686f6e2e6f72672f332f6c6962726172792f61726770617273652e68746d6c236d757475616c2d6578636c7573696f6e with [-l|--long]) and handle it in Main.run. On the GUI side, best w ould probably be to replace the long checkbox with a tkinter.ttk.Combobox with the three possibilities.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-147305589.

LyonsDo commented 8 years ago

Thanks Antony,

For the moment, I've just kludged it to meet my immediate needs. All hands dealt by North. Global_defs with deal_no = 0 vul_rot = ["None", "NS", "EW", "All", "NS", "EW", "All", "None", "EW", "All", "None", "NS", "All", "None", "NS", "EW" ] http://www.jazclass.aust.com/bridge/scoring/score11.htm

and

http://www.jazclass.aust.com/bridge/scoring/score11.htm def _pbn_str(self): """Return the deals in PBN format. """ global deal_no, vul_rot deal_no+=1 s = '[Board "' + str(deal_no) + '"]\n' s += '[Dealer "N"]\n' s += '[Vulnerable "' + str(vul_rot[(deal_no-1)%16]) + '"]\n' s += '[Deal "N:' s += self.north._short_str() + ' ' s += self.east._short_str() + ' ' s += self.south._short_str() + ' ' s += self.west._short_str() + '"]\n' s += '[Scoring "IMP"]\n' return s

Best,

Donal.

On 12 October 2015 at 09:29, Donal Lyons donallyons00@gmail.com wrote:

Thanks Antony,

I'll give that another go. I did part of what you suggest but something still threw errors.

Best,

Donal.

On 12 October 2015 at 08:05, Antony Lee notifications@github.com wrote:

Sorry for the lack of reply, I've been (and am still) pretty busy with other stuff recently. I will include the DLL in the next release. PBN output should be relatively easy to implement, do you want to give it a try? You basically need to add a third entry to the DealPrintStyle enum as well as in Deal.set_str_style, and implement Deal._pbn_str. On the CLI side you need to add a [-p|--pbn] flag ([image: mutually exclusive] https://camo.githubusercontent.com/6f7be070f442954c94e025f0d5674ad1b2120b32/68747470733a2f2f646f63732e707974686f6e2e6f72672f332f6c6962726172792f61726770617273652e68746d6c236d757475616c2d6578636c7573696f6e with [-l|--long]) and handle it in Main.run. On the GUI side, best w ould probably be to replace the long checkbox with a tkinter.ttk.Combobox with the three possibilities.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-147305589.

anntzer commented 8 years ago

See latest version for PBN support.

python -mredeal -flong ...
python -mredeal -fshort ...
python -mredeal -fpbn ...

or in the GUI.

Let me know if it works.

LyonsDo commented 8 years ago

Thanks Antony,

The PBN format seems fine - see the first line below.

But it now doesn't seem to be finding my definition file (with the accept statement)?

[Deal "N:AK.K765.KQJT72.K Q98653.AQ42.6.Q3 4.J98.A985.T9872 JT72.T3.43.AJ654"]

Tries: 50

C:\redeal-master\redeal>redeal -fpbn -n50 examples/smi.py Traceback (most recent call last): File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\Scripts\redeal -script.py", line 9, in load_entry_point('redeal==0.2.0', 'console_scripts', 'redeal')() File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\site-packa ges\redeal-0.2.0-py3.5.egg\redealmain.py", line 164, in console_entry main.parse_args() File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\site-packa ges\redeal-0.2.0-py3.5.egg\redealmain.py", line 80, in parse_args file, pathname, description = imp.find_module(name, [folder]) File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\Lib\imp.py", l ine 296, in find_module raise ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named 'smi'

Best,

Donal.

On 13 October 2015 at 20:20, Antony Lee notifications@github.com wrote:

See latest version for PBN support.

python -mredeal -flong ... python -mredeal -fshort ... python -mredeal -fpbn ...

or in the GUI.

Let me know if it works.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-147822150.

LyonsDo commented 8 years ago

As you said, it works fine when run as

C:\redeal-master>python -mredeal -fpbn smi.py

On 13 October 2015 at 21:03, Donal Lyons donallyons00@gmail.com wrote:

Thanks Antony,

The PBN format seems fine - see the first line below.

But it now doesn't seem to be finding my definition file (with the accept statement)?

[Deal "N:AK.K765.KQJT72.K Q98653.AQ42.6.Q3 4.J98.A985.T9872 JT72.T3.43.AJ654"]

Tries: 50

C:\redeal-master\redeal>redeal -fpbn -n50 examples/smi.py Traceback (most recent call last): File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\Scripts\redeal -script.py", line 9, in load_entry_point('redeal==0.2.0', 'console_scripts', 'redeal')() File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\site-packa ges\redeal-0.2.0-py3.5.egg\redealmain.py", line 164, in console_entry main.parse_args() File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\lib\site-packa ges\redeal-0.2.0-py3.5.egg\redealmain.py", line 80, in parse_args file, pathname, description = imp.find_module(name, [folder]) File "C:\Users\DLyons\AppData\Local\Programs\Python\Python35-32\Lib\imp.py", l ine 296, in find_module raise ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named 'smi'

Best,

Donal.

On 13 October 2015 at 20:20, Antony Lee notifications@github.com wrote:

See latest version for PBN support.

python -mredeal -flong ... python -mredeal -fshort ... python -mredeal -fpbn ...

or in the GUI.

Let me know if it works.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-147822150.

anntzer commented 8 years ago

Included your DLL in the latest commit. Still doesn't work for Python 64bit <3.5, but it's good enough for me.

LyonsDo commented 8 years ago

OK - when I get some time I'll rebuild and test. My youngest son is getting married in a few days and I'm working my way through my daughter's thesis prior to submission - so time's scarce right now.

Donal.

On 13 October 2015 at 23:19, Antony Lee notifications@github.com wrote:

Included your DLL in the latest release. Still doesn't work for Python 64bit <3.5, but it's good enough for me.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-147870328.

LyonsDo commented 8 years ago

What I'm currently looking at is a case where, at trick 3, the West declarer discovers a bad trump break. Given the play to date, I'd like to look at double dummy results for the continuation.

I've done simulations where the full East and West hands are input and have generated stats for those. I'd like to do something similar for the 10-card ending. Is that possible within redeal?

This technique would incidentally solve miniatures such as For example http://tedmuller.us/Bridge/Puzzles/M02-TheWhitfieldSix.htm

Regards,

Donal.

P.S. I've lost track of which software versions I'm using, but whatever they are calls to DDS seem to be working OK on a 64-bit Windows 7 machine.

anntzer commented 8 years ago

Although the underlying engine can certainly solve miniatures, specialized programs such as Bridge Calculator (which I like a lot) are probably better suited/simpler to use. The general case should also be workable, but I haven't thought much about an API yet. Perhaps something like:

def accept(deal):
    <initial shape conditions>
    deal.set_declarer("N")
    try:
        deal.play_trick("SA Sx Sx SJ")
    except CardNotAvailable: # cater for impossible shapes
        return False
    return True

and then the DDS would run on top of that?

LyonsDo commented 8 years ago

Thanks Antony.

That's a new program for me - thought I knew most of what was out there :-)

I'll think about your code snippet.

Much appreciated,

Donal.

On 14 November 2015 at 18:44, Antony Lee notifications@github.com wrote:

Although the underlying engine can certainly solve miniatures, specialized programs such as Bridge Calculator http://bcalc.w8.pl/ (which I like a lot) are probably better suited/simpler to use. The general case should also be workable, but I haven't thought much about an API yet. Perhaps something like:

def accept(deal):

deal.set_declarer("N") try: deal.play_trick("SA Sx Sx SJ") except CardNotAvailable: # cater for impossible shapes return False return True and then the DDS would run on top of that? — Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-156724734.
anntzer commented 8 years ago

Just to be clear: I don't have this functionality implemented yet. I am asking you for your opinion as to what programming interface would be most usable.

LyonsDo commented 8 years ago

I haven't thought this through. I'm currently looking at -W "AKQT8 KQ3 AQT2 3" -E "632 A62 94 AQT54" where declarer took the probably non-optimal line of cashing the two top trumps. N followed with 9S, 6C and S with 4S, 5S

So, ideally all that would go into the "accept". I'd then envisaged something like you said - that the dd engine could be cajoled into accepting the given input for the first two tricks and would then take over for the remainder of the deal.

On 14 November 2015 at 18:55, Antony Lee notifications@github.com wrote:

Just to be clear: I don't have this functionality implemented yet. I am asking you for your opinion as to what programming interface would be most usable.

— Reply to this email directly or view it on GitHub https://github.com/anntzer/redeal/issues/4#issuecomment-156727799.