
ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes - sohkamyung
http://chesskelet.x10host.com/
======
reeagbo
Hi! the author here. I really dig your comments, including the criticisms. I
see some people even looking at the code. My current intention is to work on
it a bit more. The version online is not the final one yet.

First thing: maximum respect for earlier implementations, especially 70s and
80s ones, which seem to me much more difficult to complete with the resources
of that time. And for 1K programs like Toledo's, I´m fully aware it would
smash my code, but I´m not trying to do something playing well, you ave tons
of good playing programs.

If you allow me, let me give you my opinion on the "full set of rules"
discussion. First of all, let me warn you that none of the 1K implementations
fulfills a full set of rules, be it Nanochess or any other. Long term draw
situations, some stale mates and others require much more development.

This said, probably the discussion is: how much can we trim the rules and
still call it chess? My pieces are letters and the board is dots! That
discards my program before moving any piece. Now, I agree that missing
castling is a bad one and I intend to add it to the "full" version later on.
The funny thing about castling is that I only need to allow the human side to
do it. With such small AI on the computer side, it would never know when it
shall use it. For the other rules most people can live without en-passant or
under-promotions for this type of informal playing.

You still think it cannot be called chess? Well, I respect it but other people
are not so worried about FIDE compliance and enjoy moving letters versus a 300
byte program.

Also, I already got feedback that allowed my to reduce code by 12 bytes, so if
anybody feels like digging into the assembly I'm sure it can be shrunk a bit.

Alex

------
flurr
Playing either of two the minimal versions, the following moves produce a
crash (yielding the "C - Nonsense in BASIC" only supposed to happen during a
checkmate).

(deterministic responses from computer in []s)

    
    
      1. e2e4 [e7e6]
      2. e4e5 [d8h4]
      3. g2g3 [h4d4]
      4. c2c3 [d4e5]
      5. d2d4 [CRASH]
    

(v 0.703)

~~~
kosmickanga
The minimal versions don't check human move validity (see the "Read before
playing" section), and d2d4 is illegal as white is in check.

------
tcbawo
This is very cool. I've been playing Nanochess since it popped up on HN
([http://www.nanochess.org/chess.html](http://www.nanochess.org/chess.html)).
He has a similarly sized and restricted version, but remarkably includes the
full rule set and competitive AI in a 1k Javacript package.

------
aj7
Not chess if no en passant, castling, etc. It’s a prototype that’s
demonstrated when the programmer realizes the “exceptions” double the code
length, or aren’t worth it because he’s not a chess player.

~~~
sago
These 'minimal chess' programs trace their lineage (and mostly their rules)
back to ZX Chess [0] for the ZX81, which was a significant accomplishment, and
remains notable in the history of personal computing, cropping up from time to
time in lists of the greatest program ever written. It says this at the top of
the page.

It is not a naive prototype. I'd be very surprised if the programmer couldn't
play chess. It's a part of computing history. And the competition to reduce
the number of bytes is > 35 years old.

[0]
[https://en.wikipedia.org/wiki/1K_ZX_Chess](https://en.wikipedia.org/wiki/1K_ZX_Chess)

------
guru_meditation
Moved white queen in front of black (computer) king under the cover of the
white knight. Computer went ahead and captured my queen using its king.

Was tempted to capture the king with my knight, closed browser window instead
:)

------
comnetxr
I played a short game; I captured black's queen on black's back row with my
queen, in which the black king could have taken my queen or moved out of
check. Instead, black moved a different piece (invalid given that it is in
check). So I captured black's king...

------
imglorp
Side question about this site: Does anyone know why the FF back button (Alt
left arrow) and Page-up/down is disabled and why this would be desirable?

~~~
shakna
Seems to be a consequence of JSSpeccy, the Spectrum emulator embedded into the
site. Perhaps to let the emulator grab those sorts of shortcuts for any hosted
program.

------
benj111
Re "C - Nonsense in BASIC"

This isn't a Basic program, does it just use that string to save embedding
text, or does it actually use Basic for some things?

~~~
sago
The machine doesn't have error messages for machine code. And it would be a
waste of space to code a graceful endgame state. In the larger version it
changes border colour and reinitialises the board. In the smaller version, it
just blows the call stack (edit: with an unexpected return value), and that is
interpreted by the machine (which has no clue whether it's running BASIC or
not) as the error given.

~~~
benj111
Ok interesting thanks, so Basic's error handling was basically the machines
error handling. The spectrum had more of a (what would you call it? Bios?)
than I thought. I didn't think there would be anything to catch and display an
error, I assumed it would be more a case of just resetting. I suppose it shows
just how built around Basic the spectrum was.

~~~
sago
> (what would you call it? Bios?)

I stumbled over what to call it too.

I should add I have only basic experience in both ZX machines. I was a kid at
the time and just learning, so my memory may be dubious. But yes that's
basically my understanding.

~~~
avian
> I stumbled over what to call it too.

People at the time just called it "ROM or "ROM routines". There's the BASIC
interpreter, but there's also a lot of useful functions you can call from
assembly (like the ROM tape loader for example).

> it just blows the call stack

It seems to me this is an unintended side effect. The game code is entered
using USR, which is the BASIC expression to call into assembly code [1]. A
normal "ret" opcode should just return to the prompt, but apparently the game
messes up some internal BASIC interpreter state, which results in this error
upon return.

[1]
[http://www.worldofspectrum.org/ZXBasicManual/zxmanchap26.htm...](http://www.worldofspectrum.org/ZXBasicManual/zxmanchap26.html)

