• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Write Chess Game

 
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no idea about how to build a chess game using Java.
Can somebody give me ideas or any useful links?
 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rajan Chinna
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Omar

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 thiru73@coolgoose.com.
Thanks
 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

HTH,
Aaron R>
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Ranch Hand
Posts: 458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ankur:

Could u please tell me how can we add image on a frame .

Hi!

You can add an image to a JPanel this way:
1� - create your classe "Piece", that extends JPanel;
2� - Insert in the method paintComponent() the image that u want to display

Example:


Here it's a good link:
Chess Program Written in Java

Best regards,
Daniel Botelho
 
reply
    Bookmark Topic Watch Topic
  • New Topic