Chess program!

Pages: 12
So I plan on starting a simple program. I want to make this as OO as possible. The classes I have in mind are:
1. Board
2. Peice(Pawn, bishop, queen, etc.)
3. Move(Tests legality of move.)
4. AI...?

I can't really think of any other I would need. In Move, should I have the pawn swap rules in there? Like, when a pawn reaches the opponents side, user gets to choose to replace the pawn with a better piece.
I presume that we are talking about the back-end (the engine).

If you are new to chess programming, the Chess Programming Wiki is a good place to start.
http://chessprogramming.wikispaces.com/

Some more useful links are available here: http://www.top-5000.nl/prostuff.htm



I had just planned on having a console front end. The front end wasn't really my concern though, no. I'll check the links out though
Like, when a pawn reaches the opponents side, user gets to choose to replace the pawn with a better piece.


Is this seriously a rule? I love chess and I've not heard of this one before...
Is this seriously a rule? I love chess and I've not heard of this one before...


Yes it is.
Oh, I guess you meant, the opponent's "end".. I know about that.. Rank 1 or 8... for some reason, I was thinking of the half-way mark (Rank 4 and 5's border)... o.O How silly of me... Please don't think I'm dumb.. :(

Like, when a pawn reaches the opponents side, user gets to choose to replace the pawn with a better piece.



Is this seriously a rule? I love chess and I've not heard of this one before...


Are you serious ? You love chess and have no idea about this rule?

Last edited on
It's alright, I just learned of the en passant rule of chess while doing research for this. I've never heard of that one before
Don't forget the 50 moves rule too!
Yea that'll be the least of my worries haha. After quite a bit of research, I realize how daunting this project is gonna be now.
> I realize how daunting this project is gonna be now.

Divide and conquer. Take one baby step at a time and make sure that what you have got so far is working correctly, then take the next small step, and so on.

1. Start with the board representation - for example bitboard - which can represent a chess position

2. Add the functionality for basic movement of pieces - how rooks, knights etc. move.

3. Add the more complicated rules - checkmate, castling, pawn-promotion etc. At the end of this step, given any chess position your program should be able to generate a list of valid chess moves. Make sure that this is working perfectly *before* you go any further.

4. Add the functionality to play a complete game of chess, pick an arbitray random move from the list of all legal moves when it is the program's turn to play, wait for the opponent response and repeat.

After that try to make the program intelligent - search trees, evaluation, pruning and so on; the really interesting parts in programming a chess engine.


^ I like the way this guy thinks... I'd do what he says... :D In addition, just as a further step, how cool would it be, if it wrote the game in a text file in standard chess language!? You could store all the games anyone plays, and they could actually map their progress! :D

ThangoDo - I misunderstood what he meant... I realized later that I actually do know all the possible moves and rules in chess..! Knew about the en passant (I used to call it side-step move earlier :P ) and the 50-move draw... (I'm not that good a player though.. I just like playing it.. :D )

Though I do feel programming a chess game in a console would be a tad tedious! Enjoy! :D
I'm excited to get this started. Just hope I'll have time with classes starting back up now. Just the bitboard concept I'm struggling with. Not entirely sure what it is/how it works.
assuming we know it's in C3 how we'll find the location of it in a vector<byte> board(64) ?
Why use a vector? I think an array would be much more efficient. Considering we never have to resize, I see no need for a vector.
You can avoid a whole can of worms by using a std::bitset<64> instead of an array.
http://www.cplusplus.com/reference/stl/bitset/

@JLBorges : Genius , that's what I expected !
Hmm, how would I use this bitset to represent all I need to? I was initially thinking of using a 2D array or 64 element array of struct. The struct would hold information about each square. But, after some digging around I came to the conclusion that this would be highly inefficient.
Good luck with this project.

JLBorges, he won't be able to store much information about each square that way :/

On a totally unrelated note, has anyone here played bughouse chess? I've recently started playing it, and it's amazing, definitely try it if you have four people, I like it much more than traditional chess ^^
I have not heard of it.

Thanks for the useful links and comments everyone! I'll get back about it once I have something to show (or ran into a problem, which will likely happen first). If anyone wants to join in on the fun, just PM me. I plan on having this quite robust.
Pages: 12