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

api documentation #18

Closed
amryounis opened this issue Jun 9, 2019 · 3 comments
Closed

api documentation #18

amryounis opened this issue Jun 9, 2019 · 3 comments

Comments

@amryounis
Copy link

hi, could you provide some summary of the api

@rudzen
Copy link
Owner

rudzen commented Jun 21, 2019

Hi.. The library functionality is well documented at code level. So at the moment there are no plans to provide more documentation. Unless of course there is a specific issue with it.

@JamesLear92
Copy link

JamesLear92 commented Mar 18, 2020

Hi,
Thanks for releasing this code. I have to admit I've spent a couple of minutes now trying to work out how to use this library, despite the well commented code.

For instance, how can I create a new game?
The constructor for Game has an iposition parameter, so we have to find a position class which has that interface and find the constructor for that; I find the constructor and there are no parameters, but it's not immediately clear to me if a new position has any pieces by default.

Also game has a lot of the same methods as position, should we be calling these methods from game or the position?

Cheers again for your hard work on this.

@rudzen
Copy link
Owner

rudzen commented Mar 19, 2020

Hi,
Thanks for releasing this code. I have to admit I've spent a couple of minutes now trying to work out how to use this library, despite the well commented code.
For instance, how can I create a new game?
The constructor for Game has an iposition parameter, so we have to find a position class which has that interface and find the constructor for that; I find the constructor and there are no parameters, but it's not immediately clear to me if a new position has any pieces by default.

The Position class implements the IPosition interface so you can simply create a new Position.
Then you can use that Position reference when creating a Game reference.

For starting a new game with start position you can do something like

var position = new Position();
var game = GameFactory.Create(position);
var actual = game.NewGame();

The NewGame method has a overload for a FEN string which allows to set the position in the game without having to re-create a new Position object.

You can use the Pos property as it will always contain the current position data (updated when moves are made etc).

To retrieve what pieces that currently is in the game, I would recommend you use the game property Occupied or the various methods on the Position property directly through the game object.
This will give a bitboard with the square position of all pieces, which you can simply use a foreach loop like this

var pieces = game.Occupied;
foreach (var sq in pieces)
{
    var piece = game.Pos.GetPiece(sq);
    Console.WriteLine(piece.ToString());
}

Also game has a lot of the same methods as position, should we be calling these methods from game or the position?

I believe you are thinking about the MakeMove() and TakeMove() methods, as they seem very identical.

Where possible, always use the methods located in the game object. If needed, they will use the position variants of those same methods.

The reason for this is that its possible to use the Position class by itself for various things with respects to UI stuff etc.

Cheers again for your hard work on this.

Thanks

@rudzen rudzen closed this as completed May 12, 2020
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

3 participants