Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation :) #5

Open
RichardPortelli opened this issue Mar 24, 2023 · 1 comment
Open

Documentation :) #5

RichardPortelli opened this issue Mar 24, 2023 · 1 comment

Comments

@RichardPortelli
Copy link

First of all, I apologize for filling a bug report while it is not one, I just could not find a way to contact you :(

I would like to do a wrapper around Leorik, something that would be similar to that :
class EngineInterface {
Action onNewLine; //called each time engine output a new line

bool start(); //start engine
void stop(); //stop engine

bool startListening(); //if listening call onNewline each time engine output lines, other wise, readLine should be called
bool stopListening();
bool isListening();
bool write(string uciCommand);
string readLine(int timeout);
}

I'm a bit confused by the different projects Core, Engine, etc .... and I was looking for some information about the organisation of the code, is there a documentation somewhere?

@lithander
Copy link
Owner

lithander commented Mar 25, 2023

Hi Richard!

Please keep in mind that Leorik is not published under any open-source license. You can't legally publish anything that's using Leorik's source code without asking for permission, first. If you don't want to do that in public please feel free to contact me via lithander@gmx.de :)

I think you have a good point about lack of documentation. Maybe I should create a few wiki pages here on github. But for now I'll probably just answer your questions here:

The Leorik.Engine project is what you can compile into a UCI compatible binary and use as a chess engine in all the popular chess GUIs. This Engine project is more or less the wrapper you have in mind, receiving the UCI commands and starting the search off in it's own thread while still communicating with the GUI in the main thread, so to speak. It's taking care of the time-control logic, too.

Leorik.Core is like a library of usefull classes and is used by all the other projects. Leorik.Search uses this library to implement a quite sophisticated alpha-beta search on a position. So it's probably not surprising to find that Leorik.Engine project has a dependency on Leorik.Search and Leorik.Core. The most important class in the Leorik.Search project is the IterativeSearch class. You initialize it with a BoardState (which you can create easily from a FEN string for example) and then you can call for example Search(5) on it and it will search the position to depth 5. You can also iteratively search deeper and deeper by calling SearchDeeper() which is what you typically do in an engine. You continue searching until you exceed the time budget you have set yourself. This search instance then has a few public properties like Score, BestMove and PV that will inform you about what the search found to be the best move and it's continuation. This is the heart of Leorik, really.

Leorik.Perft, Leorik.Test und Leorik.Tuning are projects that are mostly useful for developing the engine. If you just want to create a chess-playing entity in C# using Leorik's search and evaluation logic, then you can ignore these projects for now. If you want to improve Leorik by adding features to it, then these projects are relevant to retune the evaluation parameters and validating that the new version against the previous one.

Let me know if you have any more questions? To hear what is not immediately obvious to someone looking at the code base for the first time will help me with writing the wiki eventually, so don't be shy! ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants