3D Chess 2K18

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
Einar Saukas
Manic Miner
Posts: 633
Joined: Wed Nov 15, 2017 2:48 pm

Re: 3D Chess 2K18

Post by Einar Saukas » Fri Mar 15, 2019 12:43 pm

arkannoyed wrote:
Thu Mar 14, 2019 4:25 pm
Mmmmmm....Hovering is a bit too slow to be practical;

Image
This is my favorite. Except the selected piece should be moving higher above the board to make it more visible.
0 x

User avatar
arkannoyed
Microbot
Posts: 196
Joined: Mon Feb 05, 2018 9:56 am

Re: 3D Chess 2K18

Post by arkannoyed » Fri Mar 15, 2019 12:54 pm

I agree Einar, this is the effect I find the easiest to spot whats going on, and actually the one I first came up with some time ago. Achieving it isn't difficult either. The piece can go up to 12 lines higher than standard, whereas in this demo, its only 4 lines.

Although I had said earlier that I've deliberately not looked at other Chess games to not be influenced in any direction, thats no longer true, as I have been playing a few to get a feel of how it needs to run to be comfortable.

Raised pieces is common and perfectly ok. Also, colouring or shading the square or available squares to move to is mostly how its done, which is what I have working currently.

Something I'm working on at the moment is what to use the spare upper 4 bits available in each of the squares in the board data.

So far;
Currently selected piece
Pawn has its first move available still
King in Check

Can't think of anything else at the mo, but I'm sure there are further possibilities.
0 x

User avatar
arkannoyed
Microbot
Posts: 196
Joined: Mon Feb 05, 2018 9:56 am

Re: 3D Chess 2K18

Post by arkannoyed » Mon Mar 18, 2019 4:52 pm

I've just realised that I must be an idiot!

I just spotted the most ridiculous sequence of instructions and saved a byte without any effort at all. Got the main thing down to 493 bytes now.

Work and experiments are still progressing on the game version.

I now have some rudimentary move options displayed. i.e. which squares the selected piece can move to. Surprisingly easy actually. All to do with offsets!
0 x

User avatar
arkannoyed
Microbot
Posts: 196
Joined: Mon Feb 05, 2018 9:56 am

Re: 3D Chess 2K18

Post by arkannoyed » Fri Mar 22, 2019 1:00 pm

I thought this bit might be tricky!

I've (almost) got the piece movement logic working and its 91 bytes, which actually doesn't feel too heavy.

Only 46 bytes of movement vector data tables, which are quite repetitive, so may well get smaller yet.

The piece selected then has all of its available squares that it can move to shaded, which can be scrolled through to select which move to perform, or select the piece and cancel that move.

The maths involved in checking which moves are legal is mostly quite easy, but from a few HUGE irritations.

So far En Passant and promotion aren't integrated, but should be quite simple to add. The initial state of the Pawns with their extra move availability works, but will interfere in other areas, so I need to alter that still.

Castling, maybe. Not sure on that one yet.

It is starting to take shape finally.
0 x

User avatar
Pegaz
Microbot
Posts: 188
Joined: Mon Nov 13, 2017 1:44 pm

Re: 3D Chess 2K18

Post by Pegaz » Sat Mar 23, 2019 9:03 am

Yesterday I came across this great chess program ChesSkelet, some tribute to the famous zx81 1K chess, but even smaller in just 377 bytes!
The program doesnt support some of chess rules (castling, stalemates, repetitions draw) but is generally quite functional.
I think it can be useful as a reference for creating a "3D Chess 2K18" chess engine.
Alex Garcia has developed a program on the ZX-Spin emulator, assembly code is available as well as online emulation.
I also think that the program should be added to the ZXDB database, as another very valuable new title.

http://chesskelet.x10host.com/
1 x

User avatar
arkannoyed
Microbot
Posts: 196
Joined: Mon Feb 05, 2018 9:56 am

Re: 3D Chess 2K18

Post by arkannoyed » Mon Mar 25, 2019 9:44 am

This is absolute Dynamite!!!

Great explanations for how it was conceived and programmed, and enough detail about how it works for me to be reasonable happy that amazingly, many of the concepts and game mechanics I've coded so far are very close to his.

I'm astounded that I came to exactly the same conclusion regarding the off board testing, where there is a standard mechanism called 0x88 which checks if a square lies within the board boundaries. Without any online searching I came up with the same thing, but because of the alignment of my board, it won't work fully. I check top/ bottom and sideways moves with 0x48 and then there are 2 further checks for diagonal moves.

If I could adapt my board layout to be 128 byte, then perhaps this might be useful in other areas too.

The movement vectors and distances are almost the same as I came up with too. It's nice to know i'm on the right track!
1 x

User avatar
Pegaz
Microbot
Posts: 188
Joined: Mon Nov 13, 2017 1:44 pm

Re: 3D Chess 2K18

Post by Pegaz » Mon Mar 25, 2019 10:05 am

Great, I'm really glad, to hear that.
I found it quite accidentally, I simply didnt believe it was possible to make a functional chess program in only 377 bytes.
The first thing I thought was that with this or similar engine, you can comfortably complete your chess within 1K.
0 x

User avatar
arkannoyed
Microbot
Posts: 196
Joined: Mon Feb 05, 2018 9:56 am

Re: 3D Chess 2K18

Post by arkannoyed » Mon Mar 25, 2019 10:29 am

It does miss a lot of functionality in 377 bytes, but its been written well enough to allow extra features to be fairly easily added.

Although I've only read through the code briefly, I can already see a few areas where some little improvements could be made to the size based upon the way I've achieved the same thing. But its written in a very careful way to align 2 x 256 aligned pieces of code so that switching between them works correctly. Any changes would probably break that.

I've managed to make my original display routine read through and display a 128 byte left aligned board with the addition of only 6 bytes so far, which isn't too bad. Using that layout might assist with many calculations later on.
0 x

User avatar
arkannoyed
Microbot
Posts: 196
Joined: Mon Feb 05, 2018 9:56 am

Re: 3D Chess 2K18

Post by arkannoyed » Mon Mar 25, 2019 11:23 am

One thing that puzzles me though is the reason for his numbering of the pieces, though that could be to do with their relative values in the game.

Pawn = 01
Knight = 02
Bishop = 03
Castle = 04
Queen = 05
King = 06

3D Chess 2k18 numbers as follows;

Pawn = 01
Castle = 02
Knight = 03
Bishop = 04
Queen = 05
King = 06

I guess it has to be a scoring thing.
0 x

User avatar
arkannoyed
Microbot
Posts: 196
Joined: Mon Feb 05, 2018 9:56 am

Re: 3D Chess 2K18

Post by arkannoyed » Mon Mar 25, 2019 3:15 pm

the extended board architecture is now working with the addition of just +5 bytes to the original routine.

Reading, and checking the board and move legality just got a lot easier, so 5 bytes added there will hopefully save many more elsewhere.
0 x

Post Reply