SebLague / Chess-Challenge

Create your own tiny chess bot!
https://www.youtube.com/watch?v=Ne40a5LkK6A
MIT License
1.77k stars 1.06k forks source link

How do you figure out what moves have been played? #95

Open MathabsUnity opened 1 year ago

MathabsUnity commented 1 year ago

How can you find out what moves have been played in a game (like 1. e4 e5 2. Nf3 Nc6 etc.)? Is there a function that I can use?

stianlaa commented 1 year ago

Doesn't seem to be a function described in the docs: https://seblague.github.io/chess-coding-challenge/documentation/, I suppose you could diff the bitboard states between your moves and infer the move.

MathabsUnity commented 1 year ago

@SebLague can you add this feature to the code?

MinekPo1 commented 1 year ago

@SebLague can you add this feature to the code?

Lague is most likely asleep currently (its 20 min till midnight in his (and my) time zone). I doubt this will be added as this feature likely has little to no use when creating an engine.

If you want a unique value representing a position use board.ZobristKey

ufrshubham commented 1 year ago

Duplicate of #92 @MathabsUnity seems like you are opening same issue multiple times.

Bulmenisaurus commented 1 year ago

This is actually found in the Board class here: https://github.com/SebLague/Chess-Challenge/blob/20b3556031cca60cdbdd88e4f5e24359bf99e617/Chess-Challenge/src/Framework/Chess/Board/Board.cs#L61. But unfortunately I don't think we can access that class, as it is not specified as public in the Board we can access: https://github.com/SebLague/Chess-Challenge/blob/20b3556031cca60cdbdd88e4f5e24359bf99e617/Chess-Challenge/src/API/Board.cs#L10

If board was public there we would be able to do something like

    public Move Think(Board board, Timer timer)
    {
        List<Move> moves = board.board.AllGameMoves;
    }

but we can't :(

SebLague commented 1 year ago

There isn't currently a way to access this through the api. Do you just need this for debugging, or do you plan to somehow use that info as part of your bot's strategy?

MathabsUnity commented 1 year ago

I want to use it in my bot's strategy.