Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative imports / DLLs #4

Open
LyonsDo opened this issue Sep 21, 2015 · 56 comments
Open

Relative imports / DLLs #4

LyonsDo opened this issue Sep 21, 2015 · 56 comments

Comments

@LyonsDo
Copy link

LyonsDo commented Sep 21, 2015

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
Copy link
Owner

anntzer commented Sep 21, 2015

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
Copy link
Author

LyonsDo commented Sep 21, 2015

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 [email protected] 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
#4 (comment).

@LyonsDo
Copy link
Author

LyonsDo commented Sep 21, 2015

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
Copy link
Author

LyonsDo commented Sep 21, 2015 via email

@anntzer
Copy link
Owner

anntzer commented Sep 21, 2015

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
Copy link
Author

LyonsDo commented Sep 21, 2015

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\redeal__main
.py
", line 178, in
console_entry()
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.py
", line 167, in console_entry
main.run()
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.py
", line 161, in run
self.generate(simulation)
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.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
Copy link
Author

LyonsDo commented Sep 21, 2015

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\redeal__main
.py
", line 178, in
console_entry()
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.py
", line 167, in console_entry
main.run()
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.py
", line 161, in run
self.generate(simulation)
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.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 [email protected] 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
#4 (comment).

@LyonsDo
Copy link
Author

LyonsDo commented Sep 21, 2015

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 [email protected] 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\redeal__main
.py
", line 178, in
console_entry()
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.py
", line 167, in console_entry
main.run()
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.py
", line 161, in run
self.generate(simulation)
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.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
Copy link
Owner

anntzer commented Sep 22, 2015

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
Copy link
Author

LyonsDo commented Sep 22, 2015 via email

@anntzer
Copy link
Owner

anntzer commented Sep 22, 2015

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
Copy link
Author

LyonsDo commented Sep 23, 2015

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 [email protected] 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
#4 (comment).

@anntzer
Copy link
Owner

anntzer commented Sep 23, 2015

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

@LyonsDo
Copy link
Author

LyonsDo commented Sep 23, 2015

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 [email protected] wrote:

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


Reply to this email directly or view it on GitHub
#4 (comment).

@anntzer
Copy link
Owner

anntzer commented Sep 23, 2015

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

@LyonsDo
Copy link
Author

LyonsDo commented Sep 23, 2015 via email

@LyonsDo
Copy link
Author

LyonsDo commented Sep 23, 2015

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\redeal__main
.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 [email protected] wrote:

Line 75 I think needs to be changed to

"for seat in global_defs.Seat:"

anntzer added a commit that referenced this issue Sep 23, 2015
@anntzer
Copy link
Owner

anntzer commented Sep 23, 2015

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

@LyonsDo
Copy link
Author

LyonsDo commented Sep 23, 2015

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 [email protected] 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
#4 (comment).

@LyonsDo
Copy link
Author

LyonsDo commented Sep 24, 2015

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 [email protected] 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 [email protected]
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
#4 (comment).

@LyonsDo
Copy link
Author

LyonsDo commented Sep 24, 2015

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 [email protected] 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
Copy link
Author

LyonsDo commented Sep 25, 2015

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\redeal__main
.py
", line 179, in
console_entry()
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.py
", line 168, in console_entry
main.run()
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.py
", line 162, in run
self.generate(simulation)
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.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
Copy link
Author

LyonsDo commented Sep 25, 2015

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 [email protected] 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\redeal__main
.py
", line 179, in
console_entry()
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.py
", line 168, in console_entry
main.run()
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.py
", line 162, in run
self.generate(simulation)
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.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
Copy link
Author

LyonsDo commented Sep 25, 2015

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 [email protected] 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 [email protected] 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\redeal__main
.py
", line 179, in
console_entry()
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.py
", line 168, in console_entry
main.run()
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.py
", line 162, in run
self.generate(simulation)
File
"C:\Users\DLyons\Downloads\redeal-master\redeal-master\redeal__main__.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
Copy link
Owner

anntzer commented Sep 25, 2015

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
Copy link
Author

LyonsDo commented Sep 25, 2015

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 [email protected] 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
#4 (comment).

@anntzer
Copy link
Owner

anntzer commented Sep 25, 2015

I did not receive the DLL.

@LyonsDo
Copy link
Author

LyonsDo commented Sep 25, 2015

Should be attached now.

On 25 September 2015 at 23:28, Antony Lee [email protected] wrote:

I did not receive the DLL.


Reply to this email directly or view it on GitHub
#4 (comment).

@anntzer
Copy link
Owner

anntzer commented Sep 25, 2015

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
Copy link
Author

LyonsDo commented Sep 25, 2015

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

On 26 September 2015 at 01:17, Antony Lee [email protected] 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
#4 (comment).

@anntzer
Copy link
Owner

anntzer commented Sep 25, 2015

Got it, thanks.

@anntzer
Copy link
Owner

anntzer commented Sep 26, 2015

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
Copy link
Author

LyonsDo commented Sep 26, 2015

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 [email protected] 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
#4 (comment).

@LyonsDo
Copy link
Author

LyonsDo commented Sep 26, 2015

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 [email protected] 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 [email protected]
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
#4 (comment).

@LyonsDo
Copy link
Author

LyonsDo commented Sep 26, 2015 via email

@LyonsDo
Copy link
Author

LyonsDo commented Sep 26, 2015

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 [email protected] 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
#4 (comment).

@LyonsDo
Copy link
Author

LyonsDo commented Oct 9, 2015 via email

@anntzer
Copy link
Owner

anntzer commented Oct 12, 2015

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
Copy link
Author

LyonsDo commented Oct 12, 2015

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 [email protected] 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
#4 (comment).

@LyonsDo
Copy link
Author

LyonsDo commented Oct 13, 2015

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 [email protected] 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 [email protected] 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
#4 (comment).

@anntzer
Copy link
Owner

anntzer commented Oct 13, 2015

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
Copy link
Author

LyonsDo commented Oct 13, 2015

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\redeal__main__.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\redeal__main__.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 [email protected] 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
#4 (comment).

@LyonsDo
Copy link
Author

LyonsDo commented Oct 13, 2015

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 [email protected] 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\redeal__main__.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\redeal__main__.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 [email protected] 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
#4 (comment).

@anntzer
Copy link
Owner

anntzer commented Oct 13, 2015

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

@LyonsDo
Copy link
Author

LyonsDo commented Oct 14, 2015

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 [email protected] 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
#4 (comment).

@LyonsDo
Copy link
Author

LyonsDo commented Nov 14, 2015 via email

@anntzer
Copy link
Owner

anntzer commented Nov 14, 2015

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
Copy link
Author

LyonsDo commented Nov 14, 2015

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 [email protected] 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
#4 (comment).

@anntzer
Copy link
Owner

anntzer commented Nov 14, 2015

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
Copy link
Author

LyonsDo commented Nov 14, 2015

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 [email protected] 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
#4 (comment).

@anntzer
Copy link
Owner

anntzer commented Nov 14, 2015

What was the lead and who's declarer?

@LyonsDo
Copy link
Author

LyonsDo commented Nov 14, 2015

Sorry

W declarer, contract 6S, lead JH.

On 14 November 2015 at 19:37, Antony Lee [email protected] wrote:

What was the lead and who's declarer?


Reply to this email directly or view it on GitHub
#4 (comment).

@anntzer
Copy link
Owner

anntzer commented Nov 14, 2015

From a bridge POV, looks like heart ace and diamond to queen. If it wins cash SA DA and ruff two diamonds is basically cold, if not they can return a club which is probably best -- I don't think I can cater for everything so I need to guess which minor to finesse.
After the given start, ugh...

I have a few other things on my plate but I'll get back to you once I implement this.

@LyonsDo
Copy link
Author

LyonsDo commented Nov 14, 2015

The two top trumps by my partner at least had the merit of showing the bad
break.

Me, I'd probably then have run the 9D (if S covers, then W also covers).
That has the merit in practice of driving out KD and one can do a trump
reduction without having to finesse the QC.

My stats says 6S is about 85% a priori. Given the 4-1 trump break, that
drops to 70% if the KD is offside with N but the JD onside with S.
And say 40% if both are offside (now depending on C finesse).

In practice, I wonder about leading small to the 9D and waiting for the
(fairly average) opposition to panic :-)

It's hard to evaluate the success conditions of the various lines of play
and even more so in a simultané where I strongly suspect deal bias (I'd
previously dropped an offside singleton K holding AQxx opposite JXxxxx).

On 14 November 2015 at 19:57, Antony Lee [email protected] wrote:

From a bridge POV, looks like heart ace and diamond to queen. If it wins
cash SA DA and ruff two diamonds is basically cold, if not they can return
a club which is probably best -- I don't think I can cater for everything
so I need to guess which minor to finesse.
After the given start, ugh...


Reply to this email directly or view it on GitHub
#4 (comment).

@anntzer
Copy link
Owner

anntzer commented Nov 14, 2015

Ah, it's matchpoints. In which case my line becomes much less attractive as it basically gives up on any chance for an overtrick (most likely there will be a diamond overruff, which I would welcome at IMPs).

@LyonsDo
Copy link
Author

LyonsDo commented Nov 14, 2015

Yes, the gambler in me much prefers matchpoints.

Case in point last week
3S - - ?
I hold K Qxx AQ AKJ10XXX

So wouldn't any red-blooded male bid 3NT? Apparently not - "On ne joue pas
le Poker, Donal"

I misplayed it to make only one overtrick (98% as opposed to 100%).

On 14 November 2015 at 21:51, Antony Lee [email protected] wrote:

Ah, it's matchpoints. In which case my line becomes much less attractive
as it basically gives up on any chance for an overtrick (most likely there
will be a diamond overruff, which I would welcome at IMPs).


Reply to this email directly or view it on GitHub
#4 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants