hi Rajan I have the same problem , and i need to finish my game in 10 days what i have done for now is putting on a JFrame an Image ,this image is the playing Board , and then With the mouseListenerEvent i can locate which Block ( careau in "French" ) is clicked and on each Block there is a JLabel with an Image (this Image is the Piece that can be a castle , soldier ...) and i dont move the pieces i only change the Image on the JLable located on the Playing Board, plus there is a long tests if the move is legal or not. hope i helped you with an idea to start with ,if you have a better one plz tell me ,or if you need my sourceCode you can mail me and ill send it to you . bye
Joined: Jul 01, 2004
Nice to hear that u also work on the same thing, by the way is your game human to human or human to computer? I am looking for human to computer resource.... Anyway could u please mail your source code to email@example.com. Thanks
Hi , I m impressed with ur idea . I m also trying for the same but I am on a basic level . Could u please tell me how can we add image on a frame . Definately I will face some bigger problem in future so could u give me ur mail ID so i can mail u on that . thanks in advance . bye Ankur
There are all kinds of ways to make the GUI on the board. You could do the JLabel version, which is pretty slick. You could write your own custom component by extending JComponent and then overriding the paintComponent() method. You could do it using jME and have the ability to do 3d with lighting effects, though that might be a bit much right now.
If you need to play against the computer, you'll need to look up AI resources. Implementing an AI chess system isn't going to be easy.
1) ditch the GUI (for now) for text input 2) make it modular so you can easily plug one UI for another 3) read up on computer chess, there's tons of websites related to it 4) start with an engine that just validates moves input by the user 5) then add a move generator to replace a human player
I've been thinking of creating a chess program for a long time, never gotten around to making more than a tiny start (that was a few C++ classes I wrote about 10 years ago that I since lost the source of).
The best way to start would be to create logic that obeys all the rules of chess and then a short routine to select the next best offensive move or any offensive move to begin with.
After that you could introduce standard chess openings. If you are not familiar with these, get a beginners book on chess. "Chess in a Nutshell" is good. I don't remember the author.
Once it is working you can get more sophisticated adding a governor of sorts to decide how many moves in advance to plan. Also a routine to identify threatened pieces and possible attacks from the opponent.
Like any complex programming challenge. Lay the ground work by getting the basic functions to work and then build on top of it.
Anxiety does not empty tomorrow of its sorrows, but only empties today of its strength. – Charles Spurgeon