Page 3 of 4

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Thu Jun 06, 2019 11:26 am
by arkannoyed
Just wondering if it needs to be the case in this routine that you don't apply the result into L directly as opposed to C then L. Does it need to be saved into C for use elsewhere, as I can't find it.

Code: Select all

celloo				; prepare x88 check (7B)
				ld a, d		; delta loaded
				add a, c	; current target (sq. + delta)
				ld c, a		; current target [does the result need to go into C?]
				and $88		; 0x88, famous OOB trick
				jr nz, vecnex	; ---v exit: OOB, next vector
			
				; read target square (3B)
				inc h		; H(L)= $80 = boasth ++
				ld l, c		; point at target square [could the result of ld a,d, add a,c go straight into L?]		
				ld a, (hl)	; read target square content

				; mark attacked ### str. pawn marked attacked
					inc h		; H(L)= $81 = boaath ++
					ld (hl), h	; mark attacked ($81)
					dec h		; H(L)= $80 = boasth ++
					
				dec h		; H(L)= $79= movlih ++
Might be missing something though, as is often the case. :?

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Thu Jun 06, 2019 2:59 pm
by reeagbo
arkannoyed wrote: Thu Jun 06, 2019 11:26 am Just wondering if it needs to be the case in this routine that you don't apply the result into L directly as opposed to C then L. Does it need to be saved into C for use elsewhere, as I can't find it.

Code: Select all

celloo				; prepare x88 check (7B)
				ld a, d		; delta loaded
				add a, c	; current target (sq. + delta)
				ld c, a		; current target [does the result need to go into C?]
				and $88		; 0x88, famous OOB trick
				jr nz, vecnex	; ---v exit: OOB, next vector
			
				; read target square (3B)
				inc h		; H(L)= $80 = boasth ++
				ld l, c		; point at target square [could the result of ld a,d, add a,c go straight into L?]		
				ld a, (hl)	; read target square content

				; mark attacked ### str. pawn marked attacked
					inc h		; H(L)= $81 = boaath ++
					ld (hl), h	; mark attacked ($81)
					dec h		; H(L)= $80 = boasth ++
					
				dec h		; H(L)= $79= movlih ++
Might be missing something though, as is often the case. :?
Very good one. I had a quick glance and it seems like we could save a byte there. As you say we could (in theory) use L directly instead of C. Let me test it and I´ll get back early next week. We would need to start changing thing ever before, from celloo tag and on.

Alex

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Thu Jun 06, 2019 3:20 pm
by arkannoyed
Do you have any projection yet as to what sort of size its going to be down to now? Sub 350 bytes?

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Thu Jun 06, 2019 8:37 pm
by reeagbo
arkannoyed wrote: Thu Jun 06, 2019 3:20 pm Do you have any projection yet as to what sort of size its going to be down to now? Sub 350 bytes?
Best case would be 351,but I need to verify this last change. "genmov" is very sensitive to changes. It took me ages to make it work.

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Sat Jun 08, 2019 7:09 am
by hitm4n
Do it gently and it'll slide in...

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Tue Jun 11, 2019 9:01 am
by reeagbo
reeagbo wrote: Thu Jun 06, 2019 2:59 pm
arkannoyed wrote: Thu Jun 06, 2019 11:26 am Just wondering if it needs to be the case in this routine that you don't apply the result into L directly as opposed to C then L. Does it need to be saved into C for use elsewhere, as I can't find it.

Code: Select all

celloo				; prepare x88 check (7B)
				ld a, d		; delta loaded
				add a, c	; current target (sq. + delta)
				ld c, a		; current target [does the result need to go into C?]
				and $88		; 0x88, famous OOB trick
				jr nz, vecnex	; ---v exit: OOB, next vector
			
				; read target square (3B)
				inc h		; H(L)= $80 = boasth ++
				ld l, c		; point at target square [could the result of ld a,d, add a,c go straight into L?]		
				ld a, (hl)	; read target square content

				; mark attacked ### str. pawn marked attacked
					inc h		; H(L)= $81 = boaath ++
					ld (hl), h	; mark attacked ($81)
					dec h		; H(L)= $80 = boasth ++
					
				dec h		; H(L)= $79= movlih ++
Might be missing something though, as is often the case. :?
Very good one. I had a quick glance and it seems like we could save a byte there. As you say we could (in theory) use L directly instead of C. Let me test it and I´ll get back early next week. We would need to start changing thing ever before, from celloo tag and on.

Alex
Hi,

I was looking into your proposition, and unfortunately it won't fly. C is used to store the target square and it's used later:

Code: Select all

				; add candidate (B: current square, C: target square) (9B)
					push hl
					ld hl, canlis	; HL: start of candidate list. No H reuse ++
					inc (hl)	; +2 to candidate counter to move to next
					inc (hl)	; first free position in list
					ld l, (hl)	; point at free position
	
					ld (hl), b	; 1) save origin square
					inc hl		; move to next byte
					ld (hl), c	; 2) save dest square					
legend					pop hl		; recover HL=pointer to vector list
As you can see it's not possible to use L instead, as L is already used down here. I thought of using DE, but DE is not an option to replace HL, since some of the instructions do not exist. :-( Thanks for trying anyway. It looked very good.

Alex

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Tue Jun 11, 2019 9:46 am
by arkannoyed
Back to the Drawing Board eh? Never mind. When everything is so tightly stressed, you have to explore even the most abstract concepts to try and achieve a smaller size. Obsessing over saving even one byte becomes the norm.

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Thu Jun 13, 2019 7:07 pm
by reeagbo
After some lazy days, I've managed to put together all the dissection entries and create a single article with the whole thing, revised and cleaned up a bit. Those who need to get depressed, look here:
http://chesskelet.x10host.com/dissection.html

It's like a 50 page word document for a bunch of bytes. It can't get more ridiculous.

I was watching this documentary on how AlphaGo was developed and managed to beat the World Champion. It reminds me so much of what we do here that thought "I have to post this":
https://www.netflix.com/title/80190844

:lol: :lol: :lol: :lol:

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Fri Jun 14, 2019 8:38 am
by arkannoyed
The lengthy write up is actually much easier to read than what you posted on here, mostly I think because the code snippets are clearer to read. Having it all in one go is much nicer to read. Thanks for the mention too! ;)

Really good read.

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Sat Jun 15, 2019 10:19 am
by reeagbo
ChesSkelet v0.811 released. 352 bytes for the smallest version!

All details in http://chesskelet.x10host.com/

Have a good weekend.
Alex

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Thu Dec 05, 2019 8:12 am
by reeagbo
Hi all,

I know it's kind of unorthodox, but I need to contact Arkannoyed and he's not responding private messages or tweets. Anybody who know any other way to contact him?

Thank you!
Alex

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Thu Dec 05, 2019 10:30 am
by Ast A. Moore
Life’s complicated. We’ve had plenty of people in the community going off the grid for a while. I don’t have any of his contacts, but it won’t hurt tagging him in a post like so: [mention]arkannoyed[/mention].

Who knows what his forum settings are; maybe he doesn’t receive notifications for private messages but does when he’s mentioned directly.

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Thu Dec 05, 2019 6:42 pm
by arkannoyed
Ello?!

Sorry, seems I’ve been very uncommunicative of late. Been busy with new job and don’t get time to do what I love with speccy things any more. I’m at your service Sir! :)

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Fri Jan 03, 2020 10:09 am
by Alone Coder
Any chance to port this to Spectrum? https://habr.com/ru/post/478240/
https://github.com/leanchess/leanchess/ ... ter/LC.ASM
It searches moves in depth.

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Thu Apr 16, 2020 7:19 pm
by reeagbo
Hi Alone Coder,

Arriving like 4 months late. Sorry, I´ve been away for a while. Ok, I know about Leanchess, and it did not occur to me the idea of porting it to Spectrum. That would be a super piece of work. Leanchess is made for 8086 and that is really a great advantage vs. Spectrum program. THe guy who did it really took the best of both worlds.It´s 8 bits, which is perfect for microchess, but the instruction set is way bigger than the Z80's. Imagine, there is one instruction to push all registers to the stack. How many instructions takes to do that in Z80? 8 minimum.

Part of the porting may not be so difficult, but I´m sure that some segments need many more instructions than in the 8086. Also,I don´t feel like getting into the guts of this other program. If you know someone who takes this, let me know.

Alex

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Thu Apr 16, 2020 7:20 pm
by reeagbo
Aonther thing,

I moved my site to

http://chesskelet.epizy.com/

in case someone feels like having a look. No changes or new contents for now.

Alex

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Thu Apr 16, 2020 7:26 pm
by Lethargeek
reeagbo wrote: Thu Apr 16, 2020 7:19 pm Imagine, there is one instruction to push all registers to the stack. How many instructions takes to do that in Z80? 8 minimum.
OTOH the Z80 has more 8-bit registers and an instruction to swap 3 pairs with alternatives so it won't probably need to push that much

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Thu Apr 16, 2020 11:24 pm
by reeagbo
Right! You could have helped me with my program! Anyway, I meant bytes.

With chesskelet it happened to me that I had all regular registers occupied, so I had no chance but pushing some, so the work, and popping then later,so this kind of thing would have saved mute from some headaches.

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Tue Feb 27, 2024 3:36 pm
by Supamax
The main links are not reachable anymore:

http://chesskelet.x10host.com/
http://chesskelet.epizy.com/

The last release I have is v0.811.
Is there a newer one?
Is it possible to have a .tap file of it, instead of a .sna? :)

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Wed Feb 28, 2024 2:21 am
by Wall_Axe
So the a.i. only compares one move. Considering you have about 42,000 bytes left you could implement min max algorithm :) to make it really hard - lol

Out of interest how long does it take to load 350 bytes from tape?

I suppose you could put code in the screen memory as most of the screen is unused, therefore not using any more actual ram :) lol

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Wed Feb 28, 2024 2:42 am
by ParadigmShifter
Was about 11 seconds or so for me to save a 363 byte block of random data. Most of that was the 2 lead ins and the header. Attribs are 768 bytes so less than half the time for that probably. (0s take longer to load than 1s which is weird since the 1s - being more pointy - must get stuck in the wires more when loading, the 0s being round can just roll down them?).

You don't need to use a lot of memory for minimax many 80s chess computers only had 4 or 8K of RAM. You can backtrack moves instead of storing them and if you know the order moves are generated in you can just use an index for the best move so far.

Negamax uses even less code memory

function negamax(node, depth, color) is
if depth = 0 or node is a terminal node then
return color × the heuristic value of node
value := −∞
for each child of node do
value := max(value, −negamax(child, depth − 1, −color))
return value

I think the idea is to make a chess game using as few bytes as possible in the machine code payload though so you just do the least thing to get it working. Nothing stopping them from using all the available RAM though - probably not needed for the above reasons. So implementing a proper search for decent moves is probably too large for their liking. I think the aim is to outdo the 1K ZX81 chess program for nerdiness ;)

Modern chess engines use megabytes of memory on hash tables of course to make searches quicker.

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Wed Feb 28, 2024 2:56 am
by Wall_Axe
That's cool, the attributes take about three seconds to load so it must load so quickly :)

The 0's might have to push themselves down the wires

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Wed Feb 28, 2024 3:04 am
by ParadigmShifter
Surely they make the wire wide enough for a 0 not to get jammed. It's bends and kinks in the wire that makes the 1s get stuck. That's like electronics 101

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Wed Feb 28, 2024 7:16 am
by uglifruit
ParadigmShifter wrote: Wed Feb 28, 2024 3:04 am That's like electronics 101
A.k.a. Electronics 5.

Re: ChesSkelet: micro chess program - 363 Bytes

Posted: Wed Feb 28, 2024 9:04 am
by arkannoyed
Wall_Axe wrote: Wed Feb 28, 2024 2:21 am I suppose you could put code in the screen memory as most of the screen is unused, therefore not using any more actual ram :) lol
I did exactly that in an experimental version of c2k19.
I’ll see if I can find it, though I think it’s probably here on an old thread.
It ran from the screen with ATTRs just concealing its location around the boards surroundings.