2
Goal
Given a deal result from Duplicate Contract Bridge, calculate the deal score.
Basically the same as iBug's question, which was deleted. I figured out this scoring system while trying to answer that question.
Input
Input is a deal result, and whether or not the declaring side is vulnerable.
The deal result is a string in the following format:
[contract] [result]
The contract is defined as follows:
[tricks][suit][doubling]
- The
tricks
is a number1-7
(both inclusive), - The
suit
is one ofC
,H
,S
,D
, orNT
(Clubs, Hearts, Spades, Diamonds, and notrump)- Suits are grouped as follows:
notrump: NT
,Major suits: H, S
andMinor suits: C, D
.
- Suits are grouped as follows:
doubling
can be blank ,X
orXX
(Undoubled, Doubled, Redoubled)
result
is the resulting number of 'tricks' in relation to the contract. The value can be in the range [-13; +6]
, depending on the value
(sign included).
The sum of contract number
and result
must be in the range[-6; 7]
, which means:
- For
tricks= 1
,result
must be[-7; +6]
- For
tricks= 2
,result
must be[-8; +5]
- ..
- For
tricks= 7
,result
must be[-13; 0]
Examples of valid deal results:
1S 0
, 4NT -3
, 7NTXX -13
, 3HX +3
Vulnerability can be input as a boolean or any truthy/falsy value.
Output
Output is the scoring of the deal result.
The score is based on the number of tricks in a deal, and whether it reached the contract.
Scoring
The score is a measure of the result compared to the contract.
If the contract is made, the score for each such deal consists of:
- Contract points, assigned to each trick bid and made
- Overtrick points, assigned for each trick taken over the contracted number of tricks
- A slam bonus for a small slam or grand slam contract
- A doubling bonus
- A game bonus
If the contract is defeated, the defenders receive
- Penalty points, assigned for every undertrick (negative value of
result
)
Contract points:
Contract points are awarded for the tricks of the contract.
Points per trick
Suit undoubled doubled redoubled
------------------------------------------------------------
Notrump
-first trick 40 80 160
-subsequent tricks 30 60 120
Major suits 30 60 120
Minor suits 20 40 80
Overtrick points:
Overtrick points are awarded for the tricks made, more than the contract (result
> 0
)
Points per trick
Suit vulnerable not vulnerable
If undoubled:
Notrump 30 30
Major suits 30 30
Minor suits 20 20
Doubled (per trick) 200 100
Redoubled (per trick) 400 200
Slam bonus
If a large contract is made, it earns a slam bonus:
tricks = 6
earns a bonus of500
if not vulnerable, and750
if vulnerabletricks = 7
earns a bonus of1000
if not vulnerable, and1500
if vulnerable
Doubled or redoubled bonus
If a doubled or redoubled contract is made, a bonus is earned:
50
points for a doubled contract100
points for a redoubled contract
Game bonus
A game bonus is awarded based on the contract points.
- Contract points below
100
earns a bonus of50
points. - Contract points
>= 100
earns a bonus of300
if not vulnerable, and500
if vulnerable
Penalty
Each undertrick (negative result
) gives a penalty point.
No points are ganied for the contract, as it was failed.
Points per undertrick
vulnerable not vulnerable
undoubled doubled redoubled undoubled doubled redoubled
1st undertrick 100 200 400 100 100 200
2nd and 3rd, each 100 300 600 100 200 400
4th and subsequent 100 300 600 100 300 600
Examples:
Deal result: 4DX +1
, Vulnerable=true
:
- Contract points =
4*40 = 160
- Overtrick points =
1*200 = 200
- Slam bonus = no bonus
- (re)doubled bonus =
50
- Game bonus =
500
(140>=100
and vulnerable)
Result = 160+200+50+500 =
910
Deal result: 6NTXX 0
, Vulnerable=false
:
- Contract points =
4*40 = 160
- Overtrick points =
1*200 = 200
- Slam bonus = no bonus
- (re)doubled bonus =
50
- Game bonus =
500
(140>=100
and vulnerable)
Result = 160+200+50+500 =
910
Deal result: 4SX -3
, Vulnerable=false
:
- Penalty =
1*100 + 2*200 = 500
Result = -500
Deal result: 7SNTXX -13
, Vulnerable=true
:
- Penalty =
1*400 + 2*600 + 10*600 = 7600
Result = -7600
Example Input/Output:
Input is guaranteed to be valid.
1S 0 (non-vul) # => 80
3NT +1 (non-vul) # => 430
3NT +1 (vul) # => 630
6CX +1 (vul) # => 1740
4D -1 (vul) # => -100
7NTXX -13 (vul) # => -7600
Results can be checked against these tables.
I've also included a TIO with all results hardcoded in python, to check against.
@PeterTaylor It is duplicate. I've edited that in, and updated the testcase – TFeld – 2018-08-04T06:56:21.710