~ubuntu-branches/ubuntu/utopic/dds/utopic-proposed

« back to all changes in this revision

Viewing changes to DLL-dds_20_i.txt

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2010-04-20 23:27:57 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100420232757-rzez7nr9st6ymeje
Tags: 2.0.0+ddd105-1
* New dds upstream version (only bumping version).
* Add SolveBoard.3 manpage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Bo Haglund, Bob Richardson
 
2
Rev I, 2010-04-10
 
3
Latest DLL issue with this description is available at http://www.bahnhof.se/wb758135/
 
4
 
 
5
 
 
6
Short description of the DLL functions supported in Double Dummy Problem Solver 2.0
 
7
 
 
8
Callable functions
 
9
 
 
10
extern "C" __declspec(dllimport) int __stdcall SolveBoard(struct deal, int target,  
 
11
    int solutions,  int mode, struct futureTricks *futp, int threadIndex);
 
12
 
 
13
extern "C" __declspec(dllimport) int __stdcall CalcDDtable(struct ddTableDeal tableDeal, struct ddTableResults * tablep);
 
14
 
 
15
 
 
16
SolveBoard
 
17
 
 
18
SolveBoard is thread-safe, so several threads (max 16) can call SolveBoard in parallel.
 
19
 
 
20
Before SolveBoard can be called, a structure of type "futureTricks" must be declared. 
 
21
 
 
22
SolveBoard returns a status integer, "no fault" means the DLL supplies the trick data in the "futureTricks" type structure.
 
23
Status codes:   
 
24
   1=No fault, 
 
25
  -1=Unknown fault, 
 
26
  -2=No of cards = 0, 
 
27
  -3=target > Number of tricks left,                         
 
28
  -4=Duplicated cards, 
 
29
  -5=target < -1, 
 
30
  -7=target >13, 
 
31
  -8=solutions < 1, 
 
32
  -9=solutions > 3, 
 
33
-10=No of cards > 52
 
34
-11=Not used
 
35
-12=Suit or rank value out of range for deal.currentTrickSuit or deal.currentTrickRank.
 
36
-13=Card already played in the current trick is also defined as a remaining card to play.
 
37
-14=Wrong number of remaining cards for a hand.
 
38
-15=threadIndex < 0 or > 15.
 
39
  
 
40
Structure ”deal” defines all data needed to describe the deal to be analyzed.
 
41
struct deal { 
 
42
   int trump;   /* I.e. which suit that is trump or if contract is NT, Spades=0, Hearts=1, Diamonds=2, Clubs=3,  NT=4 */ 
 
43
   int first;      /* 0-3, 0=North, 1=East, 2=South, 3=West , Leading hand for the trick.*/ 
 
44
    int currentTrickSuit[3];  /* 0-2 for up to 3 cards in the order played */
 
45
   int currentTrickRank[3];  /* 2-14 for up to 3 cards */
 
46
   unsigned int remainCards[4][4]; /* 1st index hand (0-3), 2nd index suit (0-3), values as bitstring of ranks bit 0=0, bit 1=0, bit 2=rank 2, ………. bit 14=rank 14, bit 15=0 for cards remaining after already played cards (cards already played to the current trick are not included in this bitstring).  
 
47
 The decimal value for a card then range between 4 (=rank 2) and 16384  (Ace=rank 14). */ 
 
48
}; 
 
49
 
 
50
Parameter ”target” is the number of tricks to be won by the side to play, -1 means that the program shall find the maximum number. For equivalent  cards only the highest is returned. 
 
51
 
 
52
Parameter ”solutions” defines how many card solutions that SolveBoard must return:
 
53
  target=1-13, solutions=1:  Returns only one of the cards. Its returned score is the same as target whentarget or higher tricks can be won. Otherwise, score –1 is returned if target cannot be reached, or score 0 if no tricks can be won. 
 
54
  target=-1, solutions=1:  Returns only one of the optimum cards and its score.
 
55
  target=0, solutions=1:  Returns only one of the cards legal to play with score set to 0.
 
56
  target 1-13, solutions=2:  Return all cards meeting target. Their returned scores are the same as target when target or higher tricks can be won. Otherwise, only one card is returned with score –1 if target cannot be reached, or score 0 for all cards legal to play if no tricks can be won.
 
57
  target –1, solutions=2:  Return all optimum cards with their scores.
 
58
  target=0, solutions=2:  Return all cards legal to play with scores set to 0.
 
59
  target irrelevant, solutions=3:  Return all cards that can be legally played with their scores in descending  order.
 
60
 
 
61
Parameter ”mode” defines the DLL mode of operation. This mode does not affect the DLL if there are multiple choices for cards to play. If there is just one card to play, or multiple cards that are all equivalent, this mode determines  whether or not the DLL will search to find the score.
 
62
  mode=0:  Do not search to find the score if the hand to play has only one card, including its equivalents, to play. Score is set to –2 for this card, indicating that there are no alternative cards. This mode is very fast but you don’t 
 
63
  mode=1:  Always search to find the score. Even when the hand to play has only one card,  with possible equivalents, to play.  For both mode=0 and mode=1: If the preceding SolveBoard call had the same trump suit and the same or similar deal, except for deal.first, then the transposition table contents is reused from the preceding SolveBoard call. Setting mode=2 is no longer needed, but can still be done for backwards
 
64
compatibility.
 
65
  mode=2:  As for mode=1, but the transposition table contents is reused from the preceding SolveBoard call. Deal must be the same, except for deal.first. Trump suit must be the same. Example:
 
66
1st call:  SolveBoard(deal, -1, 1, 1, &fut),  deal.first=1, i.e. East leads.
 
67
        2nd call:  SolveBoard(deal, -1, 1, 2, &fut),  deal.first=2, i.e. South leads.
 
68
        3rd call:  SolveBoard(deal, -1, 1, 2, &fut),  deal.first=3, i.e. West leads. 
 
69
4th call:  SolveBoard(deal, -1, 1, 2, &fut),  deal.first=0, i.e. North leads.   
 
70
 
 
71
struct futureTricks { /* The DLL provides the score (number of tricks) that can be won by the card to play defined by its suit and rank. Array of all alternative cards. */ 
 
72
  int nodes;     /* Number of searched nodes */
 
73
  int cards;         /*  No of alternative cards  */
 
74
  int suit[13];         /* 0=Spades, 1=Hearts, 2=Diamonds, 3=Clubs */
 
75
  int rank[13];        /* 2-14 for 2 through Ace */ 
 
76
  int equals[13];        /* Bitstring of ranks for equivalent lower rank cards. The decimal value range between 4 (=2) and 8192 (King=rank 13).  When there are several ”equals”, the value is the sum of each ”equal”. */
 
77
  int score[13];     /* -1 indicates that target was not reached, otherwise target or max numbe of tricks */ 
 
78
} ; 
 
79
 
 
80
Parameter ”threadIndex” defines the identity of the thread used when calling SolveBoard.
 
81
Maximum 16 threads can call SolveBoard in parallel, threadIndex must be an integer of the range 0..15.
 
82
 
 
83
 
 
84
CalcDDtable
 
85
 
 
86
CalcDDtable calculates the double dummy values of the initial 52 cards for all the 20 trump suit/leading hand combinations.   
 
87
 
 
88
Before CalcDDtable can be called, a structure of type " ddTableResults" must be declared.
 
89
CalcDDtable returns a status integer, "no fault" means the DLL supplies the double dummy scores in the "ddTableResults" type structure.
 
90
Status codes:   
 
91
   1=No fault,
 
92
   Other status codes are errors, with codes equal to SolveBoard status codes.   
 
93
 
 
94
Structure ”ddTableDeal” defines the dealt cards to be analyzed.
 
95
struct ddTableDeal {
 
96
  unsigned int cards[4][4];   /* 1st index is hand, 2nd index is suit, same coding as for deal.remainCards for SolveBoard. */
 
97
};
 
98
 
 
99
struct ddTableResults { /* For each combination trump suit / leading hand, the DLL provides the double dummy score. */
 
100
  int resTable[5][4];   /* 1st index is trump (0=Spades, 1=Hearts, 2=Diamonds, 3=Clubs, 4=No Trump 2nd index is leading hand, 0=North, 1=East, 2=South, 3=West */
 
101
};
 
102
 
 
103
 
 
104
 
 
105
 
 
106
Revision History
 
107
 
 
108
Rev A, 2006-02-25.              First issue.
 
109
 
 
110
Rev B, 2006-03-20               Updated issue.
 
111
 
 
112
Rev C, 2006-03-28       Updated issue. Addition of the SolveBoard parameter ”mode”.
 
113
 
 
114
Rev D, 2006-04-05       Updated issue. Usage of target=0 to list all cards that are legal to play.
 
115
 
 
116
Rev E, 2006-05-29       Updated issue. New error code –10 for number of cards > 52.
 
117
 
 
118
Rev F, 2006-08-09       Updated issue. New mode parameter value = 2. New error code –11 for calling SolveBoard with mode = 2 and forbidden values of other parameters.
 
119
 
 
120
Rev F1, 2006-08-14      Clarifications on conditions for returning scores for the different combinations of the values for target and solutions.
 
121
 
 
122
Rev F2, 2006-08-26      New error code –12 for wrongly set values of deal.currentTrickSuit and
 
123
deal.currentTrickRank.
 
124
 
 
125
Rev G, 2007-01-04       New DDS release 1.1, otherwise no change compared to isse F2.
 
126
 
 
127
Rev H, 2007-04-23       DDS release 1.4, changes for parameter mode=2.
 
128
 
 
129
Rev I,  2010-04-10      DDS release 2.0, multi-thread support.