J challenge: chess in 1K characters

This is a discussion on J challenge: chess in 1K characters within the APL forums in Programming Languages category; H. G. Muller has created a modern chess program called Micro-Max in under 2000 characters of C source. http://home.hccnet.nl/h.g.muller/max-src2.html However, his original goal was such a program in under 1K of source. I figure that the terseness of J and the array and functional nature of the problem would be good fit for a J solution. Any takers?...

Go Back   Application Development Forum > Programming Languages > APL

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-02-2008, 01:54 PM
Ian Osgood
Guest
 
Default J challenge: chess in 1K characters

H. G. Muller has created a modern chess program called Micro-Max in
under 2000 characters of C source.

http://home.hccnet.nl/h.g.muller/max-src2.html

However, his original goal was such a program in under 1K of source. I
figure that the terseness of J and the array and functional nature of
the problem would be good fit for a J solution.

Any takers?
Reply With Quote
  #2  
Old 09-08-2008, 10:12 PM
kai
Guest
 
Default Re: J challenge: chess in 1K characters

> Any takers?

The restriction makes sure that the code will be unreadable. The
program might just be able to move according to the rules, but it is
certainly extremely weak.

I wonder why anybody should waste time on such a useless contest.

Kai

Reply With Quote
  #3  
Old 09-09-2008, 06:40 AM
Gosi
Guest
 
Default Re: J challenge: chess in 1K characters

On 2 Sep, 17:54, Ian Osgood <i...@quirkster.com> wrote:
> H. G. Muller has created a modern chess program called Micro-Max in
> under 2000 characters of C source.
>
> *http://home.hccnet.nl/h.g.muller/max-src2.html
>
> However, his original goal was such a program in under 1K of source. I
> figure that the terseness of J and the array and functional nature of
> the problem would be good fit for a J solution.
>
> Any takers?


To get you going then the display is available and it is good to look
at the cardgame next to it too.



---------- Forwarded message ----------
From: Oleg Kobchenko
Date: 2006/8/31


It's good for manual entry by human, though rows
are not very visible. For processing in code,
such may be considered:

P=: ' PNBRQKpnbrqk'
cmax=: [^>&(a.&i.))"0
charboard=: 1j1 #"1 (' .'{~2|+/~i.8) cmax~ ]
$BEGIN=: (,|.@toupper) ' ',~' ',~'rnbqkbnr',:'p'
8 8
charboard BEGIN NB. character display
r n b q k b n r
p p p p p p p p
. . . .
.. . . .
. . . .
.. . . .
P P P P P P P P
R N B Q K B N R


There is also a new J Wiki page for bitmap layout

http://www.jsoftware.com/jwiki/Scripts/Chess_Generator


http://www.jsoftware.com/jwiki/Scripts/Cards_Generator
Reply With Quote
  #4  
Old 09-10-2008, 05:34 AM
Stephen Taylor
Guest
 
Default Re: J challenge: chess in 1K characters

On Sep 9, 11:40*am, Gosi <gos...@gmail.com> wrote:
> On 2 Sep, 17:54, Ian Osgood <i...@quirkster.com> wrote:
>
> > H. G. Muller has created a modern chess program called Micro-Max in
> > under 2000 characters of C source.

>
> > *http://home.hccnet.nl/h.g.muller/max-src2.html

>
> > However, his original goal was such a program in under 1K of source. I
> > figure that the terseness of J and the array and functional nature of
> > the problem would be good fit for a J solution.

>
> > Any takers?

>
> To get you going then the display is available and it is good to look
> at the cardgame next to it too.
>
> ---------- Forwarded message ----------
> From: Oleg Kobchenko
> Date: 2006/8/31
>
> It's good for manual entry by human, though rows
> are not very visible. For processing in code,
> such may be considered:
>
> * P=: ' PNBRQKpnbrqk'
> * cmax=: [^>&(a.&i.))"0
> * charboard=: 1j1 #"1 (' .'{~2|+/~i.8) cmax~ ]
> * $BEGIN=: (,|.@toupper) ' ',~' ',~'rnbqkbnr',:'p'
> 8 8
> * charboard BEGIN * NB. character display
> r n b q k b n r
> p p p p p p p p
> *. * . * . * .
> . * . * . * .
> *. * . * . * .
> . * . * . * .
> P P P P P P P P
> R N B Q K B N R
>
> There is also a new J Wiki page for bitmap layout
>
> *http://www.jsoftware.com/jwiki/Scripts/Chess_Generator
>
> http://www.jsoftware.com/jwiki/Scripts/Cards_Generator


I'm soooo tempted to try it in Dyalog 12 just because (a) Unicode
means the board can be exactly represented as a 8×8 character table
that actually looks like a chessboard, and (b) APL has the advantage
of fewer diglyphs.

If only I were clever…

Stephen Taylor
editor@vector.org.uk
Reply With Quote
  #5  
Old 09-10-2008, 06:02 AM
Jan Karman
Guest
 
Default Re: J challenge: chess in 1K characters


"Stephen Taylor <editor@vector.org.uk>"
<StephenTaylorFRSA@googlemail.com> wrote in message
news:a9ee5f40-351d-4928-a25d-33c397e722cd@y38g2000hsy.googlegroups.com...
On Sep 9, 11:40 am, Gosi <gos...@gmail.com> wrote:
>> On 2 Sep, 17:54, Ian Osgood <i...@quirkster.com> wrote:
>>
>> > H. G. Muller has created a modern chess program called Micro-Max in

>

[...]
>
> I'm soooo tempted to try it in Dyalog 12 just because (a) Unicode
> means the board can be exactly represented as a 8×8 character table
> that actually looks like a chessboard, and (b) APL has the advantage
> of fewer diglyphs.


Stevan Apter's
http://www.nsl.com/papers/push.htm

please, go to the bottom ...

>
> If only I were clever…

initiating the longest thread ever !!

(completed to an epigram)






Reply With Quote
  #6  
Old 09-10-2008, 06:51 AM
Gosi
Guest
 
Default Re: J challenge: chess in 1K characters

On 9 Sep, 10:40, Gosi <gos...@gmail.com> wrote:
> On 2 Sep, 17:54, Ian Osgood <i...@quirkster.com> wrote:
>
> > H. G. Muller has created a modern chess program called Micro-Max in
> > under 2000 characters of C source.

>
> > *http://home.hccnet.nl/h.g.muller/max-src2.html

>
> > However, his original goal was such a program in under 1K of source. I
> > figure that the terseness of J and the array and functional nature of
> > the problem would be good fit for a J solution.

>
> > Any takers?

>
> To get you going then the display is available and it is good to look
> at the cardgame next to it too.
>
> ---------- Forwarded message ----------
> From: Oleg Kobchenko
> Date: 2006/8/31
>
> It's good for manual entry by human, though rows
> are not very visible. For processing in code,
> such may be considered:
>
> * P=: ' PNBRQKpnbrqk'
> * cmax=: [^>&(a.&i.))"0
> * charboard=: 1j1 #"1 (' .'{~2|+/~i.8) cmax~ ]
> * $BEGIN=: (,|.@toupper) ' ',~' ',~'rnbqkbnr',:'p'
> 8 8
> * charboard BEGIN * NB. character display
> r n b q k b n r
> p p p p p p p p
> *. * . * . * .
> . * . * . * .
> *. * . * . * .
> . * . * . * .
> P P P P P P P P
> R N B Q K B N R
>
> There is also a new J Wiki page for bitmap layout
>
> *http://www.jsoftware.com/jwiki/Scripts/Chess_Generator
>
> http://www.jsoftware.com/jwiki/Scripts/Cards_Generator


Oleg showed me how to do this and I placed the bitmap and explanations
of this on

http://groups.google.com/group/J-Pro...files?upload=1
http://groups.google.com/group/J-Pro...754301daf38da2

Reply With Quote
  #7  
Old 09-11-2008, 05:03 AM
Gosi
Guest
 
Default Re: J challenge: chess in 1K characters

On 10 Sep, 10:51, Gosi <gos...@gmail.com> wrote:
> On 9 Sep, 10:40, Gosi <gos...@gmail.com> wrote:
>
>
>
> > On 2 Sep, 17:54, Ian Osgood <i...@quirkster.com> wrote:

>
> > > H. G. Muller has created a modern chess program called Micro-Max in
> > > under 2000 characters of C source.

>
> > > *http://home.hccnet.nl/h.g.muller/max-src2.html

>
> > > However, his original goal was such a program in under 1K of source. I
> > > figure that the terseness of J and the array and functional nature of
> > > the problem would be good fit for a J solution.

>
> > > Any takers?

>
> > To get you going then the display is available and it is good to look
> > at the cardgame next to it too.

>
> > ---------- Forwarded message ----------
> > From: Oleg Kobchenko
> > Date: 2006/8/31

>
> > It's good for manual entry by human, though rows
> > are not very visible. For processing in code,
> > such may be considered:

>
> > * P=: ' PNBRQKpnbrqk'
> > * cmax=: [^>&(a.&i.))"0
> > * charboard=: 1j1 #"1 (' .'{~2|+/~i.8) cmax~ ]
> > * $BEGIN=: (,|.@toupper) ' ',~' ',~'rnbqkbnr',:'p'
> > 8 8
> > * charboard BEGIN * NB. character display
> > r n b q k b n r
> > p p p p p p p p
> > *. * . * . * .
> > . * . * . * .
> > *. * . * . * .
> > . * . * . * .
> > P P P P P P P P
> > R N B Q K B N R

>
> > There is also a new J Wiki page for bitmap layout

>
> > *http://www.jsoftware.com/jwiki/Scripts/Chess_Generator

>
> >http://www.jsoftware.com/jwiki/Scripts/Cards_Generator

>
> Oleg showed me how to do this and I placed the bitmap and explanations
> of this on
>
> http://groups.google.com/group/J-Pro...ead/thread/e97...


It is possible also to communicate with a chess engine and then
display the moves.

---------- Forwarded message ----------
From: Oleg
Date: 2007/4/5
Subject: Re: [Jprogramming] stdin/stdout
To: Programming forum <programming@jsoftware.com>


Here's my session with Arasan (latest i-taks with
minor unrelated changes for dir param).

p=. 'jtask'conew~ 'cmd /c arasanx.exe';'D:\Tools\Arasan'
write__p 'help',LF
1
wait__p 1
1459
read__p ''
Arasan 8.4 Copyright 1997-2005 by Jon Dart
Using book file book.bin
analyze: enter Winboard analyze mode
black: set computer to play Black
....

write__p 'e2e4',LF
1
wait__p 3
22
read__p ''
1. e2e4
1. ... c7c5

write__p ;,&LF each;:'Nf3 d4 Nxd4 Nc3 Be2 f4'
1
wait__p 3
124
read__p ''
2. Nf3
2. ... d7d6
3. d4
3. ... c5d4
4. Nxd4
4. ... g8f6
5. Nc3
5. ... e7e6
6. Be2
6. ... f8e7
7. f4
7. ... o-o

NB. write__p 'quit',LF
close__p''
0
wait__p 3
6
read__p ''
quit

destroy__p''

-------------------------------

I would be interested in seeing chess engines in J and others APLs

It is good fun to play chess engines against each other.

I saw a very nice chess display in Dialog using Unicode.

Arasan has become so powerful that I can not win over it anymore.
Up to version 2.1 I always won.
After 2.1 I got 8 and I could hardly ever beat it.
Version 9 and 10 I only use it to play against each other and watch
while I set one to think to fix depth 8 and the other to depth 12.
The one with depth 12 almost always wins with a rare draw.

Reply With Quote
  #8  
Old 09-11-2008, 07:22 AM
Stephen Taylor
Guest
 
Default Re: J challenge: chess in 1K characters

On Sep 10, 11:02*am, "Jan Karman" <aq...@planet.nl (remove the q's)>
wrote:
> "Stephen Taylor <edi...@vector.org.uk>"<StephenTaylorF...@googlema il.com>wrote in message
>
> news:a9ee5f40-351d-4928-a25d-33c397e722cd@y38g2000hsy.googlegroups.com...
> On Sep 9, 11:40 am, Gosi <gos...@gmail.com> wrote:
>
> >> On 2 Sep, 17:54, Ian Osgood <i...@quirkster.com> wrote:

>
> >> > H. G. Muller has created a modern chess program called Micro-Max in

>
> [...]
>
> > I'm soooo tempted to try it in Dyalog 12 just because (a) Unicode
> > means the board can be exactly represented as a 8×8 character table
> > that actually looks like a chessboard, and (b) APL has the advantage
> > of fewer diglyphs.

>
> Stevan Apter'shttp://www.nsl.com/papers/push.htm
>
> please, go to the bottom ...
>


I thought we'd published something of this in Vector. It looks like
I've been remembering Morten's conference presentations instead.
Dyalog 12 treats the Unicode wide characters as single elements of a
text array. The black and white chess pieces all have Unicode
positions. So (in his presentation he showed) a chess board can be
represented by an 8×8 character table that needs no translating to a
human-readable form.

You can see a little bit of this sort of thing on the APL Wiki, where
the Solitaire Game uses the four suit symbols for its character
displays. No looping... and no mapping either.

http://aplteam2.com/aplwiki/SolitaireGame

Stephen Taylor
editor@vector.org.uk

Reply With Quote
  #9  
Old 09-11-2008, 10:51 PM
Martin Neitzel
Guest
 
Default Re: J challenge: chess in 1K characters

Hi Kai, long time no see! And, speaking of seeing, have you
actually taken a look at C source code of the chess program?

>The restriction makes sure that the code will be unreadable.


I have to differ. The "restrictions" allow for any amount of
white space (decent code layout) + comments. I had a look at
the web pages with the code, and I consider the **extensive**
commentary on the used encodings & algorithms to be examplary
for any kind of software project.

It really _is_ a tough and interesting challenge to match the
given C code with APL or any of its dialects; it is beautiful
and well engineered C code (when seen in regard to the metric
it is aiming at, of course). We APL'ers are quite prejudiced
about having the Best Notation For Arrays Ever; nevertheless,
when I saw an array initializer in the chess program's C code
spread across three lines without any trouble I couldn't fail
to notice that even that would already be much messier in APL
or J. We would have to use either an "overlong" line for the
same vector initializer or some contraption to allow for some
line breaks within that. That really made me thinking: "Gee,
this here is a bloody simple vector initializer and APL could
not keep up with C already, be it with respect to compactness
or to readability. Could we truly catch up later while using
that array?" I was honestly perplexed by the simple fragment
of (non-tricky) C code which is difficult to parallel in APL.

It's an intriguing challenge indeed. The chess programer was
_not_ out to put C against other languages. Just to put "any
language" against a character count. Fair enough, I say, and
how much readability you can preserve, well, that's up to you
and your APL skills. Efforts to prove (or at least to check)
APL's alleged terseness would be, I have to agree, justified.
Reply With Quote
  #10  
Old 09-16-2008, 03:44 AM
kai
Guest
 
Default Re: J challenge: chess in 1K characters

On Sep 12, 3:51 am, neit...@marshlabs.gaertner.de (Martin Neitzel)
wrote:
> Hi Kai, long time no see! And, speaking of seeing, have you
> actually taken a look at C source code of the chess program?
>
> >The restriction makes sure that the code will be unreadable.

>
> I have to differ. The "restrictions" allow for any amount of
> white space (decent code layout) + comments. I had a look at
> the web pages with the code, and I consider the **extensive**
> commentary on the used encodings & algorithms to be examplary
> for any kind of software project.
>
> It really _is_ a tough and interesting challenge to match the
> given C code with APL or any of its dialects; it is beautiful
> and well engineered C code (when seen in regard to the metric
> it is aiming at, of course). We APL'ers are quite prejudiced
> about having the Best Notation For Arrays Ever; nevertheless,
> when I saw an array initializer in the chess program's C code
> spread across three lines without any trouble I couldn't fail
> to notice that even that would already be much messier in APL
> or J. We would have to use either an "overlong" line for the
> same vector initializer or some contraption to allow for some
> line breaks within that. That really made me thinking: "Gee,
> this here is a bloody simple vector initializer and APL could
> not keep up with C already, be it with respect to compactness
> or to readability. Could we truly catch up later while using
> that array?" I was honestly perplexed by the simple fragment
> of (non-tricky) C code which is difficult to parallel in APL.
>
> It's an intriguing challenge indeed. The chess programer was
> _not_ out to put C against other languages. Just to put "any
> language" against a character count. Fair enough, I say, and
> how much readability you can preserve, well, that's up to you
> and your APL skills. Efforts to prove (or at least to check)
> APL's alleged terseness would be, I have to agree, justified.


Hello Martin,

good to hear from you.

However beautiful the C code might be, that still does not attract me.
And the goal does not either. I am looking at any kind of C code only
if I am enforced to do so anyway, really

That the resulting program can hardly be of any use in terms of
actually *playing* chess still holds true.

Surely there are more interesting things to do to kill your time.
Nothing stops you from producing beautifully designed APL code on such
a goal.

Kai
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 10:54 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.