News for hackers. Stuff that matters.
Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by reeagbo on Saturday March 30, 2019 @02:42PM (#19531006)
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

Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by flurr on Saturday March 30, 2019 @02:07AM (#19528046)
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)
Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by kosmickanga on Saturday March 30, 2019 @05:11AM (#19528547)
The minimal versions don't check human move validity (see the "Read before playing" section), and d2d4 is illegal as white is in check.
Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by tcbawo on Saturday March 30, 2019 @08:32AM (#19529079)
This is very cool. I've been playing Nanochess since it popped up on HN (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.
Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by aj7 on Saturday March 30, 2019 @06:24AM (#19528726)
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.
Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by sago on Saturday March 30, 2019 @07:40AM (#19528927)
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

Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by mrob on Saturday March 30, 2019 @07:12AM (#19528856)
En passant is rare enough that it's still more or less the same game without it, but castling is extremely common. Deciding when to castle is a major part of chess strategy, and I agree that it's not really chess without it.
Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by guru_meditation on Saturday March 30, 2019 @07:08AM (#19528841)
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 :)

Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by comnetxr on Saturday March 30, 2019 @04:19PM (#19531582)
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...
Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by imglorp on Saturday March 30, 2019 @07:24AM (#19528888)
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?
Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by shakna on Saturday March 30, 2019 @08:04AM (#19528997)
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.
Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by benj111 on Saturday March 30, 2019 @05:20AM (#19528570)
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?

Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by sago on Saturday March 30, 2019 @07:59AM (#19528986)
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.
Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by benj111 on Saturday March 30, 2019 @08:45AM (#19529133)
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.
Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by sago on Saturday March 30, 2019 @08:51AM (#19529151)
> (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.

Re:ChesSkelet: Micro Chess Game for ZX Spectrum in 365 Bytes by avian on Saturday March 30, 2019 @09:27AM (#19529286)
> 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...