I'm trying to program an engine (named Pebble), but I've found that programming chess is a lot harder than it looks. I don't think it helps much that I'm still a beginner at programming, either.
I want to at least make an engine that can beat me. That's my whole goal with computer chess. I think once I understand most of the intricacies, I won't feel so overwhelmed then.
I'm having trouble with the board representation. I am planning to implement the 0x88 method since I think that bitboards are stupid (I don't understand them at all.). Obviously, though, the top programs use bitboards and I can see why. It's a slick implementation that makes the program run smoother. I think I might implement these later once I understand them.
Here is the code I have so far. I am using C++, since I'm learning it right now, and even though it's a speed drain I am going to be using Object Oriented Programming.
Code: Select all
class Board
{
private:
int board[128]; //Will keep track of the state of the board
int fifty_move_rule; //Keeps track of the fifty move rule
int total_moves; //Keeps track of the total number of moves
int sidetomove; //Keeps track of the side to move
struct pieces
{
static const int whitepawn = 1;
static const int whiteknight = 2;
static const int whitebishop = 3;
static const int whiterook = 4;
static const int whitequeen = 5;
static const int whiteking = 6;
static const int blackpawn = -1;
static const int blackknight = -2;
static const int blackbishop = -3;
static const int blackrook = -4;
static const int blackqueen = -5;
static const int blackking = -6;
};
public:
Board();
int switchside(int sidetomove);
//makemove(); Don't know the return types
//unmakemove();
};
Any comments or suggestions would be greatly appreciated. Thanks in advance.