Back to Deal Top Page.
Plane Dealing image

Deal 2.0

Reference Guide

Covering:
  • Command line arguments
  • Additive Functions
  • Shape Functions and Classes
  • String Boxes and formatting
  • Often used Tcl features
  • Library routines

Command Line Options

-e expr
Evaluate the Tcl expression expr. Not very useful, but occasionally good for setting variables which affect the user's script, like:
deal -i userscript -e "set maxnorth 10"
-v
Verbose mode. Lets you know how many hands have been accepted and how many hands have been tried.
-[NSEW] hand-spec
Specifies the cards held by the specified hand. The hand-spec should be of the form: "AK8532 - KQ72 A65". Voids must be represented with a '-' character. hand-spec should be one argument, so the string should be quoted on the command line.
-i file
Source the commands in the file named. The language used is "Tcl". Read the man page for Tcl for help in writing Tcl code. Additions to Tcl specific to deal are listed in this manual.
-x file
Like -i, except execute this file and then exit.
-f
Instead of dealing new hands, reads hands from standard input. The hands must be in the format put out by "deal -l". You might deal, say, 10,000 hands which satisfy specific criteria, saving them to a file. Then you can use that output for input with deal -f to find out which hands satisfy other constraints.
-t
Print distribution table and exit. The distribution table is an ordered list of all possible hand patterns for a single hand.
-l
Write deals in a "single-line" format. In previous releases this was the default format. It is useful for piping to formatters written in other languages. Most formatting can be defined internally, using Tcl now. Still useful with the "-f" option.

Simple Usage

The most basic usage of the program is to generate random deals with no conditions:
% deal 2
	  S : QJ9
	  H : AJ
	  D : T52
	  C : AKQ84
 S : 752            S : AK83         
 H : T85            H : Q632         
 D : AK8763         D : J4           
 C : 2              C : T96          
	  S: T64
	  H: K974
	  D: Q9
	  C: J753
---------------------------
	  S : QJ9
	  H : 52
	  D : AKJT9
	  C : A86
 S : 763            S : A52          
 H : T763           H : J98          
 D : Q54            D : 876          
 C : T95            C : KQJ7         
	  S: KT84
	  H: AKQ4
	  D: 32
	  C: 432
---------------------------
If you want a raw format, more readable by external programs, use the -l flag, which prints deals in a single-line format:
% deal -l 5
K75 T987 AQT5 95|AQ86 2 943 QJ643|JT32 J43 KJ KT82|94 AKQ65 8762 A7
QJ96 KQ6 T95 K76|T5 J953 A72 AJT9|8432 A7 83 Q8432|AK7 T842 KQJ64 5
K52 QJT9 AKQ K63|AJ AK7542 T732 8|94 3 J965 QJT972|QT8763 86 84 A54
A76 A764 43 KJT2|J9 KJ53 K986 A87|K8543 T82 72 953|QT2 Q9 AQJT5 Q64
Q6 QJ75 3 AJ7642|AT9874 KT963 AT |K32 4 QJ2 KQ9853|J5 A82 K987654 T
This output form is crude; it is meant to be post-processed. Each line is of the form:
"North|East|South|West"
Each hand is specified by:
"Spades Hearts Diamondsar> Diay.tcl will use the value stored doubledummy.txt.
For Programmers
Implementation:
Tcl
Location:
format/ddline

Silhouette Thomas Andrews (deal@thomasoandrews.com) Copyright 1996-2010. Deal is covered by the GNU General Public License.

Plane Dealing graphic above created using POV-Ray.

./usr/share/doc/deal/html/examples.html0000644000000000000000000000602411355744740016762 0ustar rootroot Deal - Example Scripts
Back to Deal Top Page
Plane Dealing image

Deal 3.1

Examples



Silhouette Thomas Andrews (deal@thomasoandrews.com) Copyright 1996-2010. Deal is covered by the GNU General Public License.

Plane Dealing graphic above created using POV-Ray.

./usr/share/doc/deal/html/holding.html0000644000000000000000000001256011355744740016572 0ustar rootroot Holding Procedures

Holding Procedures in Deal 3.1 and iDeal

Introduction

One of the main new bridge evaluation features in Deal 3.1 and iDeal is the ability to define fast procedures for evaluating a single holding.

In Deal 2.0, we were able to define Vector functions, which assigned integer values to each card. This covered a lot of standard evaluation techniques, but not the more complicated forms. Evaluators like "quick tricks" and "losers," while still computed suit by suit and totaled, cannot be defined by assigning values to cards alone.

The solution is to allow the creation of general procedures for evaluating a holding, while still taking advantage of fast lookup tables. Thus, the introduction of the holdingProc command.

The holdingProc Command

holdingProc looks like a normal Tcl definition of a procedure. For example, we might write:
holdingProc HCP {A K Q J} {
    expr {$A*4+$K*3+$Q*2+$J}
}
to define a function called HCP. This function behaves exactly the same as the builtin hcp routine - the user can ask for the total points in a hand or for a specific suit in the hand:
set n [HCP north]
set hs [HCP north spades]
When evaluated, the parameter A is set to one if the holding has the ace, and zero otherwise.

That's a simple example, but let's say we want to do some smart reevaluation. For example, we might want to add a point for each card in a suit beyond the fourth. We also might want to evaluate a stiff king as two points, rather than three, a stiff queen as zero, and a doubleton queen as one.

We can do this by adding a "length" parameter to the parameters list:

holdingProc SmartHCP {A K Q J length} {

    if {$length>=4} {
        # Normal evaluation, +1 for each card longer than the fourth
	return [expr {$A*4+$K*3+$Q*2+$J+($len-4)}]
    }

    if {$length==3} {
        # Normal evaluation for 3-card suits
	return [expr {$A*4+$K*3+$Q*2+$J}]
    }

    if {$length==2} {
        # Jacks in doubletons are worth zero, queens one
	return [expr {$A*4+$K*3+$Q}]
    }

    if {$length==1} {
        # Queens and jacks in singletons are worth zero, kings two
	return [expr {$A*4+$K*2}]
    }

    return 0
}
Even though this code is slow, it is only evaluated at most 160 times, after which values are reused, yielding remarkably fast evaluations. One deal, you might get a holding of KQ75 which this routine evaluates as if it were evaluating KQxx. The next hand, it sees the holding KQ82 and, seeing this also as KQxx, remembers the previous value.

Types of Holding Procedures

By default, the holding procedure assumes that the values returned are integers, so that when it tries to add up the values of all four suits, it applies an integer sum.

If you want the return value interpreted as a double, you can specify it in the declaration. For example, we can define a quick tricks procedure:

holdingProc -double QuickTricks {A K Q J T length} {
    if {$A&&$K} { return 2 }
    if {$A} { return 1 }
    if {$K && ($Q || ($J && $T))} {
         return 1
    }
    if {$K && $length>1} {
            return 0.5
    }
    return 0
}

You can define the type to be any of the following:

-integer
The default, adds integer values when evaluated across multiple suits.
-double
Adds resulting values as doubles when evaluated across multiple suits.
-boolean
When evaluated on a hand, lists the suits, by name, which evaluate as true. For example, if you defined 'biddableSuit' it would return the list "spades hearts" for the hand KT954 AJ32 94 92.
-string
Returns a list of values when evaluated on multiple suits.

Arguments Allowed

The arguments are interpreted based on the first character of their name, or, in the case of spots, via the idiom 'x.' For example, we could have defined SmartHCP as:
holdingProc SmartHCP {ace King QuizShow j len} {
      ...
}
They can occur in any order.

For spot cards, you can use arguments named "x2", "x3", "x4", .., and "x9." The ten can be passed as "x10" or "T."

One last possible parameter is anything beginning with an "s" or "S", which means that the holding is passed as a string. This is useful when you already have a hash table somewhere for stored data. For example, the 'ddeval' code which comes with iDeal and Deal 3.1 uses a table of raw data created in advance.


Silhouette Thomas Andrews (deal@thomasoandrews.com) Copyright 1996-2010. Deal is covered by the GNU General Public License.

Plane Dealing graphic above created using POV-Ray.

./usr/share/doc/deal/html/reference.html0000644000000000000000000005000411355744740017077 0ustar rootroot Deal - New Features in Version 2.0
Back to Deal Top Page.
Plane Dealing image

Deal 2.0

Reference Guide

Covering:
  • Command line arguments
  • Additive Functions
  • Shape Functions and Classes
  • String Boxes and formatting
  • Often used Tcl features
  • Library routines

Command Line Options

-e expr
Evaluate the Tcl expression expr. Not very useful, but occasionally good for setting variables which affect the user's script, like:
deal -i userscript -e "set maxnorth 10"
-v
Verbose mode. Lets you know how many hands have been accepted and how many hands have been tried.
-[NSEW] hand-spec
Specifies the cards held by the specified hand. The hand-spec should be of the form: "AK8532 - KQ72 A65". Voids must be represented with a '-' character. hand-spec should be one argument, so the string should be quoted on the command line.
-i file
Source the commands in the file named. The language used is "Tcl". Read the man page for Tcl for help in writing Tcl code. Additions to Tcl specific to deal are listed in this manual.
-x file
Like -i, except execute this file and then exit.
-f
Instead of dealing new hands, reads hands from standard input. The hands must be in the format put out by "deal -l". You might deal, say, 10,000 hands which satisfy specific criteria, saving them to a file. Then you can use that output for input with deal -f to find out which hands satisfy other constraints.
-t
Print distribution table and exit. The distribution table is an ordered list of all possible hand patterns for a single hand.
-l
Write deals in a "single-line" format. In previous releases this was the default format. It is useful for piping to formatters written in other languages. Most formatting can be defined internally, using Tcl now. Still useful with the "-f" option.

Simple Usage

The most basic usage of the program is to generate random deals with no conditions:
% deal 2
	  S : QJ9
	  H : AJ
	  D : T52
	  C : AKQ84
 S : 752            S : AK83         
 H : T85            H : Q632         
 D : AK8763         D : J4           
 C : 2              C : T96          
	  S: T64
	  H: K974
	  D: Q9
	  C: J753
---------------------------
	  S : QJ9
	  H : 52
	  D : AKJT9
	  C : A86
 S : 763            S : A52          
 H : T763           H : J98          
 D : Q54            D : 876          
 C : T95            C : KQJ7         
	  S: KT84
	  H: AKQ4
	  D: 32
	  C: 432
---------------------------
If you want a raw format, more readable by external programs, use the -l flag, which prints deals in a single-line format:
% deal -l 5
K75 T987 AQT5 95|AQ86 2 943 QJ643|JT32 J43 KJ KT82|94 AKQ65 8762 A7
QJ96 KQ6 T95 K76|T5 J953 A72 AJT9|8432 A7 83 Q8432|AK7 T842 KQJ64 5
K52 QJT9 AKQ K63|AJ AK7542 T732 8|94 3 J965 QJT972|QT8763 86 84 A54
A76 A764 43 KJT2|J9 KJ53 K986 A87|K8543 T82 72 953|QT2 Q9 AQJT5 Q64
Q6