This script generates a deck of cards as a graphical bitmap suitable for visualizing card layouts. The deck contains 52 cards, a joker, two coats and a blank.

cards28x40.png

Features

The bitmap file

You need to have the bmp file before using the cards in other utilities.

The easiest way is to download the bitmap from here

You can create a bitmap from the generator as shown below, however the image on this page was generated with system font configuration to ensure best quality.

f_run ''    NB. show the generated cards in a form
f_save ''   NB. save to user/cards/cards28x40.bmp

Bridge

Here is an example of using the generated cards to lay out a table of bridge.

bridge1.png

Generated with view deal'' from the script below.

require 'viewmat'

F=: readbmp jpath'~user/cards/cards28x40.bmp'
C=: ,/}:"_1 ] 0 3 2 1{(,:~40 28) ];.3 F
T=: 16ba000

    maxd =: |:@:({.@$&>) {@;&(>./) {:@$&>
  table  =: [: > [: ,&.>/ [: ,.&.>/"1 maxd {.!.T&.> ]
    hand =: (,!.T)&.>/
    stack=: (,.~ 12&{."1)~/
    group=: [: (<.@%&13 </. ]) /:~ 
  shand  =: empty`([: >@hand (<C) stack@:{&.>~ group)@.(*@#)
  tabmat =: 3 3 $&, a:&,.
view     =: [:viewrgb [:table [:shand&.> tabmat
deal     =: _13(<\?~)52"_


Contributed by OlegKobchenko


CategoryGames

Scripts/Cards Generator (last edited 2009-09-11 08:54:08 by OlegKobchenko)