Page 1 of 1
I'm contemplating attempting a PHP chess board.
Posted: Tue Jun 26, 2007 9:02 am
by impulse()
How difficult do you all believe this to be? It wouldn't contain any images as I've never touched image manipulation, but I think an ASCII chess board would work with 2 text boxes (coordinates), 1 dropdown (piece) and a submit button.
I'm thinking at the moment it would work best with 64 functions, one for each square on the board, which are run on every move where move legality is calculated or attack is compared.
In my head at the moment it seems like it's going to be a doddle. Has anybody else attempted PHP chess before and could they tell me if it's a hard game to write.
Regards,
Posted: Tue Jun 26, 2007 9:34 am
by infolock
making it is not very difficult. There are a million chess algorithms out there to help you on your way. it's all up to you.
-Jon
Posted: Tue Jun 26, 2007 9:42 am
by impulse()
I'm hoping to create it from a blank document. I like writing as much as I can myself as long as it doesn't take forever. And I'd say I'm a beginner/intermediate at PHP so I like a good challenge that makes me think of lots of ways to get around situations so I can try unfamiliar things on the way.
If I manage to finish it you will see it appear in the coding critique in the next few days

Posted: Tue Jun 26, 2007 11:47 am
by superdezign
I'd put it together using PHP with JavaScript, and allow the pieces to be draggable. Every time a piece is moved (not just clicked, but moved), it'd trigger a form submission at which point PHP would handle the rest (whether it's a valid move, storing the movement, making attacks, etc.).
Posted: Tue Jun 26, 2007 3:13 pm
by onion2k
Validation of chess moves is harder than it first looks. Finding out whether a player is in check, or checkmate, or stalemate is even harder still. Fortunately it's a problem lots of people have tackled before, so there's plenty of information out there. For most moves you can use a "bit board" idea ... a bit board is a 64 bit int where the 1s and 0s in the number represent a square each. You can validate moves by using bit operations to check if a move is valid. It's very clever, and it's how most modern chess applications work.
http://www.fzibi.com/cchess/bitboards.htm