You're right.
Oscar Toledo did chess in 352 bytes of x86 machine codes,
MicroChess, first 'commercial' program ran on unexpanded KIM-1,
so it's possible.
How to implement negamax search + eval using unsigned integers only?
Moderator: Ras
-
- Posts: 775
- Joined: Sat Sep 08, 2018 5:37 pm
- Location: Ukraine
- Full name: Maksim Korzh
Re: How to implement negamax search + eval using unsigned integers only?
Didactic chess engines:
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
-
- Posts: 28353
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: How to implement negamax search + eval using unsigned integers only?
Yes, it is possible. But the question is whether it would still be possible if you start bloating the code by using unnatural representation of integers.
-
- Posts: 2696
- Joined: Tue Aug 30, 2016 8:19 pm
- Full name: Rasmus Althoff
Re: How to implement negamax search + eval using unsigned integers only?
You could use dec 128 as your logical 0 value (i.e. draw score is 128). Anything below 128 corresponds to negative values in conventional engines, anything above 128 to positive ones.maksimKorzh wrote: ↑Sat Jun 04, 2022 2:17 pmCan anyone please gimme a clue on how can I alter my code so that it relies only on 8-bit unsigned type integers?
Rasmus Althoff
https://www.ct800.net
https://www.ct800.net
-
- Posts: 16
- Joined: Sat Dec 12, 2020 5:29 am
- Full name: Ben Bradley
Re: How to implement negamax search + eval using unsigned integers only?
I recall that the source for Microchess is available online. Regardless, I still have an original printed manual with the source listing. Despite my knowledge of 6502 back then, I certainly didn't understand a lot of the Microchess code, but I do recall a thing or two.maksimKorzh wrote: ↑Sun Jun 05, 2022 4:48 pm You're right.
Oscar Toledo did chess in 352 bytes of x86 machine codes,
MicroChess, first 'commercial' program ran on unexpanded KIM-1,
so it's possible.
One thing Microchess does is use a piece table (32 bytes, each giving the position of a piece) instead of a board array (which would take 64 bytes). This makes the code slower, harder to understand, and probably other bad things, but at least it runs on a KIM-1.
And I agree with others, 2's complement signed numbers are the natural signed type for the 6502, and using 1's complement (which to my knowledge is no longer used in any modern processors) would be a pain and bloat the code. I can only presume a C compiler for the 6502 uses types and condition codes properly.
-
- Posts: 775
- Joined: Sat Sep 08, 2018 5:37 pm
- Location: Ukraine
- Full name: Maksim Korzh
Re: How to implement negamax search + eval using unsigned integers only?
Thank you, I have Microchess listing, it's a real treasure)benb wrote: ↑Tue Jun 07, 2022 10:01 pmI recall that the source for Microchess is available online. Regardless, I still have an original printed manual with the source listing. Despite my knowledge of 6502 back then, I certainly didn't understand a lot of the Microchess code, but I do recall a thing or two.maksimKorzh wrote: ↑Sun Jun 05, 2022 4:48 pm You're right.
Oscar Toledo did chess in 352 bytes of x86 machine codes,
MicroChess, first 'commercial' program ran on unexpanded KIM-1,
so it's possible.
One thing Microchess does is use a piece table (32 bytes, each giving the position of a piece) instead of a board array (which would take 64 bytes). This makes the code slower, harder to understand, and probably other bad things, but at least it runs on a KIM-1.
And I agree with others, 2's complement signed numbers are the natural signed type for the 6502, and using 1's complement (which to my knowledge is no longer used in any modern processors) would be a pain and bloat the code. I can only presume a C compiler for the 6502 uses types and condition codes properly.
Didactic chess engines:
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
-
- Posts: 775
- Joined: Sat Sep 08, 2018 5:37 pm
- Location: Ukraine
- Full name: Maksim Korzh
Re: How to implement negamax search + eval using unsigned integers only?
Mr. Muller, I've manages to implement it using signed integers, there's a hack for signed comparison in 6502.
Work is still in progress but it definitely would be under 1k of 6502 machine codes + data (data takes most of the zero page)
Currently it searches at depth 2 and comes up with absolutely the same moves as my C prototype!
Fantastic! I'm so happy!
It's not yet available for public testing (it will be soon)
for now I can offer a video demo of how it works:
and the source code (not finished yet):
https://github.com/maksimKorzh/6502-che ... /chess.asm
I know this is not something that would impress you and my 6502 is really ugly,
however I hope you'll enjoy how your MicroMax core is translated into 6502)
Please let me know what you think!
Didactic chess engines:
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ