hrothgar Posted April 18, 2020 Report Share Posted April 18, 2020 Hi all I am playing around with a project. I was hoping that someone who is good with some of the Double Dummy solvers out there might be able to help me with some example code. (Ideally, I was joping to use Deal, but I don't care that much) Here's what I would like to do Input1. Specify a hand for North and a Second for South2. Specify how many hands to generate for the simulation Simulation 1. Generate a random hand for East + West2. Solver for the number of tricks that N/S can make in each of the five possible denominations3. Repeat N times Output A table with 5 columns and 13 rows The columns show the five denominationsThe rows show the number of times that "foo" tricks were taken Quote Link to comment Share on other sites More sharing options...
mycroft Posted April 28, 2020 Report Share Posted April 28, 2020 I've written up an absolutely hack-level version of this to try to teach me Python-DDS. Turns out my code is almost as bad as the python "port" (more correctly, a ctypes wrapper around the C library). It will break if you put in bad input, it doesn't check your input, it stores things in such a way that I have to parse it 4 different times,... definitely a first draft. Unit testing is almost certainly the next step, and then working on making it pretty. But it works - I get a table of 5x14 counts: mycroft@yvette$ python3 hrothgar.py -n 'SAKQT6, DKT5, C65432' -s 'S854, HKJ, DA8432, CQT7' -x 10000 Loaded lib <CDLL './libdds.so', handle 1cda850 at 0x7f0f2f7a1e10> (#, S, H, D, C, NT) [(0, 0, 19, 0, 0, 0), (1, 0, 408, 0, 0, 1), (2, 0, 1152, 0, 0, 48), (3, 0, 2498, 0, 0, 250), (4, 0, 3431, 0, 0, 582), (5, 0, 2492, 0, 0, 765), (6, 16, 0, 6, 0, 893), (7, 178, 0, 233, 82, 422), (8, 1340, 0, 1949, 1246, 6240), (9, 5797, 0, 5367, 4545, 797), (10, 2404, 0, 2433, 3752, 2), (11, 265, 0, 12, 375, 0), (12, 0, 0, 0, 0, 0), (13, 0, 0, 0, 0, 0)] Questions:What kind of N are you thinking about? Right now it's all in lists and things, and memory could be a serious issue.Do you care about knowing the hands for all N, or just enough to do a double check on results?What kind of time are you looking at for generation? Seconds, Hours, Days? I'm currently taking 3:29 to DD-solve and collate 10000 hands (on an old computer, with 2017 version of the DDS library). Quote Link to comment Share on other sites More sharing options...
nige1 Posted April 28, 2020 Report Share Posted April 28, 2020 /** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** tricks.ds. 28 Apr 2020. Nigel Guthrie. South's double-dummy trick expectation. A separate table for each denomination. Script for Dealer by Hans van Staveren & Henk Uijterwaal http://dealergib1.bridgebase.com/tools/dealer/dealer.php *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** **/ produce 100 predeal north SQT32, HQ932, D864, CA9 predeal south SK8, HAK765, DK2, CQJ54 action frequency "Notrump" (tricks (south, notrump), 0, 13), frequency "Spades" (tricks (south, spades), 0, 13), frequency "Hearts" (tricks (south, hearts), 0, 13), frequency "Diamonds" (tricks (south, diamonds), 0, 13), frequency "Clubs" (tricks (south, clubs), 0, 13) Quote Link to comment Share on other sites More sharing options...
smerriman Posted April 28, 2020 Report Share Posted April 28, 2020 http://dealergib1.bridgebase.com/tools/dealer/dealer.phpInteresting. The same code but at http://www.bridgebase.com/tools/dealer/dealer.php gives an error about not being able to open a temporary file, so I had always assumed the double dummy portion was unusable. Quote Link to comment Share on other sites More sharing options...
antonylee Posted April 28, 2020 Report Share Posted April 28, 2020 I don't know if mycroft is referring to https://github.com/anntzer/redeal/ (of which I am the author) but if python is your thing: from redeal import * strains = "NSHDC" table = [[0 for strain in range(5)] for tricks in range(14)] def do(deal): for strain_idx, strain in enumerate(strains): tricks = max(deal.dd_tricks(f"1{strain}N"), deal.dd_tricks(f"1{strain}S")) table[tricks][strain_idx] += 1 def final(_): print("\t".join("#" + strains)) for i, row in enumerate(table): print("\t".join(map(str, [i, *row]))) run with $ python -mredeal /path/to/script.py -N "AKQT6 - KT5 65432" -S "854 KJ A8432 QT7" -n 1000 --verbose you get Using default for initial. Using default for accept. # N S H D C 0 0 0 4 0 0 1 1 0 43 0 0 2 1 0 102 0 0 3 23 0 268 0 0 4 67 0 336 0 0 5 90 0 247 0 0 6 90 1 0 3 0 7 29 22 0 32 10 8 617 140 0 178 131 9 82 562 0 533 441 10 0 247 0 254 381 11 0 28 0 0 37 12 0 0 0 0 0 13 0 0 0 0 0 took 71s for 1000 boards; could probably cut that in half by just reusing the work to solve the board in both directions... Quote Link to comment Share on other sites More sharing options...
hrothgar Posted April 28, 2020 Author Report Share Posted April 28, 2020 Thanks very much for the suggestions Especially for Niel for pointing out the tricks function in Dealer which I haven't used in the past For anyone who is interested, here is where I am going with this all https://bridgewinners.com/article/view/new-proposed-tool-for-teaching-bridge-to-beginers/ Quote Link to comment Share on other sites More sharing options...
mycroft Posted April 28, 2020 Report Share Posted April 28, 2020 I was actually working with a python wrapper (good code, but *not* a port. To give the author credit, he doesn't claim it is either) called python-dds. I too like the action in deal, if the bugs are out of it. MUCH better than my idea. I have, literally just today, run across Cunningham's Law: "The best way to get the right answer on the internet is not to ask a question; it's to post the wrong answer." Well, I guess I've proved it! I too think that the idea is a good one, but (as BW implies) I'm not the only one who "shouldn't be let near the novices". For exactly the same reason - we simply can't think that elementary any more. This idea of "here's two hands, where do you want to be?" is a great tool for the people in my club's 299er game, I think; I expect many in our open game (read: me) would learn a fair bit from it as well. And certainly from the point of learning matchpoint play (where question 1 when dummy comes down is "what is the actual contract?") this looks like a great learning tool. I would suggest that all of these uses are far beyond "absolute beginners". But that doesn't make the tool not useful. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.