Pre-announcement: Oscar Chess Library

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Pre-announcement: Oscar Chess Library

Post by sje »

Pre-announcement: Oscar Chess Library

The Oscar Chess Library (OCL) is a set of ANSI C source files which implement a library for general, low-level chess programming tasks. It will be released under the GNU Public License for all to use without charge. At present, the OCL consists of about 6K+ lines of code contained in one C file and one header file.

I hope to have this ready in a week or two.

Project priorities in descending order:

1) Correctness
2) Standards adherence
3) Generality
4) Ease of use
5) Speed

Some scalar types:

Code: Select all

OclColor OclPiece OclMan OclFile OclRank OclSq OclMove OclPosTerm
Some other types:

Code: Select all

OclPosition OclMoveVec OclHash
Some routines (insert const qualifiers where appropriate):

Code: Select all

void OclInit(void);  // One time library initialization
void OclTerm(void);  // One time library termination

OclPosition *OclNewPosition(void);            // Position instance constructor
void OclDeletePosition(OclPosition *objptr);  // Position instance destructor

OclPosition *OclPositionCopy(OclPosition *objptr);  // Position instance copy constructor

void OclPositionEncode(OclPosition *objptr, char *fenstr);  // Position encoder (FEN)
bool OclPositionDecode(OclPosition *objptr, char *fenstr);  // Position decoder (FEN)

void OclPositionReset(OclPosition *objptr);  // Reset a position to the initial array

unsigned int OclPositionCountMoves(OclPosition *objptr);  // Returns number of moves in a position
unsigned int OclPositionGenerate(OclPosition *objptr, OclMoveVec *movevec);  // Move generation for a position

void OclPositionExecute(OclPosition *objptr, OclMove move);  // Move execution
void OclPositionRetract(OclPosition *objptr);                // Move retraction

bool OclPositionIsCheck(OclPosition *objptr);  // Position status: in check

bool OclPositionIsCheckmate(OclPosition *objptr);     // Position status: checkmated
bool OclPositionIsStalemate(OclPosition *objptr);     // Position status: stalemated
bool OclPositionIsFiftyMove(OclPosition *objptr);     // Position status: fifty move draw
bool OclPositionIsInsufficient(OclPosition *objptr);  // Position status: insufficient material draw
bool OclPositionIsThreeFold(OclPosition *objptr);     // Position status: threefold repetition draw

bool OclPositionIsMate(OclPosition *objptr);  // Position status: checkmated or stalemated
bool OclPositionIsDraw(OclPosition *objptr);  // Position status: drawn (50m, insufficienct, or 3rep)

bool OclPositionIsGameOver(OclPosition *objptr);  // Position status: mated or drawn

OclPosTerm OclPositionCalcPosTerm(OclPosition *objptr);  // Calculate positon termination (if any)

unsigned long long int OclPositionPerft(OclPosition *objptr. unsigned int draft);  // Simple perft

void OclMoveEncode(OclMove *objptr, char *sanstr);                       // Move encoder (SAN)
bool OclMoveDecode(OclMove *objptr, char *sanstr, OclPosition *objptr);  // Move decoder (SAN)

void OclMoveEncodeUCI(OclMove *objptr, char *ucistr);                       // Move encoder, UCI format
bool OclMoveDecodeUCI(OclMove *objptr, char *ucistr, OclPosition *objptr);  // Move decoder, UCI+others format
Dann Corbit
Posts: 12777
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Pre-announcement: Oscar Chess Library

Post by Dann Corbit »

Looking forward to it.
I had tons of fun playing with the SAN Toolkit in days of old, when knights were bold.
mar
Posts: 2659
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Pre-announcement: Oscar Chess Library

Post by mar »

Very nice, thanks.
I like the interface a lot - simple and clean yet powerful.

Just one comment, are you sure you want to use GPL? Wouldn't that be somewhat restrictive for a low level library?

I have to say I recently fell in love with BPL (Boost public license) and consider using it for my upcoming open source release (*unrelated to chess),
which allows others to include the library in binary form (no matter if linked statically or dynamically)
without having to go open the source and/or accompany the binaries with the copy of the license.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Pre-announcement: Oscar Chess Library

Post by sje »

mar wrote:Very nice, thanks.
I like the interface a lot - simple and clean yet powerful.

Just one comment, are you sure you want to use GPL? Wouldn't that be somewhat restrictive for a low level library?

I have to say I recently fell in love with BPL (Boost public license) and consider using it for my upcoming open source release (*unrelated to chess),
which allows others to include the library in binary form (no matter if linked statically or dynamically)
without having to go open the source and/or accompany the binaries with the copy of the license.
I may reconsider this. There is the LGPL alternative: https://en.wikipedia.org/wiki/GNU_Lesse ... ic_License
mar
Posts: 2659
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Pre-announcement: Oscar Chess Library

Post by mar »

sje wrote:I may reconsider this. There is the LGPL alternative: https://en.wikipedia.org/wiki/GNU_Lesse ... ic_License
The problem with LGPL is it prevents you from linking statically...
EDIT: so if you don't like Boost license, you may consider MIT/BSD/zlib instead
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Pre-announcement: Oscar Chess Library

Post by sje »

Dann Corbit wrote:Looking forward to it.
I had tons of fun playing with the SAN Toolkit in days of old, when knights were bold.
It's nearly complete except for some namespace magic to avoid identifier collisions.

I'll include some sample code, like a SAN/coordinate move notation mapper and position tracker useful for chatting with old programs which use XBoard protocol version one. Also, some command line utilities for simple tasks like perft(), detect mate-in-N, etc.

Eventually, I may add parsers for EPD and PGN; maybe even a book constructor. Also, I'll probably write a no-frills, low-overhead mediator/referee.
Dann Corbit
Posts: 12777
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Pre-announcement: Oscar Chess Library

Post by Dann Corbit »

mar wrote:
sje wrote:I may reconsider this. There is the LGPL alternative: https://en.wikipedia.org/wiki/GNU_Lesse ... ic_License
The problem with LGPL is it prevents you from linking statically...
EDIT: so if you don't like Boost license, you may consider MIT/BSD/zlib instead
Or just use it as a toy.
Or your own project must also be LGPL.
I never look a gift horse in the mouth.

My favorite license is Berkeley, but I will take whatever I can get, including closed source.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

A sneak peek

Post by sje »

A sneak peek at a slightly dated version of the library header file Oscar.h

See: https://dl.dropboxusercontent.com/u/316 ... ar/Oscar.h
Dann Corbit
Posts: 12777
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: A sneak peek

Post by Dann Corbit »

Suggestion:
change bool enum to Bool, so that it can also be used with C++.
tttony
Posts: 271
Joined: Sun Apr 24, 2011 12:33 am

Re: A sneak peek

Post by tttony »

I like this part :D

Code: Select all

typedef enum
{
  PieceNil = -1,
  PiecePawn,    // Weak, but has hopes for a sex change operation
  PieceKnight,  // Moves as crooked as a politician
  PieceBishop,  // Tax exempt means seeing only half the squares
  PieceRook,    // Football player: powerful, straight, and not too smart
  PieceQueen,   // The real power behind the throne
  PieceKing,    // Lazy guy who leaves the dirty work to others
  PieceVacant,  // This space open for rent
  PieceExtra    // WTF?
} Piece;
:lol: