hi friends,
am a student,pursuing my graduation in computer application...
i am in my efforts to perform a coding for a chess game between two persons who play with each other from different computer systems through internet. i want to know about how i can code in such a manner that when player 1 makes some move, player 2's chess board in his respective screen shows him the move of player 1 and vice versa. this has to happen without reloading the page. i would be very thankful if you can help me out with the logic and idea behind this.

Dwrakh,

I can't offer you any code (it would take me between a week and a month to code this up) but I can explain in principle how to go about it.

Devlop a Chess class in a server-side web language such as PHP. This class will include a data structure to represent the current state of each piece on borad, and methods to accept instructions that represent players' moves, and to serve a visual representation of the board in its current state. You might like to consider method(s) to validate moves to ensure they are legal, within the rules of the game.

You will also need a not-insignificant quantity of client-side (javascript) code to allow users to move the pieces, to communicate with the server (ajax texhniques) and to update each local visual representation of the board. Realistically, you would need to use a javascript lib such as Prototype or JQuery.

I know it's not the point, but there are undoubtedly open source, interactive, thin-client chess applications out there. Google will soon tell you.

I've not looked but I would guess you are into at least 2000 lines of code, maybe two, three or four times that - plus 12 graphics (count them). I havn't included the board itself as this could be very easily built with (D)HTML.

It would be a good one for learning thin-client app building. You would come out the other end having learned LOTS.

Good luck.

Airshow

Well, you allways need to say first, what you really want. If the goal is the big 2D or even 3D animation, look for some Flash forum.
If you really want to play the chess only, then ask the chess community, how do they play the "mail" chess. If you know the game of chess enough, yo know, that the game has a well known and stable start position, and from start to any consequent position you can go through the sequence of legal moves. For each player it is necessary and sufficient to know the last move of opponent, while every chess player makes his own play record. (The game record is equal to the last known position!)
Last move can be sent by mail, e-mail, SMS, and by HTML reuqest, of course. In case you want write more than HTML chess chat, you may:
- at the start of the game
- - create a database table for the new game record
- - send the cookie to both players
- - wait for the first move to start the count down

- by each turn,
- - check the validity of the move
- - record the move and time into the database table
- - create the current position by reading the game record from the beginning while moving the figures
- - because only the player of the last move gets the new position immediately, the opponent must actively poll the server for the new situation in some way (periodical reload of the page ...)

It is possible to enable the current chessboard position to the public (read only) view because they haven't got the "black" neither "white" cookie for the game.

For all of these purposes, the server side application is needed, hence the PHP or the other forum is the best. On the client side, you can use JavaScript for aid of "animation" the move figures on the chessboard and validation even disabling the illegal moves. The database support (like MySQL etc.) could be helpful but the possibility to manipulate with files (on server side) is sufficient.

Keep the full notation (e2-e4) because there is no need to spare the disk space.

This article has been dead for over six months. Start a new discussion instead.