[Jprogramming] chess pieces
Björn Helgason
gosinn at gmail.com
Wed Sep 10 12:24:25 HKT 2008
Why is view a showing the wrong piece?The rest are ok
2008/9/10 Oleg Kobchenko <olegykj at yahoo.com>
> You load the chess32.bmp and cut into a list of piece icons.
> It should be indexed by piece, color and square color.
> Makes sense to superimpose checkered board on pieces.
>
> Then you assemble the 8x8 board of those indices
> replacing with icons and stitch it.
>
>
>
>
> > From: Björn Helgason <gosinn at gmail.com>
> > To: Programming forum <programming at jsoftware.com>
> > Sent: Tuesday, September 9, 2008 7:56:02 PM
> > Subject: [Jprogramming] chess pieces
> >
> > I have been meaning to try out the chess pieces for a long time but never
> > got around to it until now.
> >
> > http://www.jsoftware.com/jwiki/Scripts/Chess_Generator
> > I took the cardgen script and used it as a starting point as suggested
> and
> > tested until I got the chesspieces displayed correctly.
> >
> > require 'viewmat'
> >
> > F=: readbmp jpath'~user/chess/chess32.bmp'
> > C=: ,/}:"_1 ] 0 1 2 3 4{(,:~32 31) ];.3 F
> > T=: 16ba000
> >
> > maxd =: |:@:({.@$&>) {@;&(>./) {:@$&>
> > table =: [: > [: ,&.>/ [: ,.&.>/"1 maxd {.!.T&.> ]
> > hand =: (,!.T)&.>/
> > NB. stack=: (,.~ 12&{."1)~/
> > stack=: (,.~ 1&{."1)~/
> > NB. group=: [: (<.@%&13 > group=: [: (<.@%&1 > shand =:
> empty`([: >@hand (~ group)@.(*@#)
> >
> > NB. tabmat =: 3 3 $&, a:&,.
> > tabmat =: 8 16 $&, a:&,.
> > view =: [:viewrgb [:table [:shand&.> tabmat
> > deal =: _2(<\?~)30"_
> >
> > NB. view deal''
> > a=:
> >
> 9;19;8;22;11;20;7;21;18;6;18;6;18;6;18;6;24;25;24;25;24;25;24;25;25;24;25;24;25;24;25;24;24;25;24;25;24;25;24;25;25;24;25;24;25;24;25;24;0;12;0;12;0;12;0;12;15;1;14;4;17;2;13;3
> > b=:
> >
> 9;19;8;22;11;20;7;21;18;6;18;6;18;6;18;6;24;25;24;25;24;25;24;25;25;24;25;24;25;24;25;24;24;25;24;25;24;25;24;25;25;24;25;24;25;24;25;24;0;12;0;12;0;12;0;12;15;1
> > 1;14;4;17;2;13;3
> > view a
> > view b
> >
> > ---------------------------------------
> >
> > view a gives me a wrong piece
> > It gives pawn instead of the knight
> > (piece 0 instead of piece 1)
> >
> > view b gives the knight in the right place but a green line down the
> table
> > (used 1 1 instead of 1)
> >
> > I am pretty sure this is not the best solution but it sort of works.
> >
> > Can someone please explain why view a displays the wrong piece?
>
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Björn Helgason, Verkfræðingur
Fugl&Fiskur ehf,
Þerneyjarsundi 23, Hraunborgum
Po Box 127,801 Selfoss ,
t-póst: gosinn at gmail.com
gsm: +3546985532
Landslags og skrúðgarðagerð, gröfuþjónusta
http://groups.google.com/group/J-Programming
Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
góður kennari getur stigið á tær án þess að glansinn fari af skónum
/|_ .-----------------------------------.
,' .\ / | Með léttri lund verður |
,--' _,' | Dagurinn í dag |
/ / | Enn betri en gærdagurinn |
( -. | `-----------------------------------'
| ) | (\_ _/)
(`-. '--.) (='.'=)
`. )----' (")_(")
More information about the Programming
mailing list