I would like to thank everyone for showing interest. I'll now describe my chess engine's organization along with the problems I am facing and then I'll post the Github link. So here's it:
I have programmed it in C++(some features from C++11 are required as well).
The engine consists of the following files currently:
1. data.hpp - Contains several enumerations and some macros along with the declaration of some variables to enhance the readability of the program later. Also includes other standard header files.
2. move.hpp - It contains the declaration of the class Move.
3. move,cpp - Contains the definitions of methods in the move class. They are as follows: - Move(from, to) for normal/capture moves for any piece, Move(from) if it is enPassant(this is checked internally) and move(isCastle, castle), where isCastle is a boolean and the integer castle decides if it is king side or queen side castle. There is also a function to print the move and another one to initialize a move via a string. The printing and initializing functions are not complete right now, but they work just fine.
Also there is a function Move(from, to, PromotedPiece) for pawn promotion.
4. chessboard.hpp - Contains the declaration of the class chessboard
5. chessboard.cpp - It has the following functions:
initEmptyBoard() - It initializes an empty board
setUpDebugging() - Certain variables which make coding and printing easier
initHash() - Initializes the hashlist
fenSetup() - Loads a fen position onto the board
initPieceList() - Initializes the piece list after the fen setup is done
initUniqueKey() - Initializes the hash key.
playMove() - Play a move on the board and update the required variables
undoMove() - Undo a move on the board and update the required variables
printBoard() - This prints several variables and the board on the screen, and this helped me a lot with debugging purposes.
isSquareSafe() and isSquareAttacked() - As the names suggest
isMoveValid() - Records the side of the current king. Plays a move. Sees if square of the king is safe. If safe, then validity = true, else false. Undo the move and then return the validity.
addMove() - Checks if the move is valid and if it is so, then adds the move to the vector moveList.
6. moveGen.cpp - Contains the member function chessboard::generateAllMoves() which generates all pseudolegal moves for the current side, addMove() is used, so the vector moveList finally contains only legal moves.
7 . main.cpp - Currently only used for some tests
8. The Makefile
Now for my problems:
A) The unique keys generated when I play moves from the start to get to the fen position and when I directly load the fen position are different. Eg. I load the fen position for 1. e2e4 and I play the move e2e4 on the starting position, the uniqueKeys generated are different.
However, playing and undoing moves on the same board generates the same keys, so I believe the functions playMove() and undoMove() are right.
B) the isMoveValid function does not work as intended, It goes into some sort of infinite loop, unable to figure out why. This problem bugs me the most. So right now I have commented out the line if ( isMoveValid(move) ) in my addMove function. So right now I am only adding pseudo-legal moves to the moveList vector.
C) I am unable to figure to reset the castle permissions in undoMove(). I tried using a count of the no. of times the king/rook move, but it turned out to be ugly. I think I will have to store the castle permissions in a vector containing the castle history.
Sorry for any grammatical mistakes I might have made, I wrote this in a hurry.
Thanks, and here's the link to the code I've uploaded on Github(there is no licensing so it has the standard licensing by default).
https://github.com/universecoder/Chess-Engine