Many years ago, hmmm, I think it around 1979, I wrote a basic program that
could deal bridge hands with constraints.  The idea was that you were
looking at a known hand, so let's say your partner opens 1 spade and you
are bidding 5 card majors.  I would take the cards you were looking at,
take them out of the deck, then it would generate hands where your partner
either had at least 13 points or 2 1/2 quick tricks, and 5 spades from the
remaining cards.  I used some of the optimistic revaluation stuff, like I
counted voids, singletons, doubletons, and honors in Trump.

I would generate hands and then run them through a filter, discarding hands
that didn't meet my criteria, keeping that up.  My code ran on a 370/165 or
maybe a 370/168.  I moved it to an IBM 4341 running VM but it is now lost.


Of course this was before the internet was widely available outside of
large colleges. A friend of mine who was an admin at Stanford demoed it to
me, but I had no way to connect and if I had I would have known nothing
about a repository.  So all this code is lost.

I like this....but writing an evaluator given your deck representation
might not be easy.  I used base 13 and kept the representation as numbers,
only converting to the printable representation in the final stage.

It was interesting.  How many hands out of 50 would make game or even slam
given what you knew?

What if you had more than one bid or even seen overcall?  Now you need to
constrain the other hands.  I recall one hand in duplicate in a small
tournament where my partner opened 2d (which indicated 5 hearts and 4
spades and 13-16 points) we had a complicated system of rebids, and I
determined that we could possibly make 6 spades through a crossruff and
running hearts.

We made it on a squeeze...and it turned out that everyone else was in
hearts, making 5.  Simply selecting spades and making 6 was enough for a
top board.

But then I questioned what really I should have bid based on what I knew.
So I created a filter that forced partners hand into the described shape
and point count (between opener and reverse), tossed the remaining cards
randomly.  It took a while but I got 50 hands, and my bid was right 85 or
90 percent of the time, presuming perfect play.  Occasional voids allowing
for an opening ruff and such defeated the slam.

The card dealing program starts to be interesting but it is more
interesting if you can add filters and so forth.

And just as a note, I ran multiple random stages, starting from an ordered
deck.  The theory is that from an ordered deck it takes 3 shuffles to get a
random bridge hand and the old rng stuff seemed to roll doubles too often,
so I presumed that it would select non-randomly. I have no idea if it is
needed here.  The deal function should be random enough and initial deck
order should not matter.

Also, I was a systems programmer at an insurance company so, I had a lot of
the machine available and, while I think that my current cellphone has more
power than the old mainframe, I could chug through thousands of hands
looking for ones that met all my constraints.  Now I think I would have
partial deal stages to put some cards into hands as needed to meet some of
the constraints, and then I would assign the rest of the cards, and I would
finally run the hands through the evaluator.

Like suppose the situation is that the opening lead is made, dummy comes
down and you are planning the play.  Now you have perfect knowledge of two
hands plus one card and the others are random, or if there has been bidding
you might constrain them a bit.

It was valuable to me.  Finesses are supposedly 50-50, but how does this
work with constrained hands?  Can a squeeze be executed? Hope often is that
the right play?

Anyway, this is just food for thought, since we have been complicating your
original simple and elegant program...and, thinking about design, I can see
a system where you start with a deck, and assign some cards to hands, then
randomly distribute the rest until hands are full.  Would save quite a bit
of filtering at the back end.

On Oct 27, 2018 23:08, "Linda Alvord" <lindaalvor...@outlook.com> wrote:

Ooops.  This lost an  "1

bridge=: 13 :'<"2(\:~"1(|.x)$?~*/x){y'


Linda

-----Original Message-----
From: Programming <programming-boun...@forums.jsoftware.com> On Behalf Of
Linda Alvord
Sent: Saturday, October 27, 2018 10:25 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Shuffle and deal 4 bridge hands

Sdince I still can't start a new thread, if you answer this, please chane
th subject to:
"bridge to poker"

This will deal 3 cards to six players:

S=:13#u: 9827 9830 9829 9824
   F=:52$'23456789TJQKA'
   deck=:S,.F

   bridge=: 13 :'<"2(\:~(|.x)$?~*/x){y'

   3 6 bridge deck
┌──┬──┬──┬──┬──┬──┐
│♦2│♣A│♣J│♣9│♣6│♣4│
│♣T│♦3│♣7│♣8│♦5│♣3│
│♣K│♦4│♣5│♣2│♣Q│♦6│
└──┴──┴──┴──┴──┴──┘

However in poker, the cafds have different values.
Since I don't know much about poker, I'm throwing in my hand.

Linda



-----Original Message-----
From: Programming <programming-boun...@forums.jsoftware.com> On Behalf Of
Linda Alvord
Sent: Friday, October 26, 2018 11:18 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Shuffle and deal 4 bridge hands



Here's the simplest I can get thisL:   S=:13#u: 9827 9830 9829 9824
   F=:52$'23456789TJQKA'
   deck=:S,.F

   13 4 bridge deck
┌──┬──┬──┬──┐
│♠J│♠A│♠9│♠3│
│♠8│♠K│♠5│♥A│
│♠7│♠Q│♥4│♥K│
│♠6│♠T│♥2│♥Q│
│♠4│♠2│♦A│♥J│
│♥6│♥3│♦Q│♥T│
│♥5│♦5│♦J│♥9│
│♦K│♣Q│♦9│♥8│
│♦7│♣T│♦4│♥7│
│♦3│♣9│♣K│♦T│
│♦2│♣8│♣6│♦8│
│♣A│♣5│♣4│♦6│
│♣J│♣2│♣3│♣7│
└──┴──┴──┴──┘
   bridge
[: <"2 ] {~ [: \:~"1 ([: |. [) $ [: ?~ [: */ [

   ;:'[: <"2 ] {~ [: \:~"1 ([: |. [) $ [: ?~ [: */ ['
┌──┬─┬─┬─┬─┬─┬─┬──┬──┬─┬─┬─┬─┬──┬──┬─┬─┬─┬──┬─┬─┬──┬─┬─┬─┐
│[:│<│"│2│]│{│~│[:│\:│~│"│1│(│[:│|.│[│)│$│[:│?│~│[:│*│/│[│
└──┴─┴─┴─┴─┴─┴─┴──┴──┴─┴─┴─┴─┴──┴──┴─┴─┴─┴──┴─┴─┴──┴─┴─┴─┘


Read the "words" from right to left to right to see how [: helps you tell
monadic verbs from dyadic ones.  Also note the impact of  /  and  ~  on the
meaning of the verb to its left.

Linda

-----Original Message-----
From: Programming <programming-boun...@forums.jsoftware.com> On Behalf Of
'Mike Day' via Programming
Sent: Monday, October 15, 2018 11:27 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Shuffle and deal 4 bridge hands

!52 is the number of all possible deck shuffles.

The sort-order of a bridge hand as dealt is immaterial to the player.

(!52)%*/4#!13 is 53644737765488792839237440000, which, as you mention,

is the cited number of different deals ignoring ordering within each hand.

Both results are correct in their different ways!

M



On 15/10/2018 16:06, Linda Alvord wrote:
>   Bridge ppage:
>
>
>
> 53,644,737,765,488,792,839,237,440,000 to unique bridge deals.
>
>     J :
>
> !52
> 8.06582e67
>
>
> Not much agreement.
>
> Linda
>
>
>
>
>     ,
> Sent from my Verizon, Samsung Galaxy smartphone
> -------- Original message --------
> From: 'Mike Day' via Programming <programm...@jsoftware.com>
> Date: 10/14/18 1:45 PM (GMT-05:00)
> To: programm...@jsoftware.com
> Subject: Re: [Jprogramming] Shuffle and deal 4 bridge hands
>
> Sorry - getting rather chatty,  not much J - your deck, Linda, has
> faces increasing within decreasing suits,  given that Bridge has the
> ordering spade > heart > diamond > club , so your shuffle produces
> suits in the "wrong" order.
> So redefining deck as (say):
>      [suits =: |. u: 9824 9829 9830 9827 NB. increasing ♣♦♥♠
> faces =: '23456789TJQKA'   NB. increasing
> |:each (5&{.;_5&{.) deck =:,/suits,"0/faces NB. all increasing
> ┌─────┬─────┐
> │♣♣♣♣♣│♠♠♠♠♠│
> │23456│TJQKA│
> └─────┴─────┘
>
> NB. for a set of Whist hands: (actually done here with ?. rather than ?)
>       7 (]<"2 @: {~ \:~"1 @: ((4 , [) ($ ? ~@:#) ])) deck
> ┌──┬──┬──┬──┐ │♥A│♠K│♠A│♠T│ │♥T│♠4│♠Q│♠5│ │♥2│♦5│♠8│♥J│ │♦T│♦4│♠6│♦9│
> │♣Q│♦2│♥K│♦8│ │♣3│♣A│♥7│♣K│ │♣2│♣T│♦J│♣6│ └──┴──┴──┴──┘
>
> Use lh arg of 13 for Bridge Hands.
>
> The down-sort is now intuitive, and we don't need to reverse each
> column
>
> Cheers,
>
> Mike
>
> On 14/10/2018 16:27, 'Mike Day' via Programming wrote:
>> Sorry for previous - pressed Send instead of Edit!
>>
>> Thanks, Linda
>>
>> No problems under Windows 10 in JQt 807.
>>
>> I'm no good at Bridge, but might be persuaded to play whist!
>>
>> If we want to choose Whist or Bridge,  we need to specify the
>>
>> size of a hand.  In either case, you can use draw from the row-count
>>
>> of deck rather than the product of x.
>>
>> This consideration and some other slight changes lead to:
>>
>>     shuffle =: 13 : '<@|."2 y{~ /:~"1 x$&|. ?~#y'
>>
>> SO, for a game of Whist:
>>
>>     7 4 shuffle deck
>> ┌──┬──┬──┬──┐
>> │♣8│♦7│♣6│♦A│
>> │♣2│♥6│♦Q│♦K│
>> │♦J│♥5│♦6│♦T│
>> │♦9│♥4│♥T│♥A│
>> │♦8│♥3│♥7│♥2│
>> │♥8│♠Q│♠J│♠K│
>> │♠4│♠9│♠3│♠8│
>> └──┴──┴──┴──┘
>>
>> OR - can't we assume 4 suits? -
>>     7 (13 :'<@|."2 y{~ /:~"1 (4,x)$ ?~#y') deck ┌──┬──┬──┬──┐
>> │♣A│♦K│♣Q│♣J│ │♣6│♦5│♣2│♣8│ │♦Q│♥K│♦A│♣7│ │♦T│♥Q│♦7│♣3│ │♥A│♥8│♥7│♦J│
>> │♥2│♥3│♥5│♥6│ │♠7│♠2│♠5│♠Q│ └──┴──┴──┴──┘
>>
>> Cheers,
>> Mike
>>
>> On 14/10/2018 00:47, Linda Alvord wrote:
>>> This should now work in most J environments.
>>>
>>> F=:52$'23456789TJQKA'
>>> S=:13#u: 9824 9829 9830 9827
>>> deck=:S,.F
>>> shuf=: 13 :'<"2|."2 y {~ /:~"1 (|.x)$?~*/|.x
>>>
>>> Save code above in a file and then run the script.
>>> Here's how it looks in android.
>>>
>>> 13 4 shuf deck
>>> ┌──┬──┬──┬──┐
>>> │♣A│♣J│♣K│♣9│
>>> │♣Q│♣6│♣T│♣3│
>>> │♦K│♣5│♣8│♦A│
>>> │♦T│♣4│♣7│♦J│
>>> │♦9│♣2│♦Q│♦8│
>>> │♦6│♦2│♦7│♥K│
>>> │♥A│♥Q│♦5│♥6│
>>> │♥T│♥J│♦4│♥3│
>>> │♥8│♥9│♦3│♠A│
>>> │♥7│♥4│♠Q│♠K│
>>> │♥5│♥2│♠T│♠9│
>>> │♠8│♠J│♠7│♠6│
>>> │♠5│♠2│♠3│♠4│
>>> └──┴──┴──┴──┘
>>>
>>> Linda
>>>
>>> Sent from my Verizon, Samsung Galaxy smartphone
>>> --------------------------------------------------------------------
>>> -- For information about J forums see
>>> https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww
>>> .jsoftware.com%2Fforums.htm&amp;data=02%7C01%7C%7Ce8f992fdd9964b471a
>>> bc08d632b2aa00%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C63675214
>>> 0271106545&amp;sdata=l9T9k5TfBMaf5WY8whn0VlQcGq4wbbPCwS%2Fv0%2FZkliM
>>> %3D&amp;reserved=0
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.
> avast.com%2Fantivirus&amp;data=02%7C01%7C%7Ce8f992fdd9964b471abc08d632
> b2aa00%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636752140271106545
> &amp;sdata=tCcJS4FCriXzsSK%2FdxWD3gAm1CtYnkAvLWBwRrw65eo%3D&amp;reserv
> ed=0
> ----------------------------------------------------------------------
> For information about J forums see
> https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.j
> software.com%2Fforums.htm&amp;data=02%7C01%7C%7Ce8f992fdd9964b471abc08
> d632b2aa00%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C63675214027110
> 6545&amp;sdata=l9T9k5TfBMaf5WY8whn0VlQcGq4wbbPCwS%2Fv0%2FZkliM%3D&amp;
> reserved=0
> ----------------------------------------------------------------------
> For information about J forums see
> https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.j
> software.com%2Fforums.htm&amp;data=02%7C01%7C%7Ce8f992fdd9964b471abc08
> d632b2aa00%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C63675214027110
> 6545&amp;sdata=l9T9k5TfBMaf5WY8whn0VlQcGq4wbbPCwS%2Fv0%2FZkliM%3D&amp;
> reserved=0



---
This email has been checked for viruses by Avast antivirus software.
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Feur04.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fwww.avast.com%252Fantivirus%26amp%3Bdata%3D02%257C01%257C%257C32155b8825724db7d13608d63b563695%257C84df9e7fe9f640afb435aaaaaaaaaaaa%257C1%257C0%257C636761638808517041%26amp%3Bsdata%3DizLg6frOcz%252BfdFGDc2EeNWaCA6GXjmKiBkyj%252BfBivqg%253D%26amp%3Breserved%3D0&amp;data=02%7C01%7C%7C62e63b5529024812cf1c08d63c7c859c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636762902841601909&amp;sdata=cH9DGmM0HG%2FtxXxcsdP%2Fp4sfbpSkJU1aXaIwkPYFZzA%3D&amp;reserved=0
----------------------------------------------------------------------
For information about J forums see
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Feur04.safelinks.protection.outlook.com%2F%3Furl%3Dhttp%253A%252F%252Fwww.jsoftware.com%252Fforums.htm%26amp%3Bdata%3D02%257C01%257C%257C32155b8825724db7d13608d63b563695%257C84df9e7fe9f640afb435aaaaaaaaaaaa%257C1%257C0%257C636761638808517041%26amp%3Bsdata%3Dnh6FprZ9fvrAOHEoqEDTHgrkIEAcEz0YztPPyGkQmz8%253D%26amp%3Breserved%3D0&amp;data=02%7C01%7C%7C62e63b5529024812cf1c08d63c7c859c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636762902841601909&amp;sdata=VyRn4CDPAECMVXMbRdmsdfFLV%2BJUrptshIwPye92LaM%3D&amp;reserved=0
----------------------------------------------------------------------
For information about J forums see
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Feur04.safelinks.protection.outlook.com%2F%3Furl%3Dhttp%253A%252F%252Fwww.jsoftware.com%252Fforums.htm%26amp%3Bdata%3D02%257C01%257C%257C32155b8825724db7d13608d63b563695%257C84df9e7fe9f640afb435aaaaaaaaaaaa%257C1%257C0%257C636761638808517041%26amp%3Bsdata%3Dnh6FprZ9fvrAOHEoqEDTHgrkIEAcEz0YztPPyGkQmz8%253D%26amp%3Breserved%3D0&amp;data=02%7C01%7C%7C62e63b5529024812cf1c08d63c7c859c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636762902841601909&amp;sdata=VyRn4CDPAECMVXMbRdmsdfFLV%2BJUrptshIwPye92LaM%3D&amp;reserved=0
----------------------------------------------------------------------
For information about J forums see
https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&amp;data=02%7C01%7C%7C62e63b5529024812cf1c08d63c7c859c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636762902841601909&amp;sdata=gopbZrIEpI8PiP4%2F4b2KQFMfZONadqLZTp%2Foh4w8%2Bto%3D&amp;reserved=0

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to