Here's something to start with. I haven't tested it thoroughly.
NB. score bridge
NB. x is contract level suit vul dbl
NB. suit is 0=C, 4=NT
NB. dbl is 0, 1, or 2
NB. y is result, neg=down, nonneg=number of overtricks
NB. result is score for contracting side
NB. Does not support honors
bridgescore =: 4 : 0"1 0
'level suit vul dbl' =. x
if. y < 0 do.
if. dbl do.
dbl * 100 + (y * 300) - 100 * ((y * -.vul) >. _2)
else.
y * vul { 50 100
end.
else.
odd =. (2^dbl) * (10 0 * suit=4) + (level,y) * suit { 2 3 # 20 30
pts =. (dbl * 50) + {. odd
if. 100 <: {. odd do. pts =. pts + vul { 300 500 end.
pts =. pts + (<vul,level) { _8 {."1 ] 500 1000 ,: 750 1500
pts =. pts + dbl { ({:odd) , (>:vul) * y * 100 200
end.
)
5 1 1 2 bridgescore _8 NB. The biggest number I ever collected
_4600
2 3 1 1 bridgescore 0 NB. 2S sawed, making, vul
670
Henry Rich
Brian Schott wrote:
> There have been discussions in the forums regarding
> bridge dealing and at least one on counting the high card
> points of individual dealt hands, but I have not found any
> discussion of scoring contract bridge. Has anyone done this
> and is willing to share? In addition to the scoring itself,
> I would like ideas for designing an interactive user
> interface that would allow the score to be revised, for
> example when someone remembers that the first hand was
> doubled, after the second hand has been played.
>
> I guess I am caught up in the lust for an ipad.
>
> Thanks,
>
> --
>
> (B=)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm