I am programming a chess engine with minimax.
I use an array with 120 elements for the board. For every possible move, I have to create a copy of this array which is really slow without using bitboard.
Can I fasten this board copy part, e.g. using strings?
pisces.forEach(pisce=>{
pisce.forEach(move=>{
let copy=[...board]
//other stuff
board=copy
})
})
Instead of copying the board, you could consider using a "do-undo" system:
pisces.forEach(pisce=>{
pisce.forEach(move=>{
play(board, move);
//other stuff
undo(board, move);
})
})
NB: in chess you need also to keep track of whether castling is still allowed, en passent capture is allowed, how many moves have passed since the last capture, pawn or castling move (for applying the 50-move rule), ... So a move object should have enough information to set and undo such state changes.