cc65-Chess for Oric by [raxiss]

Want to talks about games you like, would like to see developed on the Oric, it's here.
User avatar
iss
Wing Commander
Posts: 1641
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

cc65-Chess for Oric by [raxiss]

Post by iss »

Hello all! I'm very happy to present you our new release - cc65-Chess for Oric!
The game is compatible with Oric-1/Atmos/Pravetz-8D/Telestrat and comes in TAP format for easier usage.
title-2.png
title-2.png (27.36 KiB) Viewed 8612 times
game-3.png
game-3.png (37.05 KiB) Viewed 8612 times

The story: everything started from a message (comp.sys.apple2).
In 2014 Stefan Wessels created cc65-Chess for the C64. It was completely written in C using cc65.
The game and UI logic are separated from the actual board and UI rendering which allows easy porting across 8-bit platforms.
In January 2020 Oliver Schmidt ported cc65-Chess to the Apple II and this helped a lot to have in May 2020 the Oric port ready!

Oric related source code is freshly merged and can be found in the main github-repository. Compiled TAP file is available here.

Controls: arrows - move cursor, RETURN - pick/place, ESC or 'M' - menu, 'A' - show/hide attackers, 'D' - show/hide defenders.

Well, and because the port was really easy and fun, I decide to make a full finished game release! Enjoy it!

raxiss 2020/05
Attachments
cc65-Chess-raxiss-1.00.tap.zip
(20.71 KiB) Downloaded 321 times
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: cc65-Chess for Oric by [raxiss]

Post by Dbug »

Question: Does the game uses a lot of memory for the AI? I was wondering if that would help to auto-detect the presence of a disk controller to use the upper 16k of ram for additional search tree capabilities?

EDIT: I made it my Oric software Tweet of the day https://twitter.com/DefenceForceOrg/sta ... 8682178560
User avatar
jbperin
Flight Lieutenant
Posts: 480
Joined: Wed Nov 06, 2019 11:00 am
Location: Valence, France

Re: cc65-Chess for Oric by [raxiss]

Post by jbperin »

The intro is great !! It says that the pulp fiction music comes from a midi file .. I long to see how you managed to play a midi file on an Oric.

The level at chess is poor as it could be exepcted from a 8 bits machine but the rules of the games seem to be properly implemented (as far as i could see).

At first I foundd that the keyboard handling was making the games allmost unplayable . But in fact I had not understand that when we select a piece with space, it considers that we are trying to move the piece at the same place (so it writes in red) and then we can select the destination for this piece.
Here's where I am at the moment in my first game at level very hard:
good position with white at very hard level
good position with white at very hard level
ChessOric.JPG (66.45 KiB) Viewed 8578 times
I think I'm gonna mate it soon .. it made two terrible mistakes and now I think it can no longer defend the position.
niark niark :evil:


Thank you for this game !! and congratulation for the port .. I long to have a look at the source code
User avatar
jbperin
Flight Lieutenant
Posts: 480
Joined: Wed Nov 06, 2019 11:00 am
Location: Valence, France

Re: cc65-Chess for Oric by [raxiss]

Post by jbperin »

Here's a soluce on how to beat it in 17 moves at level very hard on its Alekine's defense.
My 8th move is a very bad move .. but well .. it didn't punish me for that.

Code: Select all

1- E2-E4 		G8-F6
2- E4-E5 		F6-D5
3- D2-D4	 	E7-E6
4- C2-C4 		C7-C6
5- C4*D5 		C6*D5
6- F1-D3 		H7-H6
7- D1-H5 		H8-G8
8- D3-H7 		G7-G6
9- H5-G4 		G8-G7
10- C1*H6 	A7-A5
11- H6*G7 	G6-G5
12- G7-F6  	D8-B6
13- H7-G8 	A8-A6
14- G8*F7+ 	E8*F7
15- G4-H5+ 	F7-G8
16- H5-G6+	 F8-G7
17- G6*G7 	check mate
By the way, it seems not to be possible to start a new game once the previous on is over. I pressed Esc to go back to the menu but i failed to start a new game .. the board does not reset to its original position.
MateTheOric.JPG
MateTheOric.JPG (70.61 KiB) Viewed 8553 times
User avatar
ibisum
Wing Commander
Posts: 1645
Joined: Fri Apr 03, 2009 8:56 am
Location: Vienna, Austria
Contact:

Re: cc65-Chess for Oric by [raxiss]

Post by ibisum »

This is great, and I just want to acknowledge the 'edge' that this release has as a result of the care to graphical styling .. it could have been a bit of a boring chess game with just plain chars, but the styling of the board pieces and the font make all the difference to the 'feel', which I think is neat.
User avatar
coco.oric
Squad Leader
Posts: 720
Joined: Tue Aug 11, 2009 9:50 am
Location: North of France
Contact:

Re: cc65-Chess for Oric by [raxiss]

Post by coco.oric »

Hello,

Thanks for this new game. Rax & Iss duo is the new best Oric Game Producers
I tried it (without sound) and it's a pleasure, even if my chess level seems to be lower than jb's one.
coco.oric as DidierV, CEO Member
Historic owner of Oric, Apple II, Atari ST, Amiga
User avatar
Chema
Game master
Posts: 3014
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: cc65-Chess for Oric by [raxiss]

Post by Chema »

Yeah, very nice! I am very happy to see new good developments on the Oric.

Congratulations raxiss!!
User avatar
jbperin
Flight Lieutenant
Posts: 480
Joined: Wed Nov 06, 2019 11:00 am
Location: Valence, France

Re: cc65-Chess for Oric by [raxiss]

Post by jbperin »

Dbug wrote: Sat May 16, 2020 6:54 am I was wondering if that would help to auto-detect the presence of a disk controller to use the upper 16k of ram for additional search tree capabilities?
I casted an interested glance at the source code of AI and I can see two different method to use an extra memory as a way to enhance the chess skill of the program:

The South Face: Add an opening book


The idea would be to store a tree of usual and popular first moves sequence?
There are plenty of such opening book on the internet in text format.
With such an opening book, the game could play a perfect chess in the opening part which is the most critical part and the part where the brute force computation can not replace experience acquired by human players across centuries of practice.
16k is enough to stored a valuable opening book if it is properly compressed.

The North Face: Make the thinking deeper

I don't know if the extra 16k can be used as stack, but ifis it the case then it could possible to make the AI think deeper.
The call to the thinking function is here:
https://github.com/StewBC/cc65-Chess/bl ... cpu.c#L596

The AI recursion occurs here:
https://github.com/StewBC/cc65-Chess/bl ... cpu.c#L541

The thinking recursion is configured through three different values:
  • gMaxLevel: looking like the maximum depth of analysis
  • gWidth: looking like the number of analysed possibilities at each depth
  • gDeepThoughts:must be 1
This values are given for all 4 possible levels in the array defined here:
https://github.com/StewBC/cc65-Chess/bl ... bals.c#L46

If we could change the 3 last value of this array from "16,3,1" into a combination where the 3 (gMaxLevel) is replaced by a higher value, it would clearly enhance the chess skill of the engine.. but it would lead to:
- a far longer thinking . so the 16 (gWidth) would have to be lowered
- a greedy consumption of ram . Not only for the stack, but also for the undo list which is declared here:
https://github.com/StewBC/cc65-Chess/bl ... undo.c#L40

Not sure the

Code: Select all

#define UNDO_STACK_SIZE		255
can be increased without nasty side effects
User avatar
jbperin
Flight Lieutenant
Posts: 480
Joined: Wed Nov 06, 2019 11:00 am
Location: Valence, France

Re: cc65-Chess for Oric by [raxiss]

Post by jbperin »

jbperin wrote: Sat May 16, 2020 12:21 pm
I don't know if the extra 16k can be used as stack, but ifis it the case then it could possible to make the AI think deeper.
it would lead to:
- a far longer thinking . so the 16 (gWidth) would have to be lowered
- a greedy consumption of ram . Not only for the stack, but also for the undo list which is declared here:
https://github.com/StewBC/cc65-Chess/bl ... undo.c#L40
All things considered, that's stupid ...

I don't think the memory is a real limitation in increasing the depth of thinking. The computation time will for sure become more limitating.

However, the cpu time could possibly be reduced by using precalculated index in the process of possible moves generation which starts here:

https://github.com/StewBC/cc65-Chess/bl ... ard.c#L135

In most function called in the move generator, the chess_board is accessed trough a two-dimension indexing :

Code: Select all

gChessBoard[y][x]
rather than , like other part of the code, thruogh a single dimension indexing:

Code: Select all

gpChessBoard[position]
This way to access chessboard involves costy multiplication:

Code: Select all

#define MK_POS(y,x)			((y)*8+x)
If we could store precalculated position index for running through diagonals, lines, columns, knight shapes , and so on ...
we could replace part of code like this one:

Code: Select all

	do {
		x += dx;
		y += dy;
		--n;
	
		if(x > 7 || y > 7)
			break;

		piece = gChessBoard[y][x];
	
		if(NONE == piece || addDefenceMove || my_color != (piece & PIECE_WHITE))
			gPossibleMoves[gNumMoves++] = ((y)*8+x);

		// any non-emty tiles ends the scan
		if(NONE != piece)
			break;
			
	} while(n);
by more efficient code like:

Code: Select all

do {
	
		piece = gpChessBoard[position];
	
		if(NONE == piece || addDefenceMove || my_color != (piece & PIECE_WHITE))
			gPossibleMoves[gNumMoves++] = position;

		// any non-emty tiles ends the scan
		if(NONE != piece)
			break;
			
	} while (position = next_fdiagonal_tile [position]) != NO_MORE_TILE);
provided we would have some precalculated tables like:
next_fdiagonal1_tile , next_sdiagonal1_tile
next_fdiagonal2_tile , next_sdiagonal2_tile
next_vertical1_tile , next_vertical2_tile
and so on ..


Then we could transfert some cpu time load to memory load. That would allow to play with depth of thinking without exploding the computation duration.

So that we could have an Oric version of the chess game that kicks the ass of the Apple II version :-)

:lol: :lol: :D
User avatar
iss
Wing Commander
Posts: 1641
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: cc65-Chess for Oric by [raxiss]

Post by iss »

Thanks to all for the nice words!
This definitely will keep the tempo of new release high (... if you only "can smell what the raxiss is cooking" :twisted: ).
Dbug wrote: Sat May 16, 2020 6:54 amQuestion: Does the game uses a lot of memory for the AI? I was wondering if that would help to auto-detect the presence of a disk controller to use the upper 16k of ram for additional search tree capabilities?
All platform dependent functions are defined in plat.h. I've created a 'fake' platform with all these functions as empty:

Code: Select all

void plat_Init(void){}
void plat_UpdateScreen(void){}
char plat_Menu(char **menuItems, char height, char *scroller){}
void plat_DrawBoard(char clearLog){}
void plat_DrawSquare(char position){}
void plat_ShowSideToGoLabel(char side){}
void plat_Highlight(char position, char color, char cursor){}
void plat_ShowMessage(char *str, char color){}
void plat_ClearMessage(void){}
void plat_AddToLogWin(void){}
void plat_AddToLogWinTop(void){}
int plat_ReadKeys(char blocking){}
void plat_Shutdown(void){}
And the result is exactly 18319 ($478F) bytes for the engine. And having even more 16K can help for improving the AI, I think.
jbperin wrote: Sat May 16, 2020 5:08 pmSo that we could have an Oric version of the chess game that kicks the ass of the Apple II version :-)
Congrats for the great source code analysis! It looks really promising!
And having Apple][ badly beaten - that's what I want to see :lol: .

Here is how I won in 7 moves on 'Very Easy' level but this are all my chess skills too:
checkmate-7m.png
checkmate-7m.png (41.46 KiB) Viewed 8459 times
Else about the porting - it was really easy with the well structured code and the Apple][ implementation as template.
The intro was more challenging I put lot effort there to solve many small details as:
- use Arkos Tracker 2 AKY music player by Julien Névo a.k.a. Targhan/Arkos converted to 6502/Oric by Arnaud Cocquière a.K.a GROUiK/FRENCH TOUCH a.K.a Scalex, There was real bug in code but this 'music story' deserves whole new topic;
- be compatible with Oric-1 and Atmos/Pravetz-8D - no ROM functions are used;
- implement nice HIRES switching without ugly bars/lines on screen;
- implement 'Loading...' progressbar like animation 'ala Twilighte's magic trick';
- make the scrolling Text/Bitmap script controlled and frame synchronized;
- rax painted 3 chess-boards, 3 chess-pieces sets and 10 different dividers to select from;
- ... and lot lot more including fun! :)
User avatar
kenneth
Squad Leader
Posts: 515
Joined: Fri Nov 26, 2010 9:11 pm
Location: France PdD
Contact:

Re: cc65-Chess for Oric by [raxiss]

Post by kenneth »

The demo is fantastic !
The game is nice to play. :D
User avatar
jbperin
Flight Lieutenant
Posts: 480
Joined: Wed Nov 06, 2019 11:00 am
Location: Valence, France

Re: cc65-Chess for Oric by [raxiss]

Post by jbperin »

iss wrote: Sat May 16, 2020 6:22 pm (... if you only "can smell what the raxiss is cooking" :twisted: ).
:-) Excellent !! Yum .. Yum ..

Didn't know Dwayne Johnson was on Oric .. this guy is definitely cool :-)


iss wrote: Sat May 16, 2020 6:22 pm And having Apple][ badly beaten - that's what I want to see :lol: .
That might be an interesting challenge .. If i manage to recompile the project, i'll try the various ideas i've got on how to enhance the thinking part.
iss wrote: Sat May 16, 2020 6:22 pm - use Arkos Tracker 2 AKY music player by Julien Névo a.k.a. Targhan/Arkos converted to 6502/Oric by Arnaud Cocquière a.K.a GROUiK/FRENCH TOUCH a.K.a Scalex, There was real bug in code but this 'music story' deserves whole new topic;
Yes :-)
iss wrote: Sat May 16, 2020 6:22 pm - be compatible with Oric-1 and Atmos/Pravetz-8D - no ROM functions are used;
It offers some very interesting possibilities. DBug knows how to get 16 more kilobytes thanks to that.
iss wrote: Sat May 16, 2020 6:22 pm - implement nice HIRES switching without ugly bars/lines on screen;
- implement 'Loading...' progressbar like animation 'ala Twilighte's magic trick';
- make the scrolling Text/Bitmap script controlled and frame synchronized;
- rax painted 3 chess-boards, 3 chess-pieces sets and 10 different dividers to select from;
- ... and lot lot more including fun! :)
Graphics are very nice and the text scrolling is so cool.. all that contributes to make the game very beautiful. Congratulations. and thanks again.
One more jewel in Oric's patrimony.
User avatar
jbperin
Flight Lieutenant
Posts: 480
Joined: Wed Nov 06, 2019 11:00 am
Location: Valence, France

Re: cc65-Chess for Oric by [raxiss]

Post by jbperin »

When I try to build the project with instructions provided in the readme file, it says that there's no rule to build the target "cc65-chess.oric" required to build "cc65-Chess.tap".

Am i missing something ? (other than cleverness that I know I've been missing for more than 40 years now)
User avatar
iss
Wing Commander
Posts: 1641
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: cc65-Chess for Oric by [raxiss]

Post by iss »

Main repository was just updated by StewBC: https://github.com/StewBC/cc65-Chess
But there is a small bug somewhere, so for successful build follow this steps exactly.
1. Include 'path_to/cc65/bin' in your PATH environment variable
2. Download the repo (the used upper/lower case is important!) :

Code: Select all

https://github.com/StewBC/cc65-Chess.git cc65-chess
3. Change directory to 'cc65-chess'
4. Make the Oric target:

Code: Select all

make OPTIONS=optspeed all tap
The result is: cc65-Chess.tap ;)
Hope this helps!
User avatar
jbperin
Flight Lieutenant
Posts: 480
Joined: Wed Nov 06, 2019 11:00 am
Location: Valence, France

Re: cc65-Chess for Oric by [raxiss]

Post by jbperin »

iss wrote: Wed May 27, 2020 6:35 pm Hope this helps!
Yes it helps :-)

The build failed on target cx16 (which was added recently I presume)
I removed it from the makefile and only left apple2 and oric and I got the .TAP ..

Thanks a lot :-)
Post Reply