BBO Discussion Forums: Anyone out there good with a Double Dummy solver - BBO Discussion Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Anyone out there good with a Double Dummy solver

#1 User is offline   hrothgar 

  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 15,488
  • Joined: 2003-February-13
  • Gender:Male
  • Location:Natick, MA
  • Interests:Travel
    Cooking
    Brewing
    Hiking

Posted 2020-April-18, 07:51

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

Input
1. Specify a hand for North and a Second for South
2. Specify how many hands to generate for the simulation

Simulation

1. Generate a random hand for East + West
2. Solver for the number of tricks that N/S can make in each of the five possible denominations
3. Repeat N times

Output

A table with 5 columns and 13 rows

The columns show the five denominations
The rows show the number of times that "foo" tricks were taken
Alderaan delenda est
0

#2 User is offline   mycroft 

  • Secretary Bird
  • PipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 7,429
  • Joined: 2003-July-12
  • Gender:Male
  • Location:Calgary, D18; Chapala, D16

Posted 2020-April-27, 20:37

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).

When I go to sea, don't fear for me, Fear For The Storm -- Birdie and the Swansong (tSCoSI)
0

#3 User is offline   nige1 

  • 5-level belongs to me
  • PipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 9,128
  • Joined: 2004-August-30
  • Gender:Male
  • Location:Glasgow Scotland
  • Interests:Poems Computers

Posted 2020-April-28, 03:28

/** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
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)

0

#4 User is online   smerriman 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 4,036
  • Joined: 2014-March-15
  • Gender:Male

Posted 2020-April-28, 03:53

View Postnige1, on 2020-April-28, 03:28, said:


Interesting. The same code but at http://www.bridgebas...aler/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.
0

#5 User is offline   antonylee 

  • PipPipPipPip
  • Group: Full Members
  • Posts: 499
  • Joined: 2011-January-19
  • Gender:Male

Posted 2020-April-28, 06:32

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...
0

#6 User is offline   hrothgar 

  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 15,488
  • Joined: 2003-February-13
  • Gender:Male
  • Location:Natick, MA
  • Interests:Travel
    Cooking
    Brewing
    Hiking

Posted 2020-April-28, 07:59

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://bridgewinner...ge-to-beginers/
Alderaan delenda est
0

#7 User is offline   mycroft 

  • Secretary Bird
  • PipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 7,429
  • Joined: 2003-July-12
  • Gender:Male
  • Location:Calgary, D18; Chapala, D16

Posted 2020-April-28, 11:31

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.
When I go to sea, don't fear for me, Fear For The Storm -- Birdie and the Swansong (tSCoSI)
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users