| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 |
"http://www.w3.org/TR/html4/strict.dtd"> |
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<!-- $Id: GIBstuff.html 313 2009-06-11 05:44:13Z thomasoa $ --> |
| 6 |
|
| 7 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| 8 |
<LINK REL="SHORTCUT ICON" HREF="/icon/bridge.ico"> |
| 9 |
<link rel="stylesheet" type="text/css" href="look.css"> |
| 10 |
|
| 11 |
<title>Deal 3.1 - GIB interfaces</title> |
| 12 |
|
| 13 |
</head> |
| 14 |
<body> |
| 15 |
<div class="toplevel"> |
| 16 |
<h1>Deal 3.1 - GIB interfaces</h1> |
| 17 |
<p>If you add the line: |
| 18 |
<pre class='codesample'> |
| 19 |
source lib/gib.tcl |
| 20 |
</pre> |
| 21 |
<p>it will include the GIB interface library. |
| 22 |
<p> |
| 23 |
<span class="alert">This code only works on Windows.</span> |
| 24 |
|
| 25 |
<h2><span class="code">gib::directory</span></h2> |
| 26 |
This command tells Deal where GIB is installed. If GIB is installed |
| 27 |
in the standard Windows directory, |
| 28 |
<span class="code">C:\Program Files\GIB</span>, |
| 29 |
then you don't need to call this. But if it is installed elsewhere, |
| 30 |
you need to call this procedure: |
| 31 |
<pre class="codesample"> |
| 32 |
source lib/gib.tcl |
| 33 |
|
| 34 |
gib::directory "c:/Games/GIB" |
| 35 |
</pre> |
| 36 |
Note that Tcl uses forward-slash characters, <span |
| 37 |
class="code">/</span> to seperate directory patchs. |
| 38 |
<p> |
| 39 |
You can also just edit gib.tcl to permanently change the default. |
| 40 |
<p> |
| 41 |
Another thing you might want to change is where the gib library |
| 42 |
places temporary files. Currently, gib.tcl has the directory |
| 43 |
<span class="code">C:\temp</span> hard-coded for the temporary files. If you |
| 44 |
don't have such a directory, and don't want to create one, then you'll |
| 45 |
need to edit gib.tcl . |
| 46 |
|
| 47 |
<h2><span class="code">deal:tricks</span></h2> |
| 48 |
<p><span class="alert">Note: In past releases, you would use the <code>gib::tricks</code> command, but that is obsolete in Deal 3.1.</span></p> |
| 49 |
<p>By default, <code>deal::tricks</code> uses the built-in double dummy solver written by Bo Haglund. But when you include <code>lib/gib.tcl</code>, <code>deal::tricks</code> changes to call GIB's double dummy solver.</p> |
| 50 |
<p>The procedure <span class="code">deal::tricks</span> returns the number of tricks |
| 51 |
a hand can make in a specific denomination (suit or notrump.) |
| 52 |
For example: |
| 53 |
<pre class="codesample"> |
| 54 |
source lib/gib.tcl |
| 55 |
|
| 56 |
main { |
| 57 |
|
| 58 |
accept if {[deal::tricks south notrump]>=12} |
| 59 |
|
| 60 |
} |
| 61 |
</pre> |
| 62 |
|
| 63 |
finds deals where south can make 12 or more tricks in notrump, |
| 64 |
double-dummy. |
| 65 |
<p> |
| 66 |
This is going to be slow - each call to deal::tricks can take |
| 67 |
over a second - so you might try to put some additional |
| 68 |
conditions: |
| 69 |
<pre class="codesample"> |
| 70 |
source lib/gib.tcl |
| 71 |
|
| 72 |
main { |
| 73 |
|
| 74 |
reject if {[hcp north]+[hcp south]<26} |
| 75 |
|
| 76 |
accept if {[deal::tricks south notrump]>=12} |
| 77 |
|
| 78 |
} |
| 79 |
</pre> |
| 80 |
That might miss the occasional freakish slam, but it will be considerably |
| 81 |
faster. |
| 82 |
|
| 83 |
<p> |
| 84 |
The <span class="code">deal::tricks</span> procedure caches values, |
| 85 |
so that multiple calls with the same parameters on the same deal |
| 86 |
result in quick turn-around. |
| 87 |
<p> |
| 88 |
This is useful if we are using the <span class="code">parscore</span> |
| 89 |
in our query, or if we use the output format, <span class="code">gibpar</span>, |
| 90 |
discussed later. |
| 91 |
|
| 92 |
<h2><span class="code">parscore</span></h2> |
| 93 |
|
| 94 |
<p>This routine determines the double-dummy par score for a deal. Because |
| 95 |
it calls <code>deal::tricks</code> 20 times - once for each declarer and denomination - it |
| 96 |
can take 20 seconds or more per deal. Not good for huge batches. |
| 97 |
<p>Parscore takes as input the dealer and vulnerability: |
| 98 |
<pre class="codesample"> |
| 99 |
set result [parscore north NS] |
| 100 |
set contract [lindex $result 0] |
| 101 |
set declarer [lindex $result 1] |
| 102 |
set score [lindex $result 2] |
| 103 |
set tricks [lindex $result 3] |
| 104 |
set auction [lindex $result 4] |
| 105 |
</pre> |
| 106 |
Vulnerability can be one of <span class="code">None</span>, <span class="code">NS</span>, <span class="code">EW</span>, |
| 107 |
or <span class="code">All</span>. |
| 108 |
<p> |
| 109 |
The result returned is fairly complex - it consists of a list of elements. |
| 110 |
<ul> |
| 111 |
<li> The first element is a contract, in the form "2 spades doubled" or "2 spades." [ Double-dummy par scores are, of course, never redoubled. ] |
| 112 |
<li> The second element is the declarer. |
| 113 |
<li> The third element is the score |
| 114 |
<li> The fourth element is the number of tricks declarer can take. |
| 115 |
<li> The fifth is a stupid auction to get to the contract. If north is dealer |
| 116 |
and east is declarer in the double-dummy par contract of 4 clubs doubled, |
| 117 |
the auction will be "Pass 4C X Pass Pass Pass". Not very inspired, but |
| 118 |
needed for the <span class="code">gibpar</span> application, below. |
| 119 |
</ul> |
| 120 |
|
| 121 |
<span style="font-size: small">[Why do we need to know the dealer? Suppose north <em>and</em> east are |
| 122 |
the only ones who can make 1NT, and that no higher contracts make. Then |
| 123 |
double-dummy par is 1NT by east if east is dealer, while it is 1NT by north |
| 124 |
if anybody else is dealer.]</span> |
| 125 |
|
| 126 |
<h2>The <span class="code">gibpar</span> format</h2> |
| 127 |
|
| 128 |
As soon as I got GIB, I wanted to use Deal to generate PBN files for |
| 129 |
GIB to use in play. It was trickier than I thought - GIB apparently |
| 130 |
wants a *score* in the PBN file. This was why I created the |
| 131 |
<span class="code">parscore</span> command above - so that I could write out a PBN |
| 132 |
file with a score which was objective, rather than random. |
| 133 |
<p> |
| 134 |
This format is used like any other format: |
| 135 |
<pre class="codesample"> |
| 136 |
C:\Deal30> deal -i format/gibpar 36 > myfile.pbn |
| 137 |
</pre> |
| 138 |
|
| 139 |
As with any other Deal format, <span class="code">format/gibpar</span> can be used with filters: |
| 140 |
|
| 141 |
<pre class="codesample"> |
| 142 |
C:\Deal30> deal -i format/gibpar -i ex/1.tcl > myfile.pbn |
| 143 |
</pre> |
| 144 |
|
| 145 |
Once you've generated this PBN file, you can load it into GIB via the |
| 146 |
"Load Saved Deal" command. |
| 147 |
<p> |
| 148 |
Competing against double-dummy par is grueling work - it's essentially |
| 149 |
playing a team game where everybody at the other table is an |
| 150 |
infallible psychic - both your "opponents" and your teammates. |
| 151 |
That means that any swings are due to errors at your table |
| 152 |
and/or luck. They will always bid that making 15% grand at the |
| 153 |
other table, for example. |
| 154 |
<hr> |
| 155 |
<table><tr><td><a href="../"> |
| 156 |
<img style="border:0;width:40px;height:56px" alt="Silhouette" src="graphics/StampSm.gif"></a><td> |
| 157 |
<a NAME="mysig"> Thomas Andrews</a> |
| 158 |
(<a href="mailto:[email protected]">[email protected]</a>) |
| 159 |
<a name="caveat"> Copyright 1996-2008.</a> Deal is covered by the |
| 160 |
<a href="http://www.gnu.org/copyleft/gpl.html">GNU General Public License.</a> |
| 161 |
<p> |
| 162 |
<a href="graphics/falling.jpg"><em>Plane Dealing</em></a> graphic |
| 163 |
above created using |
| 164 |
<a href="http://www.povray.org/">POV-Ray.</a> |
| 165 |
</tr></table> |
| 166 |
</div> |