APL Bridge Game -
i trying code game of bridge in apl part i'm stuck on when printing hands want return 4 separate hands scored of random cards , want sort cards suit first , within suits sort ace 2 able accomplish each 1 of these sorts individually
hand←deal;char;deck deck←make_deck char←deck[;13?52] ⍝hand←char[;'shdc23456789tjqka'”³char] hand←char[;'cdhs'”³char]
sorts suit not numbers in suit , dont know how make deal 4 hands instead of 1 hand of 13 cards
example output:
q982aqt93t934 akj657428j987 k865akj54kqt3 t743jq762a652 sssshhhhhdddc ssssshhhdcccc hhhhdddddcccc sssshddddcccc
(i wasn't sure did in make_deck, maybe there special stuff going on? otherwise there no reason make dedicated function that. also, non-native english-speaker, i'm not sure naming of cards etc. - pls. fix appropriate...)
deck←(52⍴'akqj0987654'),[.5]13/'shdc'
i dealing cards , create array of indices deck;
hands←4 13⍴52?52
these need sorted row-wise. (i'm doing using "classic" style work in apl-dialects...):
x←0 x←x+1 ⋄ hands[x;]←hands[x;⍋hands[x;]] ⋄ →(x<4)/⎕lc
(pls. note line work within function, not when execute directly in interpreter - there no ⎕lc → to...) so, what's hand of player 1?
deck[;hands[1;]] jaqj08740q4k7 sshhhhhhddccc
hope can put nice function ;-)
Comments
Post a Comment