This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Queen 8 ChessBoard Example Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Queen 8 ChessBoard Example Help" Watch "Queen 8 ChessBoard Example Help" New topic
Author

Queen 8 ChessBoard Example Help

Russell Ray
Ranch Hand

Joined: Apr 25, 2005
Posts: 116
I wanted to post here in hopes someone could provide me some direction of now to fix my problem.:

I have a simple chessboard made up of JPanels for each location on the chessboard. Each JPanel on the board has a JLable inside of it. This label has a color (black or white). As the user clicks on the location from the board, the program swaps out the JPanel with a new one with a Queen image. This seems to be working correctly, however, the application is place a "blank" JPanel to the left of the location where the queen is placed. I opine this is causing a reschuffle of the chessboard.

Could any please give me some pointers on how I can correct this.

Here is the code:


Any assisitance would be greatly appreciated as I have been working with this issue well over three days.

Russ
Russell Ray
Ranch Hand

Joined: Apr 25, 2005
Posts: 116
I figured it out.........

The problem was in the mouseReleaseed method. What was happening was exactly as I thought...... I was removing a JPanel and replacing it with a JLabel...... I didn't think Swing Components was doing this.

Here is the code:




Russ
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Hi, how is your chess program going?
Are you using Alpha-beta pruning. You probably are, it is essential
for any chess program.
Have you managed to implement checkmate and stalemate?
Thats the only problem with mine, you can set it up a position, such as mate in 3, and it will solve it correctly, but however if there are a few
pieces on board, it seems to walk right into stalemate.
I just wondered if you knew how to implement checkmate and stalemate with alpha-beta.
The problem I've found is that the algorithm is too complex to test, even with 3 pieces on the board.
Basically I'm looking for some psuedocode of alpha-beta pruning that incorporates checkmate and stalemate.

Thanks, let me know how your doing if you can.
 
jQuery in Action, 2nd edition
 
subject: Queen 8 ChessBoard Example Help
 
Similar Threads
Chessboard-Newbie Question
chess game : moving piece
display image in jpanel
I need a little guidance
Newbie problem with Event ... MouseListener