So I plan on starting a simple program. I want to make this as OO as possible. The classes I have in mind are:
2. Peice(Pawn, bishop, queen, etc.)
3. Move(Tests legality of move.)
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.
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.. :(
> 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
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.
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 ^^
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.