Page 7 of 14

Re: 3D Chess 2K18

Posted: Thu Mar 14, 2019 3:27 pm
by arkannoyed
Yeah, the arrow was just a proof of concept actually. It can go bigger, and even inside a box. I'm actually not that keen on this method, and prefer the raised pieces, which is a much clearer indication of the piece selected.

With an extra bit of code twiddling, the piece could give the appearance of hovering, gradually moving up/ down whilst the square target selection is in progress. Just needs a simple sine type table to cycle through to change the height offset.

That way, it'll always appear active. Visually, movement always helps identify whats going on.

Both methods actually take about the same amount of extra code to achieve.

Re: 3D Chess 2K18

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

Image

Re: 3D Chess 2K18

Posted: Thu Mar 14, 2019 4:42 pm
by ZXDunny
How about a 50% dither to mask everything except the piece you're selecting?

Re: 3D Chess 2K18

Posted: Thu Mar 14, 2019 4:47 pm
by arkannoyed
Thats a lot of dithering!

That would interfere with the automasking probably too much, causing all sorts of out of place pixels and weird artifacts to appear.

I did try some basic piece masking to dither the selected piece, but that looks a bit odd too.

I'll try and re-create that and show you.

Re: 3D Chess 2K18

Posted: Thu Mar 14, 2019 4:58 pm
by arkannoyed
In fact, there are so many ways that it could be done, but as always, the final decision will probably have to be based upon which is easiest and smallest to integrate into the system.

A few more ideas;

skip printing alternate lines of the piece, or swap upon each update of the frame to give a fuzzy sort of effect.
Alternately skip printing the piece altogether every other frame to make it flash.

Re: 3D Chess 2K18

Posted: Fri Mar 15, 2019 9:35 am
by arkannoyed
This test really does fit nicely into the code, adding the fewest number of bytes so far.

The alternating line effect is possible by repeatedly calling the routine, or to save even more space just a static version can be achieved, much faster and using fewer bytes.

Image

Static version;

Image

Re: 3D Chess 2K18

Posted: Fri Mar 15, 2019 9:50 am
by Pegaz
It still seems to me, that the arrow method is the most appropriate here.
We can discuss, how the arrow will look and how big will be, but I would keep that method.
btw, would it also be possible to make moves, by typing anotation eg. c2-c4 on keyboard?
Even the simplest chess programs can be used in this way...

Re: 3D Chess 2K18

Posted: Fri Mar 15, 2019 9:59 am
by arkannoyed
Pegaz wrote: Fri Mar 15, 2019 9:50 am It still seems to me, that the arrow method is the most appropriate here.
We can discuss, how the arrow will look and how big will be, but I would keep that method.
btw, would it also be possible to make moves, by typing anotation eg. c2-c4 on keyboard?
Even the simplest chess programs can be used in this way...
That method might be a consideration, but a modern implementation should surely take the graphical approach if possible?

I've not so far investigated this route, however, aside from using the ROM routine to read the keyboard, surely it would and up a little heavy on extra code?

Remember that the aim is to achieve something fitting into 1024 bytes.

Re: 3D Chess 2K18

Posted: Fri Mar 15, 2019 11:22 am
by redballoon
arkannoyed wrote: Fri Mar 15, 2019 9:35 am Image

Static version;

Image
I like the effect, but it renders the piece unreadable if there is anything behind it. Out of the options tested, I reckon the arrow is still the best possibility...however, i think an effect on the selected piece would be the best option likecwhat you’re trying with the alternate lines. Course, what that is, I’m not quite sure yet! ;)

Re: 3D Chess 2K18

Posted: Fri Mar 15, 2019 12:12 pm
by arkannoyed
The effect is one of those quick and easy things to implement, that if it works is a great bonus. If push came to shove and it had to stay because of the size restrictions, then it wouldn't be so bad.

The Arrow is ok, but might add over +40 bytes in the end, as there are quite a few alterations needed to make it work properly. I'm still keen on altering the piece somehow though.

If speedier building was possible, then it opens up further possibilities to make all kinds of things work.

Re: 3D Chess 2K18

Posted: Fri Mar 15, 2019 12:43 pm
by Einar Saukas
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.

Re: 3D Chess 2K18

Posted: Fri Mar 15, 2019 12:54 pm
by arkannoyed
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.

Re: 3D Chess 2K18

Posted: Mon Mar 18, 2019 4:52 pm
by arkannoyed
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!

Re: 3D Chess 2K18

Posted: Fri Mar 22, 2019 1:00 pm
by arkannoyed
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.

Re: 3D Chess 2K18

Posted: Sat Mar 23, 2019 9:03 am
by Pegaz
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/

Re: 3D Chess 2K18

Posted: Mon Mar 25, 2019 9:44 am
by arkannoyed
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!

Re: 3D Chess 2K18

Posted: Mon Mar 25, 2019 10:05 am
by Pegaz
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.

Re: 3D Chess 2K18

Posted: Mon Mar 25, 2019 10:29 am
by arkannoyed
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.

Re: 3D Chess 2K18

Posted: Mon Mar 25, 2019 11:23 am
by arkannoyed
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.

Re: 3D Chess 2K18

Posted: Mon Mar 25, 2019 3:15 pm
by arkannoyed
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.

Re: 3D Chess 2K18

Posted: Tue Apr 02, 2019 3:13 pm
by arkannoyed
Its all gone a bit mad with work, so not had a huge amount of time to dedicate to this lately. A few experiments have given reasonable results and the size of the main routine has just reduced by a further -1 byte courtesy of a nifty swap from ix-hl to do some searchy stuff. Once things get past Easter I expect I'll have a little more time.

Routine now at 492 bytes

Re: 3D Chess 2K18

Posted: Tue Apr 02, 2019 4:21 pm
by Ast A. Moore
If your job interferes with your Spectrum programming, I think it’s obvious you need to quit your job. :lol:

Re: 3D Chess 2K18

Posted: Fri Apr 12, 2019 4:48 pm
by arkannoyed
Probably uninteresting to many here, and I agree that I should really be concentrating on developing the GUI and game stuff, however, I've saved a further 2 bytes on the main display code, making it now 490 bytes

I'm sure its familiar to many, that sometimes when you're staring at the same piece of code and you mind isn't in gear, its nice to escape by faffing with something else instead! :lol:

Re: 3D Chess 2K18

Posted: Fri Apr 12, 2019 5:43 pm
by Ast A. Moore
arkannoyed wrote: Fri Apr 12, 2019 4:48 pm I'm sure its familiar to many, that sometimes when you're staring at the same piece of code and you mind isn't in gear, its nice to escape by faffing with something else instead!
Absolutely. I do my best coding while smoking, cooking, pacing around the room, and running errands around town. Staring at my code for hours on end usually leads to frustration and not much progress overall.

Re: 3D Chess 2K18

Posted: Sun Apr 14, 2019 1:27 pm
by dfzx
arkannoyed wrote: Fri Apr 12, 2019 4:48 pm Probably uninteresting to many here, and I agree that I should really be concentrating on developing the GUI and game stuff, however, I've saved a further 2 bytes on the main display code, making it now 490 bytes

I'm sure its familiar to many, that sometimes when you're staring at the same piece of code and you mind isn't in gear, its nice to escape by faffing with something else instead! :lol:
I'd ask that maybe you'd add another sentence or two explaining, at a high level, what you spotted and how you optimised it. And how you spotted it, if there's a pattern or something which others might learn from.

Not that I mean to be impudent, demanding what you should tell us. :) But you're clearly an expert on optimising Z80 code, and I for one, as a beginner/intermediate level Z80 coder, could learn a huge amount from you if you'd ever care to share it.