Body: <p>I am in the process of building a chess engine in Java using bitboards. I know C/C++ is more optimal for this but I have no knowledge of either so I'd rather attempt to do it with Java for now. I have two questions about storing generated moves.</p>
  <ol>
  <li>With regard to the format in which the moves themselves are stored, I've read about Stockfish's 16 bit format (from square, to square, promotion piece, special move) and I've also looked through the source code of CuckooChess (written in Java, ~2600 on CCRL) that have a Move class designated to hold all characteristics of a move in an object. What are the tradeoffs between either method, or any other method not mentioned?</li>
  <li>I'd like to store legal moves in an array, but I wouldn't be able to just append a move to the end of the array. The logical alternative would be using an ArrayList; however I'm also worried that the larger memory requirement of ArrayList would cause some issues. Would I store legal moves in an array, arrayList, or another structure, or are these considerations insignificant?</li>
  </ol>
  
Tags: <engines><computer-chess><bitboard>
Title: Storing generated moves for a chess engine in Java
ThreadText: # Storing generated moves for a chess engine in Java
  
  (Asked by: username_0 on 2023-07-25)
  
  I am in the process of building a chess engine in Java using bitboards. I know C/C++ is more optimal for this but I have no knowledge of either so I'd rather attempt to do it with Java for now. I have two questions about storing generated moves.
  
  1. With regard to the format in which the moves themselves are stored, I've read about Stockfish's 16 bit format (from square, to square, promotion piece, special move) and I've also looked through the source code of CuckooChess (written in Java, ~2600 on CCRL) that have a Move class designated to hold all characteristics of a move in an object. What are the tradeoffs between either method, or any other method not mentioned?
  2. I'd like to store legal moves in an array, but I wouldn't be able to just append a move to the end of the array. The logical alternative would be using an ArrayList; however I'm also worried that the larger memory requirement of ArrayList would cause some issues. Would I store legal moves in an array, arrayList, or another structure, or are these considerations insignificant?
  
  **Tags:** engines, computer-chess, bitboard
  
  
  ---
  
  ## 0 answers
  
  