I plead guilty!Teemu Pudas wrote:This is your code, right?
What is the worst real-world macros/pre-processor abuse you've ever come across? wrote:#define EP_STATUS CASTLING][(BOARD_FILES-2)
#define HOLDINGS_SET CASTLING][(BOARD_FILES-1)
I thought that was pretty neat & clever. Making a 2d array appear like it is a 1d array, writing board[EP_STATUS], or board[CASTLING].
The obvious way to design this from scratch would of course be to make the game state a struct with fields ep_status, castling_rights[4] and board[8][8], and define an array state[MOVE_NR] of those, but considering that the existing code had a boards[MOVE_NR][8][8] which it referred to in a zillion places it would have been a horrendous effort to replace it everywhere by the struct. Just hiding the e.p. and castling rights in some of the elements of the 2d aray took only a minute, with zero chances for introducing a bug.