Answers.Body: <p>For the fastest move generation I suggest the below code.</p>
  
  <p><a href="https://github.com/Mk-Chan/WyldChess/blob/master/src/magicmoves.c" rel="nofollow noreferrer">https://github.com/Mk-Chan/WyldChess/blob/master/src/magicmoves.c</a></p>
  
  <p>It’s not the Stockfish source code, but I was able to use it for my own hobby engine and I can tell you that it’s very fast. If you have a lot of trouble I can write a post about how I did it.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-22T04:40:22.437Z
Answers.Text: Thank you for your response i am already using this movegen for my sliding pieces and I was looking for something that could either cover the move generation for at least the pawns and knights or do the entire move generation
Answers.UserDisplayName: Julian Carrier
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-22T11:46:18.197Z
Answers.Text: I can send you my code if need be (its perft checked). Maybe look into python-chess if you want to prototype an AI engine, then switch over to a faster language.
Answers.UserDisplayName: nak3c
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-21T01:13:58.940Z
Answers.LastActivityDate: 2020-04-21T02:06:59.223Z
Answers.LastEditDate: 2020-04-21T02:06:59.223Z
Answers.UserDisplayName: nak3c
Answers.Body: <p>It's javascript but chess.js <a href="https://github.com/jhlywa/chess.js/" rel="nofollow noreferrer">https://github.com/jhlywa/chess.js/</a> will keep track of board state, load &amp; generate pgns and fens, and tell you what moves are legal.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-07T20:42:58.983Z
Answers.LastActivityDate: 2020-06-07T20:42:58.983Z
Answers.UserDisplayName: honkskillet
Body: <p>Basically, I’m creating a chess AI and I want to focus on the search algorithm rather than the most complete way or fastest move generation portions. So, for now, I was thinking I could use a prebuilt move generator from a tested and well-known source such as Stockfish.</p>
  
  <p>But I'm having trouble understanding how Stockfish represents the current gamestate and how I can read it, how I can get Stockfish to essentially loop through all of the possible nodes, and how I can check if a given node is a leaf. If someone could point me to a resource or knows how Stockfish does this it would be greatly appreciated.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-21T08:09:54.047Z
Comments.Text: Can you be more specific of what you don't understand?  Bitboards, translating into a square, source code not commented enough...?
Comments.UserDisplayName: Mike Jones
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-22T04:44:32.600Z
Comments.Text: Essentially what im trying to understand is two things how does stockfish represent the board i.e bitboards or some variation and then secondly what methods or functions it uses to do basic things like check for checkmate. From this information I intend to derive how I can read the current positions of every piece and generate all of the legal moves possible.
Comments.UserDisplayName: Julian Carrier
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-22T17:33:54.640Z
Comments.Text: http://www.craftychess.com/ is well documented, and you should have all your questions answered.  I prefer the 64 square board representation as it lends itself to better chess understanding.
Comments.UserDisplayName: Mike Jones
Tags: <engines><stockfish>
Title: Using the Stockfish move generator in a home chess engine
ThreadText: # Using the Stockfish move generator in a home chess engine
  
  (Asked by: username_0 on 2020-04-20)
  
  Basically, I’m creating a chess AI and I want to focus on the search algorithm rather than the most complete way or fastest move generation portions. So, for now, I was thinking I could use a prebuilt move generator from a tested and well-known source such as Stockfish.
  
  But I'm having trouble understanding how Stockfish represents the current gamestate and how I can read it, how I can get Stockfish to essentially loop through all of the possible nodes, and how I can check if a given node is a leaf. If someone could point me to a resource or knows how Stockfish does this it would be greatly appreciated.
  
  **Tags:** engines, stockfish
  
  > **Comments:**
  > **username_1**: Can you be more specific of what you don't understand?  Bitboards, translating into a square, source code not commented enough...?  
  > **username_0**: Essentially what im trying to understand is two things how does stockfish represent the board i.e bitboards or some variation and then secondly what methods or functions it uses to do basic things like check for checkmate. From this information I intend to derive how I can read the current positions of every piece and generate all of the legal moves possible.  
  > **username_1**: http://www.craftychess.com/ is well documented, and you should have all your questions answered.  I prefer the 64 square board representation as it lends itself to better chess understanding.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2020-04-21. Score: 5 | Accepted answer
  
  For the fastest move generation I suggest the below code.
  
  <https://github.com/Mk-Chan/WyldChess/blob/master/src/magicmoves.c>
  
  It’s not the Stockfish source code, but I was able to use it for my own hobby engine and I can tell you that it’s very fast. If you have a lot of trouble I can write a post about how I did it.
  
  > **Comments:**
  > **username_0**: Thank you for your response i am already using this movegen for my sliding pieces and I was looking for something that could either cover the move generation for at least the pawns and knights or do the entire move generation  
  > **username_2**: I can send you my code if need be (its perft checked). Maybe look into python-chess if you want to prototype an AI engine, then switch over to a faster language.  
  
  ---
  
  ### Answer by username_3 on 2020-06-07. Score: 2
  
  It's javascript but chess.js <https://github.com/jhlywa/chess.js/> will keep track of board state, load & generate pgns and fens, and tell you what moves are legal.
  
  
  ---
  
  