3D Chess 2K18

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
ZXDunny
Manic Miner
Posts: 498
Joined: Tue Nov 14, 2017 3:45 pm

Re: 3D Chess 2K18

Post by ZXDunny »

llewelyn wrote: Fri May 03, 2019 3:14 pm Hey Dunny? Please excuse my probable idiocy but why did you say zack4mac's comment about the state of PC software was idiotic?

I'm constantly annoyed by bloatware. The difference in functionality versus size came up yesterday when I went looking for an RTF to HTML conversion utility. Some of them were several megs in size, the one I eventually chose was around 700k and works just fine (not sure if I got that size right but there was a huge difference between the various examples)
There is a prevailing view that PC software is becoming bloated which, although true to an extent, is not as due to poor programming as you might think. Spectrums use 1Bpp graphics, beeper or AY code to produce sound etc - none of which is really viable on a PC as things are these days. 32Bpp graphics, high resolution textures, intricate control routines for moveable objects (such as enemies etc) and enormous, detailed level designs not to mention the fact the nearly everything is now 3D accounts for most of the bloat in games these days.

Poor programming (or at least a poor choice of tools) does have an impact - your RTF->HTML converters could probably done in raw C in just a couple of Kb - if you don't want to handle things like Unicode, and only a small subset of the RTF standard for example. Add to this that the author might be using a scripted language with included runtime libraries embedded means that you quickly bloat to MBs. Of course a 32bit architecture may mean a 4x bloat in code size alone, double that for 64bit possibly. So 700Kb is considered a pretty light application nowadays.

As a quick example, take my own SpecBAS. The executable is 16MB in size! But that's including the interpreter, the editor, all the runtime code for the myriad routines you might or might use. And then there's debug information. Without the debug info, it's 5MB. And it ain't gonna be any smaller. Why? Despite looking retro, SpecBAS runs 32bpp graphics with alpha blending and is not hardware accelerated aside from actually getting the graphics on the screen. The default font is 64KB as opposed to the same font occupying 767 bytes on the Speccy - the font is 32bit. There's masses of tables used to get things done quicker than you could on a Speccy. And of course, it's a win32/64 executable built with a modern compiler so there's runtime support libs built-in.

I'd love to get things down to less than a meg, but it's not gonna happen. And never will anymore, aside from demo coding contests where really small stuff can be built but is useless for anything other than showing off an effect.

I might have been a tad insulting back there, but you tend to get really tired of these people that can't code on modern platforms complaining that all their bytes have gone missing and you could do so much more with 16Kb back then.

Now back to your scheduled chess shenanigans.
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: 3D Chess 2K18

Post by Einar Saukas »

On another subject...

The classic 1K Chess by David Horne was never intended to be the SMALLEST POSSIBLE chess. It was the opposite. The author was trying to PUT AS MUCH CONTENT AS POSSIBLE (full chess rules, good AI, etc) within the memory limitations of the original 1K ZX81.

David Horne wasn't saving bytes to make his program smaller. He was doing it so he could have enough room to improve AI logic, for instance.

Nowadays there are several even smaller chess programs (I mentioned a few here at the time). They are all certainly impressive, but their AI is typically so bad they are not fun to play.

Your 3D chess will never be smaller than those existing 2D versions anyway. Therefore I see no point in just adding a simplistic AI to the code you already have. Instead, I suggest your goal should be achieving the BEST POSSIBLE chess game in exactly 1K. Which means supporting 100% of chess rules, and the smartest possible AI you can fit.

It seems both chesSkelet and David Horne's 1K chess play better than others. I would first play a few rounds between them to compare AIs, then use the best players as starting point to implement yours...
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

I agree regarding the 1k issue. I’ve exactly 513 bytes left to play with and intend using them all. Even when it gets to the point where it works well, if it’s left any spare space then I’ll unroll some of the key routines to get better speed. Some interesting tests were performed yesterday to try different methods of updating the display. Moving forwards from the tiny version, the game variant will require the board to be built in a buffer at C000h and then copied to the screen. This will give more fluid animation. I used block clear and copy routines that just update the 2 squares that are being swapped (piece moved from to etc). This gave much better results than straight full buffer copy and actually wasn’t much bigger to do. Once all of the shared routines are removed from the main display code then I think the result should still achieve good speed. Doesn’t sound fast but 2 frames per second is achievable. After all, Chess isn’t generally considered to be a fast game! Once these routines are all in, then I’ll re-integrate some of the GUI elements and optimise them.
DarkTrancer

Re: 3D Chess 2K18

Post by DarkTrancer »

Been reading your posts since the beginning because i found the optimisation interesting,did not understand it all but did enjoy reading.
Can't wait for a release so can play it and appreciate it. 8-)
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

One day, and hopefully it’ll live up to expectations!

As I’ve said before, if any aspect of the system or the mechanics of it is of particular interest and you want to know more, just ask. I’m always happy to expand upon anything. A good example is that when I posted the breakdown of the source here, I then spotted a few improvements. Sometimes examining or explaining a system in more detail bears fruit!
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

Some movement, in realtime;

Image

I like the way it speeds up when there are fewer pieces on the board, like Space Invaders! :D

This isn't speed optimised in terms of the copy routines. Interestingly, because the original builds straight to the screen, and contention plays its part, building to a buffer, then copying to the screen hardly adds any extra time at all!

This is using a combined copy and clear routine thats fairly efficient. It copies a byte of the buffer to the screen and then writes a '00' to the buffer for when the board is build next.

Using the optimised block copy/clear routines is bigger and more complex, and actually not much faster. If space allows, this method could be unrolled to increase the speed a little more. Currently only uses 38 bytes.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

In case anyones interested, below is the flexible Copy/ Clear routine. By just altering the number of LDD/ LD (BC),A instructions to fill a sensible amount of free space, the routine has the ability to speed up if there are free bytes still available. Nothing complicated. BC trails one byte behind whats being copied from the buffer to the screen, so it can be cleared afterwards.

Code: Select all

copy_clear:
           xor a
           ld de,57ffh
           ld hl,0d7ffh
           ld bc,0d800h
cc_lp:
           ldd
           ld (bc),a
           ldd
           ld (bc),a
           ldd
           ld (bc),a
           ldd
           ld (bc),a
           bit 6,h
           jr nz,cc_lp
           ret
Could be anywhere from 18 bytes up to a whopping 18447, which there would still be room for if I allowed buffering besides the screen too. I have some code that builds it to whatever length you choose, and thats only 27 bytes.
Last edited by arkannoyed on Wed May 08, 2019 10:15 am, edited 1 time in total.
User avatar
djnzx48
Manic Miner
Posts: 729
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: 3D Chess 2K18

Post by djnzx48 »

Oh nice, that's pretty clever. Great way to make use of the normally useless BC register during LDI/LDD copies.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

I know, the BC register just gets wasted in most cases. Nice to make it work for a change. I actually tried the routine fully unrolled to 18k and its quite fast!
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

Well I guess I must've been inspired by Liverpools epic comeback last night. I have just saved a further...

7 bytes

Making my little beauty just 505 bytes!

Thats a 1.37% saving :lol:

Actually I spotted a stupid repetition and a way of sharing a byte in the graphics data. I can't recall saving a full 7 bytes in one go for a very long time :)

No graphics changes in appearance whatsoever. I guess that now brings it perilously close to another milestone of 500 bytes, though it might as well be 100 bytes away, as I don't know where I can save any more. I do find myself uttering those very words far too often though, and proving myself wrong again and again!

Graphics data is now just 210 bytes!
Last edited by arkannoyed on Wed May 08, 2019 11:57 am, edited 1 time in total.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

Oh hang on, no, my mistake, can't count what with all the excitement!

504 bytes!
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

Bit cheaty, but by swapping the order of some of the graphics data I can use the first byte of it as the jump vector at the end of the main routine, thus saving another byte.

503 bytes
d2010
Dizzy
Posts: 79
Joined: Tue Mar 26, 2019 9:19 am

Re: 3D Chess 2K18

Post by d2010 »

arkannoyed wrote: Tue May 07, 2019 4:08 pm Some movement, in realtime;
Image
I need replace the board 2colors from black-white to texture-white.
If i enter poke 53484,255[enter] the board will be colored into white+black.
If i enter poke 53484,170[enter] the board will be colored into white+gray(bin1010101).
Can you give me, address of poke and value?(at means cheats code)
:x :?:
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

I don't exactly understand, however, are you asking if it is possible to have White/ Grey board instead of White/ Black? If so, yes, it could be re-written to do that, as that is part of the functionality of the Graphical User Interface. That will not be as simple as just poking one address to a different value unfortunately. The square plotting routine has to be re-written.

Is it because you want to make some weird video of it? :)
d2010
Dizzy
Posts: 79
Joined: Tue Mar 26, 2019 9:19 am

Re: 3D Chess 2K18

Post by d2010 »

arkannoyed wrote: Thu May 09, 2019 1:27 pm Is it because you want to make some weird video of it? :)
Yes, i cannot ~different between board_black_color and black_pieces(turn, queen,king).
Last edited by d2010 on Thu May 09, 2019 3:12 pm, edited 2 times in total.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

When I've integrated the GUI, you should be able to just set BIT 7 of all the board squares and when you build it, they will all be grey, ok?
d2010
Dizzy
Posts: 79
Joined: Tue Mar 26, 2019 9:19 am

Re: 3D Chess 2K18

Post by d2010 »

arkannoyed wrote: Thu May 09, 2019 2:51 pm When I've integrated the GUI, you should be able to just set BIT 7 of all the board squares and when you build it, they will all be grey, ok?
Yes,yes **
I do not need exactly grey-color, I need any texture (BIN 101001010), or (BIn 1100110011) of board-color-black.
The texture is mix 11--00-pixels inside the byte...i replay to you at PM.
First Step you. make easiest tasks , send to private message... :|
Second Task,only if you can make texture-board-game.
then you inject :!: hard-task.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

d2010 wrote: Thu May 09, 2019 3:20 pm
arkannoyed wrote: Thu May 09, 2019 2:51 pm When I've integrated the GUI, you should be able to just set BIT 7 of all the board squares and when you build it, they will all be grey, ok?
Yes,yes **
I do not need exactly grey-color, I need any texture (BIN 101001010), or (BIn 1100110011) of board-color-black.
The texture is mix 11--00-pixels inside the byte...i replay to you at PM.
First Step you. make easiest tasks , send to private message... :|
Second Task,only if you can make texture-board-game.
then you inject :!: hard-task.
......anyone? :?
User avatar
Pegaz
Dynamite Dan
Posts: 1209
Joined: Mon Nov 13, 2017 1:44 pm

Re: 3D Chess 2K18

Post by Pegaz »

Maybe I'm wrong, but I think he wants any kind of checkered pattern, instead of solid black fields on board.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

I just about got that much, but all this talk of Cheats and pokes! This is a highly tuned piece of procedural graphics work, that doesn't poke well! :D

Shaded squares will be available further down the line. More testing and experiments are being conducted at the moment, along with saving more bytes from the core.
reeagbo
Dizzy
Posts: 61
Joined: Mon Apr 29, 2019 9:11 am

Re: 3D Chess 2K18

Post by reeagbo »

Einar Saukas wrote: Fri May 03, 2019 12:51 pm
arkannoyed wrote: Fri May 03, 2019 12:20 pm A DEFB is all ok from an assembler point of view for a one off game, but to copy 32 bytes of data and clearing the board would still be bigger. As its going to be replayable, it needs a board reset routine.
I know.

I was suggesting DEFB for chesSkelet only, since it doesn't clear the board and it's not replayable.
Yes, that's the case for Chesskelet: DEFB board setup. With my routine, I was trying to give some ideas, but Arkannoyed has something at least as small as that routine.
reeagbo
Dizzy
Posts: 61
Joined: Mon Apr 29, 2019 9:11 am

Re: 3D Chess 2K18

Post by reeagbo »

Einar Saukas wrote: Fri May 03, 2019 5:38 pm On another subject...

The classic 1K Chess by David Horne was never intended to be the SMALLEST POSSIBLE chess. It was the opposite. The author was trying to PUT AS MUCH CONTENT AS POSSIBLE (full chess rules, good AI, etc) within the memory limitations of the original 1K ZX81.

David Horne wasn't saving bytes to make his program smaller. He was doing it so he could have enough room to improve AI logic, for instance.

Nowadays there are several even smaller chess programs (I mentioned a few here at the time). They are all certainly impressive, but their AI is typically so bad they are not fun to play.

Your 3D chess will never be smaller than those existing 2D versions anyway. Therefore I see no point in just adding a simplistic AI to the code you already have. Instead, I suggest your goal should be achieving the BEST POSSIBLE chess game in exactly 1K. Which means supporting 100% of chess rules, and the smartest possible AI you can fit.

It seems both chesSkelet and David Horne's 1K chess play better than others. I would first play a few rounds between them to compare AIs, then use the best players as starting point to implement yours...
That would be super-lovely. I totally respect 1K Chess. If anyone sees my chesSkelet website you can read that I think it's nearly impossible what he did with the 80's infra. Now, with emulators and all we can run programs 100 times per hour and see. I can't imagine how much time it would have taken for me to do chesSkelet in such conditions.

If you need any input from me to run those games, let me know.
User avatar
ZXDunny
Manic Miner
Posts: 498
Joined: Tue Nov 14, 2017 3:45 pm

Re: 3D Chess 2K18

Post by ZXDunny »

d2010 wrote: Thu May 09, 2019 3:20 pm
arkannoyed wrote: Thu May 09, 2019 2:51 pm When I've integrated the GUI, you should be able to just set BIT 7 of all the board squares and when you build it, they will all be grey, ok?
Yes,yes **
I do not need exactly grey-color, I need any texture (BIN 101001010), or (BIn 1100110011) of board-color-black.
The texture is mix 11--00-pixels inside the byte...i replay to you at PM.
First Step you. make easiest tasks , send to private message... :|
Second Task,only if you can make texture-board-game.
then you inject :!: hard-task.
You are Roger Jowett AICMFP.
User avatar
Pegaz
Dynamite Dan
Posts: 1209
Joined: Mon Nov 13, 2017 1:44 pm

Re: 3D Chess 2K18

Post by Pegaz »

I thought the same for a moment when I saw his wierd video for the first time, but I still wanted to hope. ;)
At some point he had to come here, it was simply inevitable...
It's important that arkannoyed focuses on real challenges, not on gray board fields. :)
Later, when everything is done, he can do the SamCoupe port, especially for Roger. ;)
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

@d2010, is this what you wanted?

Image
Post Reply